--- /dev/null
+package org.tizen.dynamicanalyzer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.ui.widgets.ConfigurationDialog;
+import org.tizen.dynamicanalyzer.ui.widgets.StopProgressDialog;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+
+public class StateManager {
+ private static final int INIT = 0;
+ private static final int STOP_PROCESS_START = 1;
+ private int state = INIT;
+ private StopProgressDialog dialog = null;
+
+ private static StateManager instance = new StateManager();
+
+ private StateManager() {
+
+ }
+
+ public static StateManager getInstance() {
+ return instance;
+ }
+
+ public void StopProcessStart(){
+ state = STOP_PROCESS_START;
+ Shell shell = AnalyzerUtil.getWorkbenchWindow().getShell();
+ dialog = new StopProgressDialog(shell,
+ SWT.NO_TRIM | SWT.APPLICATION_MODAL); // FIXME
+ dialog.open();
+ }
+
+ public void SaveProjectAndOthers(){
+ if(null != dialog){
+ dialog.setProcessInfomation("save project and others...");
+ dialog.setProcessSelection(20);
+ }
+ }
+
+ public void LogQueueObserverThreadEnd(){
+ if(null != dialog){
+ dialog.setProcessInfomation("Log queue observer thread end");
+ dialog.setProcessSelection(50);
+ }
+ }
+
+ public void StopTrace(){
+ if(null != dialog){
+ dialog.setProcessInfomation("stop trace");
+ dialog.setProcessSelection(100);
+ dialog.close();
+ }
+ }
+}
--- /dev/null
+package org.tizen.dynamicanalyzer.ui.widgets;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.ColorResources;
+import org.tizen.dynamicanalyzer.FontResources;
+
+
+public class StopProgressDialog{
+ private Shell parent = null;
+ private Shell shell = null;
+ private long excuteTime = 10000; //max process time(default 10000 MiliSeconds)
+ private Label processMessage = null;
+ private Label processInfo = null;
+ private ProgressBar progressbar = null;
+ private String message = "please wait....";
+ private String infomation = "start";
+ private int selection = 0;
+ private boolean isClose = false;
+ private static final int DEFAULT_WIDTH = 300;
+ private static final int DEFAULT_HEIGHT = 100;
+ private static final int DEFAULT_MAXIMUM = 100;
+ private static final int TIMER_PERIOD = 10;
+ boolean isChange = false;
+ Timer timer = null;
+ long startTime = 0;
+ long time;
+
+
+ public StopProgressDialog(Shell parent, int style){
+ shell = new Shell(parent, style);
+ this.parent = parent;
+ createContents();
+ }
+
+ public StopProgressDialog(Shell parent, int style, long excuteTime){
+ this(parent, style);
+ this.excuteTime = excuteTime;
+ }
+
+ public void setSize(int width, int height){
+ shell.setSize(width, height);
+ }
+
+ public void setBounds(Rectangle rect){
+ shell.setBounds(rect);
+ }
+
+ public void setLocation(int width, int height){
+ shell.setLocation(width, height);
+ }
+
+ private void setDefaultSize(Rectangle rect){
+ Rectangle size = new Rectangle((rect.x+rect.width)/2 - DEFAULT_WIDTH/2, (rect.y+rect.height)/2 - DEFAULT_HEIGHT/2, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ shell.setBounds(size);
+ }
+
+ public void setProcessMessage(String message){
+ this.message = message;
+ isChange = true;
+// if(null != processMessage)
+// processMessage.setText(message);
+ }
+
+ public void setProcessInfomation(String infomation){
+ this.infomation = infomation;
+ isChange = true;
+// if(null != processInfo)
+// processInfo.setText(infomation);
+ }
+
+ public void setProcessMaximum(int value){
+ progressbar.setMaximum(value);
+ }
+
+ public void setProcessSelection(int value){
+ selection = value;
+ isChange = true;
+// progressbar.setSelection(value);
+ }
+
+ protected void createContents(){
+ setDefaultSize(parent.getBounds());
+ FormLayout dialogLayout = new FormLayout();
+ shell.setLayout(dialogLayout);
+ shell.setBackground(ColorResources.WINDOW_BG_COLOR);
+
+ //Process Message
+ processMessage = new Label(shell, SWT.NONE);
+ processMessage.setText(message);
+ processMessage.setBackground(ColorResources.WINDOW_BG_COLOR);
+ processMessage.setAlignment(SWT.LEFT);
+ processMessage.setForeground(ColorResources.WHITE);
+ processMessage.setFont(FontResources.ABOUT_TEXT);
+
+ //Process Infomation
+ processInfo = new Label(shell, SWT.NONE);
+ processInfo.setText(infomation);
+ processInfo.setBackground(ColorResources.WINDOW_BG_COLOR);
+ processInfo.setAlignment(SWT.LEFT);
+ processInfo.setForeground(ColorResources.WHITE);
+ processInfo.setFont(FontResources.ABOUT_TEXT);
+
+ //Process Bar
+ progressbar = new ProgressBar(shell, SWT.SMOOTH);
+ progressbar.setMaximum(DEFAULT_MAXIMUM);
+
+ //Process Message
+ FormData formData = new FormData();
+ formData.left = new FormAttachment(0, 10);
+ formData.top = new FormAttachment(0, 15);
+ formData.width = 280;
+ formData.height = 22;
+ processMessage.setLayoutData(formData);
+
+ //Process Bar
+ formData = new FormData();
+ formData.left = new FormAttachment(0, 10);
+ formData.top = new FormAttachment(processMessage, 10);
+ formData.width = 280;
+ formData.height = 20;
+ progressbar.setLayoutData(formData);
+
+ //Process Infomation
+ formData = new FormData();
+ formData.left = new FormAttachment(0, 10);
+ formData.top = new FormAttachment(progressbar, 10);
+ formData.width = 280;
+ formData.height = 22;
+ processInfo.setLayoutData(formData);
+ }
+
+ public void open(){
+ shell.open();
+ startTimer();
+ }
+
+ public void close(){
+ isClose = true;
+ }
+
+ public void startTimer(){
+ if(null != timer)
+ stopTimer();
+
+ startTime = System.currentTimeMillis();
+ timer = new Timer();
+
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ time = System.currentTimeMillis() - startTime;
+ if (time > excuteTime || true == isClose) {
+ stopTimer();
+ shell.close();
+ }
+ else if(true == isChange){
+ processMessage.setText(message);
+ processInfo.setText(infomation);
+ progressbar.setSelection(selection);
+ }
+ }
+ });
+ }
+ }, new Date(), TIMER_PERIOD);
+ }
+
+ public void stopTimer(){
+ if(null != timer){
+ timer.cancel();
+ timer = null;
+ }
+ }
+}