[Title]Fix bug when launching app via profile with dynamic analyzer run configuration
authorsanghyunnim.lee <sanghyunnim.lee@samsung.com>
Tue, 5 Mar 2013 01:30:48 +0000 (10:30 +0900)
committersanghyunnim.lee <sanghyunnim.lee@samsung.com>
Tue, 5 Mar 2013 01:30:48 +0000 (10:30 +0900)
[Desc.]
[Issue]redmine #8585; nabi N_SE-26915

org.tizen.dynamicanalysis.ide.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationProfileDelegate.java
org.tizen.dynamicanalysis.ide.eplugin/src/org/tizen/dynamicanalysis/ide/eplugin/launch/TizenNativeApplicationProfileShortcut.java

index 888fe3c..7b5a900 100644 (file)
@@ -56,6 +56,7 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.tizen.common.IApplicationConfiguration;
@@ -93,8 +94,6 @@ import org.tizen.sdblib.SyncService;
 import org.tizen.sdblib.SyncService.SyncResult;
 
 public class TizenNativeApplicationProfileDelegate implements ILaunchConfigurationDelegate {
-       private static TizenNativeApplicationProfileDelegate instance = null;
-
        private final String TOOLS = "tools";// $NON_NLS-1$
        private final String DYNAMIC_ANALYZER = "dynamic-analyzer";// $NON_NLS-1$
        private final String PKG_TYPE = CommonProjectDependentPackager.DEFAULT;
@@ -119,16 +118,6 @@ public class TizenNativeApplicationProfileDelegate implements ILaunchConfigurati
                }
        }
 
-       public static TizenNativeApplicationProfileDelegate getInstance() {
-               if (instance == null) {
-                       instance = new TizenNativeApplicationProfileDelegate();
-               }
-               return instance;
-       }
-
-       private TizenNativeApplicationProfileDelegate() {
-       }
-
        @Override
        public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -235,66 +224,71 @@ public class TizenNativeApplicationProfileDelegate implements ILaunchConfigurati
        private void profileWithDABuild(final IProject project) {
                bSuccessBuild = true;
 
-               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-               ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
+               Display.getDefault().syncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                               ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
 
-               try {
-                       dialog.run(true, true, new IRunnableWithProgress() {
-                               @Override
-                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-                                       monitor.beginTask(Labels.MESSAGE_PREPARING_PROFILE, 1);
-                                       if (verifyDeviceReachability(currentDevice, project)) {
-                                               DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
-                                               bSuccessBuild = false;
-                                               monitor.done();
-                                               return;
-                                       }
+                               try {
+                                       dialog.run(true, true, new IRunnableWithProgress() {
+                                               @Override
+                                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                                       monitor.beginTask(Labels.MESSAGE_PREPARING_PROFILE, 1);
+                                                       if (verifyDeviceReachability(currentDevice, project)) {
+                                                               DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
+                                                               bSuccessBuild = false;
+                                                               monitor.done();
+                                                               return;
+                                                       }
 
-                                       prevBuildConfiguration = ManagedBuildManager.getBuildInfo(project).getConfigurationName();
-                                       prevProfileConfigArch = CommonConfigurationManager.getArchitecture(PlatformChangingManager.getConfigurationByName(project,
-                                                       Activator.PROFILE_BUILD_CONFIGURATION_NAME));
-                                       PlatformChangingManager.changePlatform(project, Activator.PROFILE_BUILD_CONFIGURATION_NAME, currentDevice.getArch().toString());
+                                                       prevBuildConfiguration = ManagedBuildManager.getBuildInfo(project).getConfigurationName();
+                                                       prevProfileConfigArch = CommonConfigurationManager.getArchitecture(PlatformChangingManager.getConfigurationByName(project,
+                                                                       Activator.PROFILE_BUILD_CONFIGURATION_NAME));
+                                                       PlatformChangingManager.changePlatform(project, Activator.PROFILE_BUILD_CONFIGURATION_NAME, currentDevice.getArch().toString());
 
-                                       IProjectLaunchCommand manifest = ProjectUtil.getProjectManifest(project);
-                                       CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project);
+                                                       IProjectLaunchCommand manifest = ProjectUtil.getProjectManifest(project);
+                                                       CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project);
 
-                                       buildPackage(monitor, project, manifest, packager);
-                                       if (bSuccessBuild == false) {
-                                               monitor.done();
-                                               return;
-                                       }
+                                                       buildPackage(monitor, project, manifest, packager);
+                                                       if (bSuccessBuild == false) {
+                                                               monitor.done();
+                                                               return;
+                                                       }
 
-                                       try {
-                                               if (RdsPreferencePage.isRdsMode(project)) {
-                                                       TizenLaunchCommand tizenCommand = new TizenLaunchCommand(currentDevice);
-                                                       RdsDeployer rdsDeployer = new NativeRdsDeployer(project, currentDevice, tizenCommand, null,
-                                                                       CommonProjectDependentPackager.DEFAULT.toLowerCase(), monitor);
-                                                       rdsDeployer.setInterestList(new TizenLaunchInfo().makeInterestList(project));
-                                                       if (!rdsDeployer.deploy()) {
-                                                               normalDeploy(monitor, project, manifest, packager);
+                                                       try {
+                                                               if (RdsPreferencePage.isRdsMode(project)) {
+                                                                       TizenLaunchCommand tizenCommand = new TizenLaunchCommand(currentDevice);
+                                                                       RdsDeployer rdsDeployer = new NativeRdsDeployer(project, currentDevice, tizenCommand, null,
+                                                                                       CommonProjectDependentPackager.DEFAULT.toLowerCase(), monitor);
+                                                                       rdsDeployer.setInterestList(new TizenLaunchInfo().makeInterestList(project));
+                                                                       if (!rdsDeployer.deploy()) {
+                                                                               normalDeploy(monitor, project, manifest, packager);
+                                                                       }
+                                                                       rdsDeployer.pushResInfoFile();
+                                                               } else {
+                                                                       normalDeploy(monitor, project, manifest, packager);
+                                                               }
+                                                       } catch (CoreException e) {
+                                                               bSuccessBuild = false;
+                                                               monitor.done();
+                                                               return;
                                                        }
-                                                       rdsDeployer.pushResInfoFile();
-                                               } else {
-                                                       normalDeploy(monitor, project, manifest, packager);
                                                }
-                                       } catch (CoreException e) {
-                                               bSuccessBuild = false;
-                                               monitor.done();
-                                               return;
-                                       }
+                                       });
+                               } catch (InvocationTargetException e) {
+                                       DALog.printLog(e);
+                                       DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
+                                       bSuccessBuild = false;
+                                       DALog.printLog("TizenNativeApplicationProfileDelegate - profileWithDABuild - InvocationTargetException");
+                               } catch (InterruptedException e) {
+                                       DALog.printLog(e);
+                                       DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
+                                       bSuccessBuild = false;
+                                       DALog.printLog("TizenNativeApplicationProfileDelegate - profileWithDABuild - InterruptedException");
                                }
-                       });
-               } catch (InvocationTargetException e) {
-                       DALog.printLog(e);
-                       DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
-                       bSuccessBuild = false;
-                       DALog.printLog("TizenNativeApplicationProfileDelegate - profileWithDABuild - InvocationTargetException");
-               } catch (InterruptedException e) {
-                       DALog.printLog(e);
-                       DALog.dlgErrorMessage(Labels.MESSAGE_ERROR, Labels.MESSAGE_FAIL_TO_BUILD_PROJECT);
-                       bSuccessBuild = false;
-                       DALog.printLog("TizenNativeApplicationProfileDelegate - profileWithDABuild - InterruptedException");
-               }
+                       }
+               });
        }
 
        private void normalDeploy(IProgressMonitor monitor, IProject project, IProjectLaunchCommand manifest, CommonProjectDependentPackager packager) {
index 0b22615..7c6df54 100755 (executable)
@@ -34,15 +34,15 @@ import org.eclipse.ui.IFileEditorInput;
 
 public class TizenNativeApplicationProfileShortcut implements ILaunchShortcut {
 
-    @Override
-    public void launch(ISelection selection, String mode) {
-        IResource resource = (IResource) ((IStructuredSelection) selection).getFirstElement();
-        TizenNativeApplicationProfileDelegate.getInstance().profileStart(resource.getProject());
-    }
+       @Override
+       public void launch(ISelection selection, String mode) {
+               IResource resource = (IResource) ((IStructuredSelection) selection).getFirstElement();
+               new TizenNativeApplicationProfileDelegate().profileStart(resource.getProject());
+       }
 
-    @Override
-    public void launch(IEditorPart editor, String mode) {
-        IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
-        TizenNativeApplicationProfileDelegate.getInstance().profileStart(input.getFile().getProject());
-    }
+       @Override
+       public void launch(IEditorPart editor, String mode) {
+               IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
+               new TizenNativeApplicationProfileDelegate().profileStart(input.getFile().getProject());
+       }
 }
\ No newline at end of file