[Title]stop progress dialog
authoryeongtaik.byeon <yeongtaik.byeon@samsung.com>
Fri, 29 Jun 2012 09:32:25 +0000 (18:32 +0900)
committeryeongtaik.byeon <yeongtaik.byeon@samsung.com>
Fri, 29 Jun 2012 09:32:25 +0000 (18:32 +0900)
[Type]feature
[Module]StopProgressDialog
[Priority]high
[CQ#]
[Redmine#]5212
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/StateManager.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/threads/LogQueueObservingThread.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/threads/StopLogProcessThread.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/CoolbarArea.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/StopProgressDialog.java [new file with mode: 0644]

diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/StateManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/StateManager.java
new file mode 100644 (file)
index 0000000..468417c
--- /dev/null
@@ -0,0 +1,54 @@
+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();
+               }
+       }
+}
index 4a1dca7..cd52276 100644 (file)
@@ -3,6 +3,7 @@ package org.tizen.dynamicanalyzer.threads;
 import java.util.List;
 
 import org.tizen.dynamicanalyzer.LogSpliter;
+import org.tizen.dynamicanalyzer.StateManager;
 import org.tizen.dynamicanalyzer.constants.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.model.LogQueue;
 import org.tizen.dynamicanalyzer.ui.views.CoolbarArea;
@@ -31,6 +32,7 @@ public class LogQueueObservingThread implements Runnable {
                }
                //FIXME : delete !
                System.out.println("log Queue observer thread end!!"); //$NON-NLS-1$
+               StateManager.getInstance().LogQueueObserverThreadEnd();
                CoolbarArea.getInstance().stopTimer();
        }
 
index 7240141..1cbcb23 100644 (file)
@@ -4,6 +4,7 @@ import org.eclipse.swt.widgets.Display;
 import org.tizen.dynamicanalyzer.AnalyzerManager;
 import org.tizen.dynamicanalyzer.LogSpliter;
 import org.tizen.dynamicanalyzer.SqlManager;
+import org.tizen.dynamicanalyzer.StateManager;
 import org.tizen.dynamicanalyzer.constants.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.model.Project;
 import org.tizen.dynamicanalyzer.ui.views.CoolbarArea;
@@ -25,6 +26,7 @@ public class StopLogProcessThread implements Runnable {
                                        LogSpliter.stopLogQueueObservingThread();
 
                                        System.out.println(" save project and others..."); //$NON-NLS-1$
+                                       StateManager.getInstance().SaveProjectAndOthers();
                                        /****** recording stop and log parsing / operations end!! *****/
                                        /* 1. save Project */
                                        if (!project.isValid()) {
@@ -71,6 +73,8 @@ public class StopLogProcessThread implements Runnable {
                CoolbarArea.getInstance().stopTimer();
 
                System.out.println(" stop trace "); //$NON-NLS-1$
+               StateManager.getInstance().StopTrace();
+               
 
                Display.getDefault().syncExec(new Runnable() {
                        @Override
index 4f20ed7..c4abd8b 100755 (executable)
@@ -33,6 +33,7 @@ import org.tizen.dynamicanalyzer.ColorResources;
 import org.tizen.dynamicanalyzer.DACommunicator;
 import org.tizen.dynamicanalyzer.FontResources;
 import org.tizen.dynamicanalyzer.ImageResources;
+import org.tizen.dynamicanalyzer.StateManager;
 import org.tizen.dynamicanalyzer.constants.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.constants.DesignConstants;
 import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler;
@@ -752,6 +753,7 @@ public class CoolbarArea {
                                                        setStartToolbarState(false);
                                                        // timerClock.stop();
                                                        setToolbarEnablement(true);
+                                                       StateManager.getInstance().StopProcessStart();
                                                }
                                                startButton.setEnabled(false);
                                                AnalyzerUtil.executeCommand(StartStopTraceHandler.ID);
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/StopProgressDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/StopProgressDialog.java
new file mode 100644 (file)
index 0000000..3a6c19f
--- /dev/null
@@ -0,0 +1,189 @@
+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;
+               }
+       }
+}