[Title] Fix. Designe DA Singleton Dlg.
authorphjwithyou.park <phjwithyou.park@samsung.com>
Thu, 2 Aug 2012 04:10:42 +0000 (13:10 +0900)
committerphjwithyou.park <phjwithyou.park@samsung.com>
Thu, 2 Aug 2012 04:10:42 +0000 (13:10 +0900)
[Type] feature
[Module] init
[Priority] normal
[CQ#]
[Redmine#] 6018
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/Application.java
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/ApplicationWorkbenchWindowAdvisor.java
org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/filePage/fileChart/FileChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/AboutDialog.java

index 7aad66c..2bda41a 100644 (file)
 
 package org.tizen.dynamicanalyzer.workbench;
 
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.SocketException;
 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.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;
 
-class Monitor extends Thread {
-       static int portNumber = 6824;
-       public boolean bDARunning = false;
-       
-       public void run( ) {
-               try {
-                       portNumber += 12345;
-                       ServerSocket local = new ServerSocket(portNumber);
-                       local.accept();
-               } catch (SocketException e) {
-                       bDARunning = true;                  
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-       }
-}
 
 public class Application implements IApplication {
 
-       
-       public void RunningDlg( Display display )
-       {
-               
-               Shell dialog = new Shell(display);
-               Shell shell = new Shell(dialog);
-               
-               shell.setSize(460, 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, 206, 206, 206 ) );
-               icon.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
-               
-               // 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, 12);
-               labelData.top = new FormAttachment(0, 6);
-               labelData.height = 64;
-               labelData.width = 46;
-               icon.setLayoutData(labelData);
-
-               labelData = new FormData();
-               labelData.left = new FormAttachment(0, 70);
-               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, 70);
-               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, -40);
-               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();
-           
-       }
-
-
     @Override
     public Object start(IApplicationContext context) throws Exception {
         Display display = PlatformUI.createDisplay();
@@ -155,19 +22,6 @@ public class Application implements IApplication {
                 ApplicationWorkbenchWindowAdvisor.appName = args[1];
             }
 
-                       Monitor monitor_1 =new Monitor( );
-                       monitor_1.start();
-            Thread.sleep(100);
-            
-            Monitor monitors_2 =new Monitor( );
-            monitors_2.start();
-            Thread.sleep(100);
-
-            if ( monitor_1.bDARunning == true && monitors_2.bDARunning == true )
-            {
-                               RunningDlg(display);
-            }
-            
             int returnCode =PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
             if (returnCode == PlatformUI.RETURN_RESTART) {
                 return IApplication.EXIT_RESTART;
index 10abbec..8889f07 100755 (executable)
@@ -1,5 +1,9 @@
 package org.tizen.dynamicanalyzer.workbench;
 
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.SocketException;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
@@ -16,8 +20,30 @@ import org.tizen.dynamicanalyzer.ResourceCommunicator;
 import org.tizen.dynamicanalyzer.constants.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.handlers.ExitHandler;
 import org.tizen.dynamicanalyzer.ui.views.CoolbarArea;
+import org.tizen.dynamicanalyzer.ui.widgets.SingletonInfoDialog;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 
+
+class DAMonitor extends Thread {
+       static int portNumber = 6824;
+       public int bDARunning = -1;
+       
+       public void run( ) {
+               try {
+                       portNumber += 12345;
+                       bDARunning = 0;
+                       ServerSocket local = new ServerSocket(portNumber);
+                       local.accept();
+               } catch (SocketException e) {
+                       bDARunning = 1;             
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       bDARunning = 1;
+               }
+       }
+}
+
+
 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
 
        private static final int DEFAULT_WIDTH = 1024;
@@ -43,18 +69,52 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
 
        @Override
        public void createWindowContents(Shell shell) {
+               System.out.print("createWindowContents\n");
+                 
                CoolbarArea.createInstance(getWindowConfigurer(), shell);
                // CoolbarArea.getInstance().setShellSize(width, height);
+               
+               
+               
+               // Check DA Singleton Dlg.
+               DAMonitor monitor_1 =new DAMonitor( );
+               monitor_1.start();
+               while( monitor_1.bDARunning < 0 ){
+                       try {
+                               Thread.sleep(100);
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+               DAMonitor monitors_2 =new DAMonitor( );
+        monitors_2.start();
+        while( monitors_2.bDARunning < 0 ){
+                       try {
+                               Thread.sleep(100);
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+        if ( monitor_1.bDARunning == 1 && monitors_2.bDARunning == 1 )
+        {
+               Shell shells = AnalyzerUtil.getWorkbenchWindow().getShell();
+               SingletonInfoDialog dialog = new SingletonInfoDialog(shells, SWT.NONE); // FIXME        
+                       dialog.open();
+                       
+        }
        }
 
        @Override
        public void preWindowOpen() {
-               Monitor[] monitors = PlatformUI.getWorkbench().getDisplay()
-                               .getMonitors();
+               System.out.print("preWindowOpen\n");
+               
+               Monitor[] monitors = PlatformUI.getWorkbench().getDisplay().getMonitors();
+               
                Rectangle rectangle = null;
+               
                rectangle = monitors[0].getBounds();
-               if (rectangle.width < DEFAULT_WIDTH
-                               || rectangle.height < DEFAULT_HEIGHT) {
+               
+               if (rectangle.width < DEFAULT_WIDTH || rectangle.height < DEFAULT_HEIGHT) {
                        width = MIN_WIDTH;
                        height = MIN_HEIGHT;
                }
@@ -63,9 +123,12 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
                configurer.setInitialSize(new Point(width, height));
                configurer.setShowStatusLine(false);
                configurer.setShellStyle(SWT.SHELL_TRIM/* | SWT.NO_BACKGROUND */);
+               
        }
 
        public void postWindowOpen() {
+               System.out.print("postWindowOpen\n");
+               
 
                PathManager.pathCheck();
 
@@ -77,6 +140,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
 
        public boolean preWindowShellClose() {
 
+               System.out.print("preWindowShellClose\n");
                if (ResourceCommunicator.isRunning()) {
                        ResourceCommunicator.sendMessage(AnalyzerConstants.MSG_STOP
                                        + AnalyzerConstants.CMD_SPLIT + 0
index a163069..a1ca3e2 100644 (file)
@@ -27,4 +27,5 @@ Export-Package: org.tizen.dynamicanalyzer,
  org.tizen.dynamicanalyzer.constants,
  org.tizen.dynamicanalyzer.handlers,
  org.tizen.dynamicanalyzer.ui.views,
+ org.tizen.dynamicanalyzer.ui.widgets,
  org.tizen.dynamicanalyzer.utils
index 6c34aea..5e54772 100644 (file)
@@ -22,6 +22,12 @@ public class AnalyzerLabels {
        public static String ABOUT;
        public static String LICENSE;
        public static String CONFIGURATION;
+       
+       
+       // SingletonInfoDlg.
+       public static String SINGLETON_INFO_DLG_TITLE;
+       public static String SINGLETON_INFO_DLG_MESSAGE_1;
+       public static String SINGLETON_INFO_DLG_MESSAGE_2;
 
        // Source tooltip
        public static String SOURCE_NOT_EXIST;
index 23ae459..d2a0fb3 100644 (file)
@@ -16,6 +16,13 @@ ABOUT=About Dynamic Analyzer
 LICENSE=License Dynamic Analyzer
 CONFIGURATION=Configuration Dynamic Analyzer
 
+
+# SingletonInfoDlg.
+SINGLETON_INFO_DLG_TITLE = Info
+SINGLETON_INFO_DLG_MESSAGE_1 = Can not launch Dynamic Analzer.
+SINGLETON_INFO_DLG_MESSAGE_2 = Another one with the same user name is running now.
+       
+       
 #Source tooltip
 SOURCE_NOT_EXIST=Source file does not exist.
 
index f03af03..55bd0df 100644 (file)
@@ -337,38 +337,43 @@ public class FileChartManager {
                                try
                                {
 
+                                       child.getLastData().getRelations().add(seqNum);
+                                       
                                        long time = Long.parseLong(input.get(LogCenterConstants.TIME_INDEX));
                                        if (child.getLastData().getFirstTime() < 0)
                                        {
+                                               System.out.print("setFirstTime 1 \n");
                                                child.getLastData().setFirstTime(time);
                                                child.getLastData().setLastTime(time);
                                        } 
                                        else 
                                        {
+                                               System.out.print("setLastTime 1 \n");
                                                child.getLastData().setLastTime(time);
                                        }
 
                                        
-                                       child.getLastData().getRelations().add(seqNum);
                                        parent = getFileRegister().get(child.getParentKey());
                                        if ( parent.getLastData().getFirstTime() < 0)
                                        {       
+                                               System.out.print("setFirstTime 2 \n");
+                                               
                                                parent.getLastData().setFirstTime(time);
                                                parent.getLastData().setLastTime(time);
                                        } 
                                        else 
                                        {
+                                               System.out.print("setLastTime 2 \n");
+                                               
                                                parent.getLastData().setLastTime(time);
-
                                        }
                                
 
+                                       
+                                       
                                        // calculate read/write size
                                        String rwSizeStr1 = input.get(LogCenterConstants.RESOURCE_SIZE_INDEX);
                                        long rwSize = Long.parseLong(rwSizeStr1);
-                                       System.out.print("rwSize1 "+rwSize+"\n");
-                                       
-                                       
                                        if (fdApiType.equals(LogCenterConstants.FD_API_TYPE_READ)) 
                                        {
                                                long rSize = child.getReadSize();
@@ -425,8 +430,88 @@ public class FileChartManager {
                                parentCalled.getCalledFunctionData().add(ffd);
                                AnalyzerManager.getCalledFunctionChecker().getFailedList().add(ffd);
                        
+                               
+                               
                                // Insert File API List Table
-                               fcid.getLastData().getRelations().add(seqNum);
+                       //      fcid.getLastData().getRelations().add(seqNum);
+                               
+                               
+                               FileChartItemData child = getFDRegister().get(fd);
+                               if (null == child) {
+                                       continue;
+                               }
+                               
+                               FileChartItemData parent = null;
+                               try
+                               {
+
+                                       child.getLastData().getRelations().add(seqNum);
+                                       
+                                       long time = Long.parseLong(input.get(LogCenterConstants.TIME_INDEX));
+                                       if (child.getLastData().getFirstTime() < 0)
+                                       {
+                                               System.out.print("setFirstTime 1 \n");
+                                               child.getLastData().setFirstTime(time);
+                                               child.getLastData().setLastTime(time);
+                                       } 
+                                       else 
+                                       {
+                                               System.out.print("setLastTime 1 \n");
+                                               child.getLastData().setLastTime(time);
+                                       }
+
+                                       
+                                       parent = getFileRegister().get(child.getParentKey());
+                                       if ( parent.getLastData().getFirstTime() < 0)
+                                       {       
+                                               System.out.print("setFirstTime 2 \n");
+                                               
+                                               parent.getLastData().setFirstTime(time);
+                                               parent.getLastData().setLastTime(time);
+                                       } 
+                                       else 
+                                       {
+                                               System.out.print("setLastTime 2 \n");
+                                               
+                                               parent.getLastData().setLastTime(time);
+                                       }
+                               
+
+                                       
+                                       
+                                       // calculate read/write size
+                                       String rwSizeStr1 = input.get(LogCenterConstants.RESOURCE_SIZE_INDEX);
+                                       long rwSize = Long.parseLong(rwSizeStr1);
+                                       if (fdApiType.equals(LogCenterConstants.FD_API_TYPE_READ)) 
+                                       {
+                                               long rSize = child.getReadSize();
+                                               child.setReadSize(rSize + rwSize);
+                                               long prSize = parent.getReadSize();
+                                               parent.setReadSize(child.getReadSize() + prSize);
+                                       } 
+                                       else if (fdApiType.equals(LogCenterConstants.FD_API_TYPE_WRITE)) 
+                                       {
+                                               String strTotalSize = input.get(LogCenterConstants.RESOURCE_FILE_SIZE_INDEX);
+                                               if ( strTotalSize.equals("?") == false )
+                                               {
+                                                       long totalSize = Long.parseLong(strTotalSize);
+                                                       child.setTotalSize(totalSize);  
+                                               }
+                                               
+                                               long wSize = child.getWriteSize();
+                                               child.setWriteSize( wSize + rwSize );
+                                               long pwSize = parent.getWriteSize();
+                                               parent.setWriteSize( child.getWriteSize() + pwSize);
+                                       }
+
+                               } 
+                               catch (NullPointerException e)
+                               {
+                                       System.out.println("why"); //$NON-NLS-1$
+                                       e.printStackTrace();
+                               }
+                               
+                               
                        }
                }
        }
index d358dab..59ad22c 100644 (file)
@@ -9,8 +9,10 @@ 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.Shell;
+import org.eclipse.ui.PlatformUI;
 import org.tizen.dynamicanalyzer.ColorResources;
 import org.tizen.dynamicanalyzer.ConfigureManager;
 import org.tizen.dynamicanalyzer.FontResources;
@@ -170,6 +172,18 @@ public class AboutDialog {
                licenseButton.setLayoutData(okData);
 
                shell.open();
+               
+               Display display = PlatformUI.createDisplay();
+
+           while (!shell.isDisposed()) {
+             if (!display.readAndDispatch())
+                 display.sleep();
+           }
+           
+           shell.dispose();
+           
+               
+               
                return 0;
        }
 }