[Title] DA Singleton Add Feature - Dlg.
authorphjwithyou.park <phjwithyou.park@samsung.com>
Tue, 31 Jul 2012 10:28:50 +0000 (19:28 +0900)
committerphjwithyou.park <phjwithyou.park@samsung.com>
Tue, 31 Jul 2012 10:28:50 +0000 (19:28 +0900)
[Type] Feature
[Module] DA - Init.
[Priority] normal
[CQ#]
[Redmine#] 6013
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/Application.java

index 4df7116..4b182a0 100644 (file)
@@ -8,25 +8,43 @@ import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 import org.eclipse.equinox.app.IApplication;
 import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.PlatformUI;
 import org.tizen.dynamicanalyzer.constants.AnalyzerConstants;
 
 public class Application implements IApplication {
 
-       public boolean Monitor()
+       
+       public boolean Monitor( Display display )
        {
+
                File file = null;
                FileLock fileLock = null;
                FileChannel fchannel = null;
                String defaultPath = null;
+               String filePath = null;         
 
                if (System.getProperty(AnalyzerConstants.OS_KEY).toLowerCase().indexOf(AnalyzerConstants.LINUX) >= 0) {
                        defaultPath = System.getenv(AnalyzerConstants.LINUX_INSTALL_ENV) + "/tizen-sdk/tools/dynamic-analyzer/runFile";
+                       filePath = System.getenv(AnalyzerConstants.LINUX_INSTALL_ENV) + "/configuration/org.eclipse.osgi/bundles/33/1/.cp/theme/white/img/64_DA_icon.png";
+                       
                }
                else if(System.getProperty(AnalyzerConstants.OS_KEY).toLowerCase().indexOf(AnalyzerConstants.WIN) >= 0){
                        defaultPath = "C:\\tizen-sdk\\tools\\dynamic-analyzer\\runFile";
+                       filePath = "C:\\tizen-sdk\\tools\\dynamic-analyzer\\configuration\\org.eclipse.osgi\\bundles\\33\\1\\.cp\\theme\\white\\img\\64_DA_icon.png";
                }
                else {
                        return false;
@@ -37,7 +55,106 @@ public class Application implements IApplication {
                        fchannel = new RandomAccessFile(file, "rw").getChannel();
                        fileLock = fchannel.tryLock();
                        if (fileLock == null) {
+       
                                System.out.println("Application Running fileLock "+defaultPath+"\n");
+                               
+                               Shell dialog = new Shell(display);
+                               Shell shell = new Shell(dialog);
+                               
+                               shell.setSize(446, 153);
+                               FormLayout shellLayout = new FormLayout();
+                               shell.setLayout(shellLayout);
+                               shell.setText("Info");
+
+                               Composite base = new Composite(shell, SWT.NONE);
+                               base.setLayout(new FormLayout());
+                               FormData baseData = new FormData();
+                               baseData.top = new FormAttachment(0, 0);
+                               baseData.left = new FormAttachment(0, 0);
+                               baseData.right = new FormAttachment(100, 0);
+                               baseData.height = 76;
+                               base.setLayoutData(baseData);
+                               base.setVisible(true);
+                               base.setBackground( new Color( display, 206, 206, 206 )  );
+
+                               // Icon
+                               Label icon = new Label(base, SWT.TRANSPARENT);
+                               icon.setBackground( new Color( display, 160, 160, 160 ) );
+                               icon.setImage( new Image(display, filePath) );
+                               
+                               // Contents
+                               Label dlgMessage = new Label(base, SWT.TRANSPARENT);
+                               dlgMessage.setText("Can not launch Dynamic Analzer.");
+                               dlgMessage.setBackground( new Color( display, 206, 206, 206 ));
+                               dlgMessage.setAlignment(SWT.LEFT);
+                               dlgMessage.setForeground( new Color( display, 0, 0, 0 ) );
+
+                               Label buildTime = new Label(base, SWT.TRANSPARENT);
+                               buildTime.setText("another one with the same user name is running now. "); //$NON-NLS-1$
+                               buildTime.setBackground( new Color( display, 206, 206, 206 ) );
+                               buildTime.setAlignment(SWT.LEFT);
+                               buildTime.setForeground( new Color( display, 0, 0, 0 ) );
+
+                               FormData labelData = new FormData();
+                               labelData.left = new FormAttachment(0, 15);
+                               labelData.top = new FormAttachment(0, 6);
+                               labelData.height = 64;
+                               labelData.width = 64;
+                               icon.setLayoutData(labelData);
+
+                               labelData = new FormData();
+                               labelData.left = new FormAttachment(0, 95);
+                               labelData.right = new FormAttachment(100, 0);
+                               labelData.top = new FormAttachment(0, 17);
+                               labelData.height = 22;
+                               dlgMessage.setLayoutData(labelData);
+
+                               labelData = new FormData();
+                               labelData.left = new FormAttachment(0, 95);
+                               labelData.right = new FormAttachment(100, 0);
+                               labelData.top = new FormAttachment(0, 39);
+                               labelData.height = 22;
+                               buildTime.setLayoutData(labelData);
+                               
+                               Composite buttonComp = new Composite(shell, SWT.NONE);
+                               FormLayout compLayout = new FormLayout();
+                               buttonComp.setLayout(compLayout);
+                               buttonComp.setBackground( new Color( display, 240, 240, 240 ) );
+
+                               FormData compData = new FormData();
+                               compData.top = new FormAttachment(base, 0);
+                               compData.left = new FormAttachment(0, 0);
+                               compData.right = new FormAttachment(100, 0);
+                               compData.bottom = new FormAttachment(100, 0);
+                               buttonComp.setLayoutData(compData);
+
+                               Button okButton = new Button(buttonComp, SWT.NONE);
+                               okButton.setText("OK"); //$NON-NLS-1$
+                               FormData okData = new FormData();
+                               okData.top = new FormAttachment(0, 10);
+                               okData.right = new FormAttachment(100, -20);
+                               okData.width = 100;
+                               okData.height = 34;
+                               okButton.setLayoutData(okData);
+                               okButton.addListener(SWT.Selection, new Listener() {
+                                       public void handleEvent(Event e) {
+                                               switch (e.type) {
+                                               case SWT.Selection:
+                                                       System.exit(-1);
+                                                       break;
+                                               }
+                                       }
+                               });
+                               shell.open();
+                               
+                           while (!shell.isDisposed()) {
+                             if (!display.readAndDispatch())
+                               display.sleep();
+                           }
+                           shell.dispose();
+                           
+                           
+                           
                                System.exit(-1);
                                return false;
                        }
@@ -60,7 +177,7 @@ public class Application implements IApplication {
                 ApplicationWorkbenchWindowAdvisor.appName = args[1];
             }
                     
-            Monitor();
+            Monitor( display);
             
             int returnCode =PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());