import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
- import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.ui.widgets.ProgressDialog;
+ import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
public class StartProcessManager implements Runnable {
- private static ProgressDialog dialog = null;
+ private static StartProgressDialog dialog = null;
private static int count = 1;
+ private static boolean canceled = false;
private static StartProcessManager instance = new StartProcessManager();
}
public void startProcessStart(String waitMessage) {
- Shell shell = AnalyzerUtil.getWorkbenchWindow().getShell();
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
- dialog = new ProgressDialog(shell);
+ dialog = new StartProgressDialog(shell, SWT.ON_TOP);
if (null != dialog) {
dialog.open();
+// AnalyzerManager.setExit(false);
+ canceled = false;
dialog.setProgressMessage(waitMessage);
dialog.setProgressInfo(AnalyzerLabels.STOP_PROCESS_DLG_PLEASE_WAIT);
+ dialog.setCancelListener(new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+// AnalyzerManager.setExit(true);
+ canceled = true;
+ ToolbarArea.getInstance().stopTrace();
+ }
+ });
}
Thread thread = new Thread(new StartProcessManager());
--- /dev/null
- ToolbarArea.getInstance().setEnabled(false);
+package org.tizen.dynamicanalyzer.ui.toolbar;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.helper.ColorResources;
+import org.tizen.dynamicanalyzer.widgets.helper.FontResources;
+import org.tizen.dynamicanalyzer.widgets.helper.WidgetUtils;
+import org.tizen.dynamicanalyzer.widgets.progress.Progress;
++import org.tizen.dynamicanalyzer.workbench.LayoutManager;
+
+public class StartProgressDialog {
+ private Shell shell = null;
+ private Progress progress = null;
+
+ private Listener shellMouseListener = new Listener() {
+ boolean down = false;
+ Point downPoint = new Point(0, 0);
+
+ @Override
+ public void handleEvent(Event event) {
+ int id = event.type;
+ if (event.widget instanceof Progress) {
+
+ Shell shell = (Shell) ((Progress) event.widget).getParent();
+ switch (id) {
+ case SWT.MouseDown:
+ downPoint.x = event.x;
+ downPoint.y = event.y;
+ down = true;
+ break;
+ case SWT.MouseUp:
+ down = false;
+ break;
+ case SWT.MouseMove:
+ if (down) {
+ Point p = shell.getLocation();
+ p.x = p.x + (event.x - downPoint.x);
+ p.y = p.y + (event.y - downPoint.y);
+ shell.setLocation(p);
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ down = false;
+ }
+ }
+ };
+
+ public StartProgressDialog(Shell parent, int style) {
+ shell = new Shell(parent, style);
+ shell.setSize(300, 110);
+ shell.setLayout(new FillLayout());
+
+ progress = new Progress(shell, SWT.NONE, Progress.PROGRESS_STYLE_CANCEL);
+
+ progress.setBarStartColor(ColorResources.STOP_PROGRESS_BAR_START_COLOR);
+ progress.setBarEndColor(ColorResources.STOP_PROGRESS_BAR_END_COLOR);
+ progress.setBarStartBackgroundColor(ColorResources.STOP_PROGRESS_BAR_BG_START_COLOR);
+ progress.setBarEndBackgroundColor(ColorResources.STOP_PROGRESS_BAR_BG_END_COLOR);
+ progress.setBarOutlineColor(ColorResources.STOP_PROGRESS_BAR_OUTLINE_COLOR);
+ progress.setDialogOutlineColor1(ColorResources.STOP_PROGRESS_LINE1_COLOR);
+ progress.setDialogOutlineColor2(ColorResources.STOP_PROGRESS_LINE2_COLOR);
+ progress.setProgressUpperFont(FontResources.STOP_PROGRESS_FONT);
+ progress.setProgressLowerFont(FontResources.PROGRESS_FONT);
+ progress.setProgressUpperFontColor(ColorResources.BLACK);
+ progress.setProgressLowerFontColor(ColorResources.STOP_PROGRESS_INFO_FONT_COLOR);
+ progress.setBarBackgroundColor(ColorResources.STOP_PROGRESS_BACKGROUND_COLOR);
+
+ WidgetUtils.setCenter(shell);
+
+ shell.getDisplay().addFilter(SWT.MouseDown, shellMouseListener);
+ shell.getDisplay().addFilter(SWT.MouseUp, shellMouseListener);
+ shell.getDisplay().addFilter(SWT.MouseMove, shellMouseListener);
+
+ shell.addListener(SWT.Traverse, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.detail == SWT.TRAVERSE_ESCAPE) {
+ event.doit = false;
+ }
+ }
+ });
+ }
+
+ public void open() {
+ shell.open();
- ToolbarArea.getInstance().setEnabled(true);
++ LayoutManager.setEnabled(false);
+ }
+
+ public void close() {
+ if (null != progress) {
+ if (!progress.isDisposed()) {
+ progress.close();
+ progress.dispose();
+ }
+ progress = null;
+ }
+ if (null != shell) {
+ if (!shell.isDisposed()) {
+ shell.dispose();
+ }
+ shell = null;
+ }
+
++ LayoutManager.setEnabled(true);
+ }
+
+ public void setProgressMessage(String message) {
+ progress.setUpperText(message);
+ }
+
+ public void setProgressInfo(String infoMessage) {
+ progress.setBottomText(infoMessage);
+ }
+
+ public void setValue(int value) {
+ progress.setValue(value);
+ }
+
+ public void setValues(String progressMessage, int value) {
+ progress.setUpperText(progressMessage);
+ progress.setValue(value);
+ }
+
+ public void errorOccurred(String message, String bottomMessage) {
+ progress.errorOccured(message, bottomMessage);
+ }
+
+ public void setCancelListener(DACustomButtonClickEventListener listener) {
+ if (progress != null) {
+ progress.setCancelButtonListener(listener);
+ }
+ }
+
+ public void setCancelEnabled(final boolean enable) {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (null != progress) {
+ progress.getCancelButton().setButtonEnabled(enable);
+ }
+ }
+ });
+ }
+}