LAUNCH: Supported setting command, arguments and environments when
authordonghyuk.yang <donghyuk.yang@samsung.com>
Sat, 29 Mar 2014 13:13:49 +0000 (22:13 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Sat, 29 Mar 2014 13:13:49 +0000 (22:13 +0900)
launching
LAUNCH: Supported setting .core and .cs file when coredump debugging.

There are two main changes:
 - Users can set command, arguments and environments when launching
platform module.
 - Users can set both .core and .cs files when coredump debugging.

And there are a good other changes:
 - Changed launch wizard UI
 - Find debug packages automatically if user set the command.
 - Validate launch command.

Change-Id: I5e4aa7bd21b28ef810e8f2b56184b01d63c72080
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
58 files changed:
org.tizen.nativeplatform/META-INF/MANIFEST.MF
org.tizen.nativeplatform/OSGI-INF/l10n/bundle.properties
org.tizen.nativeplatform/plugin.xml
org.tizen.nativeplatform/src/org/tizen/nativeplatform/IPlatformXMLStore.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/PlatformProject.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/coredump/CoredumpPreprocessor.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/coredump/CoredumpSelectionHandler.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/coredump/model/CoredumpModel.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/filefilter/XmlFileFilter.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/CoredumpLaunchConfigurationProcessor.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ILaunchConfigurationProcessor.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchCommandCancelThread.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchConfigurationProcessor.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForCoredump.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenPlatformDebugger.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/IAppIdChangeListener.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformArgumentsTab.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformLaunchConfigurationTabGroup.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainAttachTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainCoreTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformPackagesTab.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectDebugShortcut.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/LaunchWizardPageUIMessages.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformEFLLaunchSettingPage.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java [deleted file]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java [deleted file]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingCorePage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingPage.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingProcPage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/EnvironmentDialog.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LogTabDialog.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformCommonLaunchWizard.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformCoredumpLaunchWizard.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/manifest/PlatformManifestXMLStore.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgLauncher.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgLauncherFactory.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmDebugPackagesResolver.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmStatusUpdater.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/RpmTool.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/ZypperTool.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerOutputReceiver.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java

index 45ab60c..e4d9b9e 100644 (file)
@@ -27,7 +27,10 @@ Import-Package: org.eclipse.cdt.debug.core,
  org.eclipse.cdt.debug.internal.ui.launch,
  org.eclipse.cdt.debug.mi.core,
  org.eclipse.cdt.debug.mi.core.cdi,
+ org.eclipse.cdt.debug.mi.core.cdi.model,
+ org.eclipse.cdt.debug.mi.core.command,
  org.eclipse.cdt.debug.mi.core.command.factories,
+ org.eclipse.cdt.debug.mi.core.output,
  org.eclipse.cdt.debug.ui,
  org.eclipse.cdt.launch,
  org.eclipse.cdt.launch.internal.ui,
index 33cefd5..377abb1 100644 (file)
@@ -24,10 +24,12 @@ Buildpackage.label=Build Package
 
 ## Launch shorcut
 Platformlaunch.run=Tizen Platform Project
+Platformlaunch.debug=Tizen Platform Project
 Platformlaunch.run.desc=Runs a Tizen Platform Project
 Platformlaunch.debug.desc=Debugs a Tizen Platform Project
 Platformlaunch.debug.attach=Tizen Platform Project - Attach
 Platformlaunch.debug.attach.desc=Attach Debugs a Tizen Platform Project
+Platformlaunch.debug.coredump=Tizen Platform Project - Coredump
 
 ## Launch configuration tabs
 Platformlaunch.conf.tab=Tizen Platform Project Main Tab
index c55f622..a50ebf6 100644 (file)
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"
             name="%Platformlaunch.run"
             public="true"/>
-
+        <launchConfigurationType
+            delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
+            id="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType"
+            name="%Platformlaunch.debug"
+            public="true"/>      
+               <!--
         <launchConfigurationType
             delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"
             name="%Platformlaunch.debug.attach"
             public="true"/>
-
+               -->
         <launchConfigurationType
             delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCoredump"
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"
-            name="Tizen Platform Project - Coredump"
+            name="%Platformlaunch.debug.coredump"
             public="true"/>
 
     </extension>
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
             configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType.image"/>
-
+        <launchConfigurationTypeImage
+            icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
+            configTypeID="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType"
+            id="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType.image"/>            
+               <!--
         <launchConfigurationTypeImage
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Attach.gif"
             configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach.image"/>
-
+               -->
         <launchConfigurationTypeImage
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Core.gif"
             configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"
         <launchDelegate
             delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
             id="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
-            modes="run,debug"
+            modes="run"
             name="%Platformlaunch.run"
-            delegateDescription="The Tizen Platform Project Launcher supports running Tizen application on device"
+            delegateDescription="The Tizen Platform Project Launcher supports running Tizen platform module"
             sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
             sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
             type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"/>
-
+        <launchDelegate
+            delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
+            id="org.tizen.nativeplatform.debug.PlatformLaunchDelegate"
+            modes="debug"
+            name="%Platformlaunch.debug"
+            delegateDescription="The Tizen Platform Project Launcher supports debugging Tizen platform module"
+            sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
+            sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
+            type="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType"/>              
+               <!--
         <launchDelegate
             delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
             id="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
             sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
             sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
             type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"/>
-
+               -->
         <launchDelegate
             delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCoredump"
             id="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCoredump"
             class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
             id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
             type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"/>
-
+        <launchConfigurationTabGroup
+            class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
+            id="org.tizen.nativeplatform.debug.ui.PlatformLaunchConfigurationTabGroup"
+            type="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType"/>             
+               <!--
         <launchConfigurationTabGroup
             class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
             id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
             type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"/>
-
+               -->
         <launchConfigurationTabGroup
             class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
             id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
 
     <extension
         point="org.eclipse.debug.ui.launchConfigurationTabs">
+        <!--
         <tab
             id="org.tizen.nativeplatform.launch.ui.PlatformMainTab"
             group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
             name="%Platformlaunch.conf.tab"
             class="org.tizen.nativeplatform.launch.ui.PlatformMainTab">
             <associatedDelegate delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"/>
-        </tab>
-
+        </tab>         
         <tab
             id="org.tizen.nativeplatform.launch.ui.PlatformMainAttachTab"
             group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
             class="org.tizen.nativeplatform.launch.ui.PlatformMainAttachTab">
             <associatedDelegate delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"/>
         </tab>
-
+               -->
         <tab
             id="org.tizen.nativeplatform.launch.ui.PlatformMainCoreTab"
             group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
         <shortcut
             label="%Platformlaunch.run"
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
-            modes="run,debug"
+            modes="run"
             class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectLaunchShortcut"
             id="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectLaunchShortcut">
         <contextualLaunch>
 
         <description
             mode="run"
-            description="%Platformlaunch.run.desc"/>
+            description="%Platformlaunch.run.desc"/>        
+        <configurationType
+            id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType">
+        </configurationType>
+        </shortcut>
+        
+        <shortcut
+            label="%Platformlaunch.debug"
+            icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
+            modes="debug"
+            class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectDebugShortcut"
+            id="org.tizen.nativeplatform.debug.ui.shortcut.PlatformProjectLaunchShortcut">
+        <contextualLaunch>
+         <enablement>
+            <with
+                  variable="selection">
+               <count
+                     value="1">
+               </count>
+               <iterate>
+                     <adapt
+                           type="org.eclipse.core.resources.IResource">
+                        <test
+                              property="org.eclipse.core.resources.projectNature"
+                              value="org.tizen.nativeplatform.tizenPlatformNature">
+                        </test>
+                     </adapt>
+               </iterate>
+            </with>
+         </enablement>
+      </contextualLaunch>
+      
         <description
             mode="debug"
             description="%Platformlaunch.debug.desc"/>
         <configurationType
-            id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType">
+            id="org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType">
         </configurationType>
-        </shortcut>
-
+        </shortcut>        
+               <!--
         <shortcut
             label="%Platformlaunch.debug.attach"
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Attach.gif"
             id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach">
         </configurationType>
         </shortcut>
-
+               -->
         <shortcut
             label="Tizen Platform Project - Coredump"
             icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Core.gif"
index a790f35..96965b3 100644 (file)
@@ -44,6 +44,13 @@ public interface IPlatformXMLStore {
     public String getAppId(String programPath);
 
     /**
+     * Returns application's id list.
+     * 
+     * @return application's id list.
+     */
+    public String[] getAppId();
+
+    /**
      * Returns icon file list of this xml store.
      * 
      * @return list of icon files.
index aa33fcc..d457254 100644 (file)
@@ -116,7 +116,7 @@ public class PlatformProject extends AbstractTizenProject implements ITizenProje
     public boolean isEFLApplication() {
         File projectPath = project.getLocation().toFile();
         // get ".xml" file list
-        String[] files = projectPath.list(new XmlFileFilter());
+        String[] files = projectPath.list(new XmlFileFilter(true));
         // return false if ".xml" file does not exist
         for (String file : files) {
             if (file.trim().startsWith(PKG_PREFIX)) {
index 787d236..8d4ee8b 100644 (file)
@@ -164,13 +164,15 @@ public class CoredumpPreprocessor {
             for (String so : solist) {
                 checkCancelProcess(monitor);
                 monitor.subTask(String.format("Getting provider of %s", so));
-                Map<String, PkgStatus> wp = commander.getWhatProvides(so);
+                Map<String, PkgStatus> wp = commander.getWhatProvides(so, TOOL.ZYPPER);
                 if (wp == null) {
                     monitor.worked(1);
                     continue;
                 }
                 for (String pkgName : wp.keySet()) {
-                    requiredPackages.add(pkgName);
+                    if (!requiredPackages.contains(pkgName)) {
+                        requiredPackages.add(pkgName);
+                    }
                 }
                 monitor.worked(1);
             }
@@ -230,9 +232,18 @@ public class CoredumpPreprocessor {
         try {
             for (String pkg : pkglist) {
                 checkCancelProcess(monitor);
-                String[] debugPkgs = getDebugPackageName(pkg);
-                debugPackages.add(debugPkgs[0]);
-                debugPackages.add(debugPkgs[1]);
+                resetLogAndMessage();
+                String[] debugPkgs = PlatformLaunchUtil.getDebugPackageName(commander, pkg);
+                if (!debugPackages.contains(debugPkgs[0])) {
+                    debugPackages.add(debugPkgs[0]);
+                }
+                if (!debugPackages.contains(debugPkgs[1])) {
+                    debugPackages.add(debugPkgs[1]);
+                }
+                String develPkg = PlatformLaunchUtil.getDevelPackageName(commander, pkg);
+                if (!debugPackages.contains(develPkg)) {
+                    debugPackages.add(develPkg);
+                }
                 monitor.worked(1);
             }
         } finally {
@@ -241,20 +252,6 @@ public class CoredumpPreprocessor {
         return debugPackages;
     }
 
-    private String[] getDebugPackageName(String binaryPkg) throws InterruptedException {
-        resetLogAndMessage();
-        String sourcePackage = commander.getSrcPkgName(binaryPkg);
-        String[] result = new String[2];
-        if (sourcePackage.isEmpty()) {
-            result[0] = binaryPkg + "-debuginfo";
-            result[1] = binaryPkg + "-debugsource";
-        } else {
-            result[0] = sourcePackage + "-debuginfo";
-            result[1] = sourcePackage + "-debugsource";
-        }
-        return result;
-    }
-
     private void checkCancelProcess(IProgressMonitor monitor) throws InterruptedException {
         if (monitor.isCanceled()) {
             log = commander.getLogs();
index b22c138..1a9e36b 100644 (file)
@@ -32,7 +32,33 @@ public class CoredumpSelectionHandler {
         this.target = target;
     }
 
-    public String[] processRemoteCorefile(FileEntry corefileEntry, IProgressMonitor monitor)
+    public String processRemoteCorefile(FileEntry entry, IProgressMonitor monitor)
+            throws CoreException, Exception {
+        return processRemoteFile(entry, "core", monitor);
+    }
+
+    public String processRemoteCsfile(FileEntry entry, IProgressMonitor monitor)
+            throws CoreException, Exception {
+        return processRemoteFile(entry, "cs", monitor);
+    }
+
+    public String processRemoteFile(FileEntry entry, String ext, IProgressMonitor monitor)
+            throws CoreException, Exception {
+        monitor.beginTask("", 1);
+        monitor.subTask(String.format("Downloading %s file...", ext));
+        try {
+            String workingDir = CommandLauncherUtil.getCoredumpDir();
+            FileUtil.createDirectory(workingDir);
+            String path = entry.getFullPath();
+            String fileName = new Path(path).lastSegment();
+            String destFilePrefix = new Path(workingDir).append(fileName).toOSString();
+            return downloadFile(entry, destFilePrefix, ext);
+        } finally {
+            monitor.done();
+        }
+    }
+
+    public String[] processRemoteArchiveFile(FileEntry corefileEntry, IProgressMonitor monitor)
             throws CoreException, Exception {
         monitor.beginTask("", 1);
         monitor.subTask("Downloading coredump archive...");
@@ -42,7 +68,7 @@ public class CoredumpSelectionHandler {
             String coredumpPath = corefileEntry.getFullPath();
             String fileName = new Path(coredumpPath).lastSegment().replace(".tar.gz", "");
             String destFilePrefix = new Path(workingDir).append(fileName).toOSString();
-            return downloadCoreFile(corefileEntry, destFilePrefix);
+            return downloadArchiveFile(corefileEntry, destFilePrefix);
         } finally {
             monitor.done();
         }
@@ -71,8 +97,8 @@ public class CoredumpSelectionHandler {
 
             monitor.subTask("Copying coredump and cs file...");
             if ((corefilePath != null && corefileExt
-                    .equals(FilenameUtil.getExtension(corefilePath))) &&
-                    (csfilePath != null && "cs".equals(FilenameUtil.getExtension(csfilePath)))) {
+                    .equals(FilenameUtil.getExtension(corefilePath)))
+                    && (csfilePath != null && "cs".equals(FilenameUtil.getExtension(csfilePath)))) {
                 String corefileName = new Path(corefilePath).lastSegment();
                 String csfileName = new Path(csfilePath).lastSegment();
 
@@ -102,7 +128,38 @@ public class CoredumpSelectionHandler {
         return null;
     }
 
-    private String[] downloadCoreFile(FileEntry coreDir, String destFilePrefix)
+    private String downloadFile(FileEntry entry, String destFilePrefix, String ext)
+            throws CoreException, Exception {
+        List<String> downloadedFiles = new ArrayList<String>();
+        if (entry == null)
+            return null;
+
+        if (ext.equals(FilenameUtil.getExtension(entry.getName()))) {
+            String selectedFilePath = entry.getFullPath();
+            FileEntry file = target.getDevice().getFileEntry(selectedFilePath);
+            FileOutputStream fileOut = null;
+            try {
+                String outputPath = destFilePrefix;
+                fileOut = new FileOutputStream(outputPath);
+                SyncResult result = target.getDevice().getSyncService()
+                        .doPull(file, fileOut, null, -1);
+                if (result.isOk()) {
+                    downloadedFiles.add(outputPath);
+                } else {
+                    logger.error(String.format("Failed to pull file: %s", selectedFilePath));
+                }
+            } finally {
+                IOUtil.tryClose(fileOut);
+            }
+        }
+        if (downloadedFiles.isEmpty()) {
+            return null;
+        } else {
+            return downloadedFiles.get(0);
+        }
+    }
+
+    private String[] downloadArchiveFile(FileEntry coreDir, String destFilePrefix)
             throws CoreException, Exception {
         List<String> downloadedFiles = new ArrayList<String>();
         if (coreDir == null)
@@ -159,8 +216,8 @@ public class CoredumpSelectionHandler {
         cmdLauncher.run(cmd, null);
         String csfilePath = cmdLauncher.getEndLine();
 
-        if ((corefilePath != null && corefileExt.equals(FilenameUtil.getExtension(corefilePath))) &&
-                (csfilePath != null && "cs".equals(FilenameUtil.getExtension(csfilePath)))) {
+        if ((corefilePath != null && corefileExt.equals(FilenameUtil.getExtension(corefilePath)))
+                && (csfilePath != null && "cs".equals(FilenameUtil.getExtension(csfilePath)))) {
             String[] result = {
                     TizenPlatformConstants.DEBUG_COREFILE_EXTRACT_TEMP_PATH + "/" + corefilePath,
                     TizenPlatformConstants.DEBUG_COREFILE_EXTRACT_TEMP_PATH + "/" + csfilePath };
index 4f23779..79cec03 100644 (file)
@@ -7,22 +7,29 @@ public class CoredumpModel {
         REMOTE, LOCAL
     }
 
-    private String originPath;
+    private String originCorefilePath;
+    private String originCsfilePath;
     private String path;
     private LOCATION loc;
     private CSVO csvo;
     private boolean x86coredump = false;
     private boolean armcoredump = false;
 
-    public CoredumpModel(String originPath, String path, CSVO csvo, LOCATION loc) {
-        this.originPath = originPath;
+    public CoredumpModel(String originCorefilePath, String originCsfilePath, String path,
+            CSVO csvo, LOCATION loc) {
+        this.originCorefilePath = originCorefilePath;
+        this.originCsfilePath = originCsfilePath;
         this.path = path;
         this.csvo = csvo;
         this.loc = loc;
     }
 
-    public String getOriginPath() {
-        return originPath;
+    public String getOriginCorefilePath() {
+        return originCorefilePath;
+    }
+
+    public String getOriginCsfilePath() {
+        return originCsfilePath;
     }
 
     public String getPath() {
index 4fc081a..cb2f745 100644 (file)
@@ -5,16 +5,29 @@ import java.io.FilenameFilter;
 
 public class XmlFileFilter implements FilenameFilter {
 
+    private boolean includesXmlInFile;
+
     private static final String XML_EXT = ".xml";
+    private static final String XML_IN_EXT = ".xml.in";
+
+    public XmlFileFilter() {
+        this(false);
+    }
+
+    public XmlFileFilter(boolean includesXmlInFile) {
+        this.includesXmlInFile = includesXmlInFile;
+    }
 
     @Override
     public boolean accept(File dir, String name) {
         boolean isAccept = false;
 
-        if (name.toLowerCase().endsWith(XML_EXT)) {
-            isAccept = true;
+        if (includesXmlInFile) {
+            isAccept = (name.toLowerCase().endsWith(XML_EXT) || name.toLowerCase().endsWith(
+                    XML_IN_EXT));
+        } else {
+            isAccept = (name.toLowerCase().endsWith(XML_EXT));
         }
-
         return isAccept;
     }
 }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/CoredumpLaunchConfigurationProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/CoredumpLaunchConfigurationProcessor.java
new file mode 100644 (file)
index 0000000..1cb40ea
--- /dev/null
@@ -0,0 +1,351 @@
+package org.tizen.nativeplatform.launch;
+
+import java.io.File;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.coredump.CSFileReader;
+import org.tizen.nativeplatform.coredump.CoredumpSelectionHandler;
+import org.tizen.nativeplatform.coredump.model.CSVO;
+import org.tizen.nativeplatform.coredump.model.CoredumpModel;
+import org.tizen.nativeplatform.launch.wizards.PlatformCoredumpLaunchWizard;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.types.CmdTargetTypes;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.service.FileEntry;
+
+public class CoredumpLaunchConfigurationProcessor implements ILaunchConfigurationProcessor {
+    private ILaunchConfiguration launchConfig;
+    private IProject project;
+    private String mode;
+    private IProgressMonitor monitor;
+    private Shell shell;
+    private PkgCommandTarget target;
+    private PlatformRootstrap rootstrap;
+
+    public CoredumpLaunchConfigurationProcessor(Shell shell, ILaunchConfiguration launchConfig,
+            IProject project, String mode, PkgCommandTarget target, IProgressMonitor monitor) {
+        this.shell = shell;
+        this.launchConfig = launchConfig;
+        this.project = project;
+        this.mode = mode;
+        this.target = target;
+        this.monitor = monitor;
+    }
+
+    @Override
+    public boolean process() throws CoreException {
+        boolean needSetConfiguration = !isSetProgramPath(launchConfig);
+
+        if (needSetConfiguration) {
+            return internalProcess(monitor);
+        } else {
+            checkChangedConfiguration(monitor);
+            return true;
+        }
+    }
+
+    private boolean internalProcess(IProgressMonitor monitor) throws CoreException {
+        return setLaunchConfiguration(new SubProgressMonitor(monitor, 1));
+    }
+
+    private boolean setLaunchConfiguration(IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask("", 1);
+        final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
+        final IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
+        try {
+            SWTUtil.syncExec(new Runnable() {
+                @Override
+                public void run() {
+                    PlatformCoredumpLaunchWizard wizard = new PlatformCoredumpLaunchWizard(shell,
+                            project, config, target, mode);
+                    PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
+                    dlg.create();
+                    if (Window.OK == dlg.open()) {
+                        String programPath = dlg.getProgramPath();
+                        String coredumpPath = "";
+                        String originCoredumpfilePath = "";
+                        String originCsfilePath = "";
+                        String coredumpLocation = "";
+                        CoredumpModel cmodel = dlg.getCoredumpModel();
+                        if (cmodel != null) {
+                            coredumpPath = dlg.getCoredumpModel().getPath();
+                            originCoredumpfilePath = dlg.getCoredumpModel().getOriginCorefilePath();
+                            originCsfilePath = dlg.getCoredumpModel().getOriginCsfilePath();
+                            coredumpLocation = dlg.getCoredumpModel().getLocation().toString();
+                        }
+                        rootstrap = dlg.getSelectedRootstrap();
+                        target.setRootstrap(rootstrap);
+                        String rootstrapName = rootstrap.getName();
+                        setOptionAttributes(wc, programPath, coredumpPath, originCoredumpfilePath,
+                                originCsfilePath, coredumpLocation, rootstrapName);
+                    }
+                }
+            });
+        } finally {
+            monitor.done();
+        }
+        return isSetProgramPath(launchConfig);
+    }
+
+    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, String programPath,
+            String coredumpPath, String originCoredumpfilePath, String originCsfilePath,
+            String coredumpLocation, String rootstrapName) {
+        if (programPath != null) {
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+        }
+        if (coredumpPath != null) {
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, coredumpPath);
+        }
+        if (originCoredumpfilePath != null) {
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH,
+                    originCoredumpfilePath);
+        }
+        if (originCsfilePath != null) {
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ORIGIN_CSFILE_PATH,
+                    originCsfilePath);
+        }
+        if (coredumpLocation != null) {
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION,
+                    coredumpLocation);
+        }
+        if (rootstrapName != null) {
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_NAME, rootstrapName);
+        }
+
+        try {
+            wc.doSave();
+        } catch (CoreException e) {
+            CDebugUIPlugin.log(e);
+            e.printStackTrace();
+        }
+    }
+
+    protected void checkChangedConfiguration(IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask("", 1);
+        monitor.subTask("Setting coredump file...");
+        try {
+            String coredumpPath = launchConfig.getAttribute(
+                    ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH, "");
+            String originCsPath = launchConfig.getAttribute(
+                    ITizenLaunchConfigurationConstants.ATTR_ORIGIN_CSFILE_PATH, "");
+            String programPath = launchConfig.getAttribute(
+                    ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+            String rootstrapName = launchConfig.getAttribute(
+                    ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_NAME, "");
+            String coredumpLocation = launchConfig.getAttribute(
+                    ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION, "");
+            if (coredumpPath.isEmpty() || rootstrapName.isEmpty()) {
+                newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, null);
+            }
+            String rootstrapId = RootstrapManager.getRootstrapId(rootstrapName);
+            rootstrap = RootstrapManager.getRootstrap(rootstrapId);
+            if (rootstrap == null) {
+                newCoreException(
+                        String.format(PlatformLaunchMessages.CANNOT_FIND_ROOTSTRAP, rootstrapId),
+                        null);
+            }
+            target.setRootstrap(rootstrap);
+            changeBuildTarget();
+            if (originCsPath.isEmpty()) {
+                if (coredumpLocation.equals(CoredumpModel.LOCATION.REMOTE.toString())) {
+                    FileEntry coredumpEntry = target.getDevice().getFileEntry(coredumpPath);
+                    if (coredumpEntry.getDate() == null) {
+                        newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
+                    }
+                    processRemoteDumpfile(coredumpEntry, programPath, new SubProgressMonitor(
+                            monitor, 1));
+                } else {
+                    File file = new File(coredumpPath);
+                    if (!file.exists()) {
+                        newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
+                    }
+                    processLocalDumpfile(coredumpPath, programPath, new SubProgressMonitor(monitor,
+                            1));
+                }
+            } else {
+                if (coredumpLocation.equals(CoredumpModel.LOCATION.REMOTE.toString())) {
+                    FileEntry coreFileEntry = target.getDevice().getFileEntry(coredumpPath);
+                    if (coreFileEntry.getDate() == null) {
+                        newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
+                    }
+                    FileEntry csFileEntry = target.getDevice().getFileEntry(originCsPath);
+                    if (csFileEntry.getDate() == null) {
+                        newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
+                    }
+                    processRemoteCorefile(coreFileEntry, csFileEntry, programPath,
+                            new SubProgressMonitor(monitor, 1));
+                }
+            }
+        } finally {
+            monitor.done();
+        }
+    }
+
+    private void processRemoteCorefile(FileEntry corefileEntry, FileEntry csfileEntry,
+            String programPath, IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask("", 3);
+        monitor.subTask("Downloading core file...");
+        try {
+            CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
+            String coreFile;
+            String csFile;
+            coreFile = handler.processRemoteCorefile(corefileEntry, new SubProgressMonitor(monitor,
+                    1));
+            if (coreFile == null) {
+                newCoreException(PlatformLaunchMessages.FAILED_DOWNLOAD_COREDUMP, null);
+            }
+            checkCancelProcess(monitor);
+            monitor.worked(1);
+            monitor.subTask("Downloading cs file...");
+            csFile = handler.processRemoteCsfile(csfileEntry, new SubProgressMonitor(monitor, 1));
+            if (csFile == null) {
+                newCoreException(PlatformLaunchMessages.FAILED_DOWNLOAD_COREDUMP, null);
+            }
+            checkCancelProcess(monitor);
+            monitor.worked(1);
+            CSFileReader csReader = new CSFileReader(csFile);
+            CSVO csvo = csReader.parse();
+            monitor.subTask("Setting configuration...");
+
+            if (programPath.isEmpty()) {
+                programPath = PlatformLaunchUtil.LAUNCHPAD_PATH;
+            }
+            setOptionAttributes(launchConfig.getWorkingCopy(), programPath, coreFile, null, null,
+                    null, null);
+            monitor.worked(1);
+        } catch (Exception e) {
+            newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, e);
+        } finally {
+            monitor.done();
+        }
+    }
+
+    private void processLocalDumpfile(String coredumpFile, String programPath,
+            IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask("", 2);
+        monitor.subTask("Extracting coredump archive...");
+        try {
+            CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
+            String[] coreFiles = handler.processLocalCorefile(coredumpFile, new SubProgressMonitor(
+                    monitor, 1));
+            if (coreFiles == null) {
+                newCoreException(PlatformLaunchMessages.FAILED_EXTRACT_COREDUMP, null);
+            }
+            monitor.subTask("Parsing coredump archive...");
+            String coredumpPath = coreFiles[0];
+            String csFile = coreFiles[1];
+            CSFileReader csReader = new CSFileReader(csFile);
+            CSVO csvo = csReader.parse();
+            monitor.worked(1);
+            checkCancelProcess(monitor);
+            monitor.subTask("Setting configuration...");
+            if (programPath.isEmpty()) {
+                programPath = PlatformLaunchUtil.LAUNCHPAD_PATH;
+            }
+            setOptionAttributes(launchConfig.getWorkingCopy(), programPath, coredumpPath, null,
+                    null, null, null);
+            monitor.worked(1);
+        } catch (Exception e) {
+            newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, e);
+        } finally {
+            monitor.done();
+        }
+    }
+
+    private void processRemoteDumpfile(FileEntry coredumpEntry, String programPath,
+            IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask("", 3);
+        monitor.subTask("Downloading coredump archive...");
+        try {
+            CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
+            String[] coreFiles;
+            coreFiles = handler.processRemoteArchiveFile(coredumpEntry, new SubProgressMonitor(
+                    monitor, 1));
+            if (coreFiles == null) {
+                newCoreException(PlatformLaunchMessages.FAILED_DOWNLOAD_COREDUMP, null);
+            }
+            checkCancelProcess(monitor);
+            monitor.subTask("Parsing coredump archive...");
+            String coredumpPath = coreFiles[0];
+            String csFile = coreFiles[1];
+            CSFileReader csReader = new CSFileReader(csFile);
+            CSVO csvo = csReader.parse();
+            monitor.worked(1);
+            checkCancelProcess(monitor);
+            monitor.subTask("Setting configuration...");
+            /*
+             * programPath should be
+             * "/usr/bin/launchpad_preloading_preinitializing_daemon" because
+             * tizen application normally executes as launchpad. if tizen
+             * application which is executed directly, programPath should be
+             * corePage.getBinaryPath()
+             */
+            if (programPath.isEmpty()) {
+                programPath = PlatformLaunchUtil.LAUNCHPAD_PATH;
+            }
+            setOptionAttributes(launchConfig.getWorkingCopy(), programPath, coredumpPath, null,
+                    null, null, null);
+            monitor.worked(1);
+        } catch (Exception e) {
+            newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, e);
+        } finally {
+            monitor.done();
+        }
+    }
+
+    private void changeBuildTarget() {
+        IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
+        String oldTargetId = PlatformConfigurationManager.getBuildTargetName(config);
+        SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+        String toolchainId = sbi.getToolchainIDFromTargetID(oldTargetId);
+        String oldRootstrapId = sbi.getRootstrapIDFromTargetID(oldTargetId);
+        String rootstrapId = rootstrap.getId();
+        if (!rootstrapId.equals(oldRootstrapId)) {
+            String newTargetId = SmartBuildInterface.makeTargetID(rootstrapId, toolchainId);
+            PlatformConfigurationManager.setBuildTargetName(config, newTargetId);
+        }
+    }
+
+    protected boolean isSetProgramPath(ILaunchConfiguration wc) throws CoreException {
+        String path = wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+        return !path.isEmpty();
+    }
+
+    protected void killIfRunningApplication(String appId) throws CoreException {
+        IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
+        boolean isRunning = commander.isRunningApp(appId);
+        if (isRunning) {
+            commander.killApp(appId);
+        }
+    }
+
+    protected void newCoreException(String message, Throwable exception) throws CoreException {
+        Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
+        throw new CoreException(status);
+    }
+
+    protected void checkCancelProcess(IProgressMonitor monitor) throws CoreException {
+        if (monitor.isCanceled()) {
+            newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+        }
+    }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ILaunchConfigurationProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ILaunchConfigurationProcessor.java
new file mode 100644 (file)
index 0000000..f1d50a5
--- /dev/null
@@ -0,0 +1,7 @@
+package org.tizen.nativeplatform.launch;
+
+import org.eclipse.core.runtime.CoreException;
+
+public interface ILaunchConfigurationProcessor {
+    boolean process() throws CoreException;
+}
index a4b144e..9c9ee71 100644 (file)
@@ -33,15 +33,18 @@ public interface ITizenLaunchConfigurationConstants {
 
     public static final String PLATFORM_LAUNCH_ID = "org.tizen.platform.launch"; //$NON-NLS-1$
     public static final String ATTR_APP_PROJECT_NAME = PLATFORM_LAUNCH_ID + ".APP_PROJECT_ATTR"; //$NON-NLS-1$
-    public static final String ATTR_EXTRA_PACKAGE_LIST = PLATFORM_LAUNCH_ID
-            + ".EXTRA_PACKAGE_LIST_ATTR"; //$NON-NLS-1$
+    public static final String ATTR_APPLICATION_ID = PLATFORM_LAUNCH_ID + ".APP_ID_ATTR"; //$NON-NLS-1$
+    public static final String ATTR_DEVICE_PACKAGE_LIST = PLATFORM_LAUNCH_ID
+            + ".DEVICE_PACKAGE_LIST_ATTR"; //$NON-NLS-1$
+    public static final String ATTR_ROOTSTRAP_PACKAGE_LIST = PLATFORM_LAUNCH_ID
+            + ".ROOTSTRAP_PACKAGE_LIST_ATTR"; //$NON-NLS-1$
     public static final String ATTR_REINSTALL_OPTION = PLATFORM_LAUNCH_ID + ".REINSTALL_OP_ATTR"; //$NON-NLS-1$
-    public static final String ATTR_SELECTPKG_OPTION = PLATFORM_LAUNCH_ID + ".SELECTPKG_OP_ATTR"; //$NON-NLS-1$
     public static final String ATTR_FROM_SHORTCUT = PLATFORM_LAUNCH_ID + ".FROM_SHORTCUT_ATTR"; //$NON-NLS-1$
     public static final String ATTR_PROCESSNAME_OPTION = PLATFORM_LAUNCH_ID + ".PROCESS_NAME_ATTR"; //$NON-NLS-1$
     public static final String ATTR_PROCESSID_OPTION = PLATFORM_LAUNCH_ID + ".PROCESS_ID_ATTR"; //$NON-NLS-1$
     public static final String ATTR_ORIGIN_COREFILE_PATH = PLATFORM_LAUNCH_ID
             + ".ORIGIN_COREFILE_ATTR"; //$NON-NLS-1$
+    public static final String ATTR_ORIGIN_CSFILE_PATH = PLATFORM_LAUNCH_ID + ".ORIGIN_CSFILE_ATTR"; //$NON-NLS-1$
     public static final String ATTR_ROOTSTRAP_NAME = PLATFORM_LAUNCH_ID + ".ROOTSTRAP_ATTR"; //$NON-NLS-1$
     public static final String ATTR_COREFILE_LOCATION = PLATFORM_LAUNCH_ID + ".COREFILE_LOC_ATTR"; //$NON-NLS-1$
 }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchCommandCancelThread.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchCommandCancelThread.java
new file mode 100644 (file)
index 0000000..b1a7fd9
--- /dev/null
@@ -0,0 +1,35 @@
+package org.tizen.nativeplatform.launch;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+
+public class LaunchCommandCancelThread extends Thread {
+    private IPkgCommander commander;
+    private IProgressMonitor monitor;
+    private boolean running = true;
+    
+    public LaunchCommandCancelThread(IPkgCommander commander, IProgressMonitor monitor) {
+        this.commander = commander;
+        this.monitor = monitor;
+    }
+    
+    public void setTerminated() {
+        running = false;
+    }
+    
+    public void run() {
+        while(running) {
+            if (monitor.isCanceled()) {
+                commander.getOutputReceiver().processNewLine("Execution canceled");
+                commander.cancelExecution();
+                monitor.subTask("Execution cancelled");
+                running = false;
+            }
+            try {
+                sleep(1000);
+            } catch (InterruptedException e) {
+                running = false;
+            }
+        }
+    }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchConfigurationProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchConfigurationProcessor.java
new file mode 100644 (file)
index 0000000..8abee04
--- /dev/null
@@ -0,0 +1,260 @@
+package org.tizen.nativeplatform.launch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.IPkgFilter;
+import org.tizen.nativeplatform.pkg.commander.IPkgLauncher;
+import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgFilterFactory;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
+import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.types.CmdTargetTypes;
+import org.tizen.nativeplatform.types.LaunchTypes;
+import org.tizen.nativeplatform.util.PackageUtil;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
+
+public class LaunchConfigurationProcessor implements ILaunchConfigurationProcessor {
+    private ILaunchConfiguration launchConfig;
+    private IProject project;
+    private IConfiguration buildConfig;
+    private String mode;
+    private IProgressMonitor monitor;
+    private Shell shell;
+    private PkgCommandTarget target;
+    private String applicationId = "";
+    private PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
+    private IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil
+            .getPkgType());
+    private String rootstrapInstallLog = "";
+    private String deviceInstallLog = "";
+
+    public LaunchConfigurationProcessor(Shell shell, ILaunchConfiguration launchConfig,
+            IProject project, String mode, PkgCommandTarget target, IProgressMonitor monitor) {
+        this.shell = shell;
+        this.launchConfig = launchConfig;
+        this.project = project;
+        this.mode = mode;
+        this.target = target;
+        this.monitor = monitor;
+        this.buildConfig = getBuildConfiguration();
+    }
+    
+    @Override
+    public boolean process() throws CoreException {
+        boolean configurationIsSet = isSetProgramPath(launchConfig);
+        boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
+        
+        if (configurationIsSet) {
+            if (isEflApp) {
+                String appId = launchConfig.getAttribute(ITizenLaunchConfigurationConstants.ATTR_APPLICATION_ID, "");
+                killIfRunningApplication(appId);
+            }
+            return installPackages(configurationIsSet, monitor);                                           
+        } else {            
+            monitor.beginTask("", 2);
+            try {
+                String descMsg = "";
+                if (!installPackages(configurationIsSet, new SubProgressMonitor(monitor, 1))) {
+                    descMsg = "Installation seems to be failed. Check package installation log.";
+                }
+                if (!setLaunchConfigurationForEFL(new SubProgressMonitor(monitor, 1), descMsg, isEflApp)) {                
+                    return false;
+                }
+            } finally {
+                monitor.done();
+            }
+        }
+        return true;
+    }
+    
+    private boolean _installPackages(List<IPackage> devicePkgs, List<IPackage> rootstrapPkgs, 
+            boolean reinstallOp, IProgressMonitor monitor) throws CoreException {       
+        int totalWorks = 2;
+        monitor.beginTask("", totalWorks);
+        
+        IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target,
+                devicePkgs, rootstrapPkgs, reinstallOp);
+        try {
+            if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+                pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, new SubProgressMonitor(
+                        monitor, 1));
+            } else {
+                pkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
+            }
+        } catch (InterruptedException e) {
+            return false;
+        } finally {
+            monitor.done();
+            rootstrapInstallLog = pkgLauncher.getRootstrapLog();
+            deviceInstallLog = pkgLauncher.getDeviceLog();
+        }
+        
+        return true;
+        
+    }
+    
+    @SuppressWarnings("unchecked")
+    private boolean installPackages(boolean configurationIsSet, IProgressMonitor monitor) throws CoreException {        
+        ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
+        List<IPackage> devicePackages = new ArrayList<IPackage>();
+        List<IPackage> rootstrapPackages = new ArrayList<IPackage>();
+        boolean reinstallOp = true;
+        
+        if (configurationIsSet) {
+            IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType());
+            List<String> devicePkgStr = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_DEVICE_PACKAGE_LIST, new ArrayList<String>());
+            List<String> rootstrapPkgStr = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_PACKAGE_LIST, new ArrayList<String>());                    
+            devicePackages.addAll(maker.makeModels(devicePkgStr));
+            rootstrapPackages.addAll(maker.makeModels(rootstrapPkgStr));
+        } else {
+            List<IPackage> packages = pkgUtil.getPackages(project, buildConfig);           
+            if (!packages.isEmpty()) {
+                devicePackages.addAll(pkgFilter.filter(CmdTargetTypes.DEVICE, packages));
+                rootstrapPackages.addAll(pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, packages));
+            }
+            setOptionAttributes(wc, devicePackages, rootstrapPackages, reinstallOp);
+        }       
+        return _installPackages(devicePackages, rootstrapPackages, reinstallOp, monitor);        
+    }
+
+    private boolean setLaunchConfigurationForEFL(IProgressMonitor monitor, final String descMsg,
+            final boolean isEflApp) throws CoreException {
+        monitor.beginTask("", 1);
+        final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();        
+        try {
+            SWTUtil.syncExec(new Runnable() {
+                @Override
+                public void run() {
+                    PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, launchConfig, project, buildConfig, 
+                            target, mode, deviceInstallLog, rootstrapInstallLog, descMsg, isEflApp);
+                    PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
+                    dlg.create();
+                    if (Window.OK == dlg.open()) {
+                        String programPath = dlg.getProgramPath();
+                        String arguments = dlg.getArguments();
+                        applicationId = dlg.getSelectedApp();
+                        Map<String, String> environments = dlg.getEnvironments();
+                        setOptionAttributes(wc, programPath, arguments, applicationId, environments);
+                    }
+                }
+            });
+        } finally {
+            monitor.done();
+        }
+        
+        if (isSetProgramPath(launchConfig)) {
+            if (applicationId != null && !applicationId.isEmpty()) {
+                killIfRunningApplication(applicationId);
+            }            
+            return true;
+        } else {
+            return false;
+        }
+    }
+   
+    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, String programPath,
+            String arguments, String applicationId, List<IPackage> devicePackages, List<IPackage> rootstrapPackages, 
+            boolean reinstallOp, boolean selectPkgOp, Map<String, String> environments) {
+        setOptionAttributes(wc, programPath, arguments, applicationId, environments);
+        setOptionAttributes(wc, devicePackages, rootstrapPackages, reinstallOp);
+    }
+    
+    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, String programPath,
+            String arguments, String applicationId, Map<String, String> environments) {
+        if (programPath != null) {
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+        }
+        if (arguments != null) {
+            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, arguments);
+        }
+        if (applicationId != null) {
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APPLICATION_ID, applicationId);
+        }
+        if (environments != null && environments.size() == 0) {
+            wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>) null);
+        } else {
+            wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, environments);
+        }
+        wc.setAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
+        
+        try {
+            wc.doSave();
+        } catch (CoreException e) {
+            CDebugUIPlugin.log(e);
+            e.printStackTrace();
+        }
+    }
+    
+    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, List<IPackage> devicePackages, List<IPackage> rootstrapPackages, 
+            boolean reinstallOp) {        
+        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
+        if (devicePackages != null) {
+            List<String> strs = new ArrayList<String>();
+            for (IPackage p : devicePackages) {
+                strs.add(p.getPath());
+            }
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_DEVICE_PACKAGE_LIST, strs);
+        }
+        if (rootstrapPackages != null) {
+            List<String> strs = new ArrayList<String>();
+            for (IPackage p : rootstrapPackages) {
+                strs.add(p.getPath());
+            }
+            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_PACKAGE_LIST, strs);
+        }        
+        try {
+            wc.doSave();
+        } catch (CoreException e) {
+            CDebugUIPlugin.log(e);
+            e.printStackTrace();
+        }
+    }
+    
+    protected boolean isSetProgramPath(ILaunchConfiguration wc) throws CoreException {
+        String path = wc.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+        return !path.isEmpty();
+    }
+    
+    protected void killIfRunningApplication(String appId) throws CoreException {
+        if (appId == null || appId.isEmpty()) {
+            return;
+        }
+        IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
+        boolean isRunning = commander.isRunningApp(appId);
+        if (isRunning) {
+            commander.killApp(appId);
+        }
+    }
+    
+    protected void newCoreException(String message, Throwable exception) throws CoreException {    
+        Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
+        throw new CoreException(status);
+    }
+    
+    protected IConfiguration getBuildConfiguration() {
+        return PlatformConfigurationManager.getDefaultConfiguration(project);       
+    }
+}
index 0f3f11e..a463ecd 100644 (file)
@@ -45,7 +45,6 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.ICDISession;
 import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -90,7 +89,6 @@ import org.tizen.nativecommon.build.CommonBuildMessages;
 import org.tizen.nativecommon.build.CommonConfigurationManager;
 import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.launch.LaunchUtils;
-import org.tizen.nativecommon.launch.TizenDebugger;
 import org.tizen.nativecommon.launch.TizenLaunchCommand;
 import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
@@ -98,21 +96,16 @@ import org.tizen.nativecommon.launch.TizenUIThreadForConfirmMessage;
 import org.tizen.nativecommon.launch.ui.TizenLaunchDeviceSelectionDialog;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
-import org.tizen.nativeplatform.launch.wizards.SelectItemDialog;
 import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
 import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
-import org.tizen.nativeplatform.pkg.commander.IPkgLauncher;
-import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
+import org.tizen.nativeplatform.pkg.commander.IPkgFilter;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgFilterFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.pkg.model.PkgStatus;
 import org.tizen.nativeplatform.rootstrap.RootstrapManager;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
-import org.tizen.nativeplatform.types.LaunchTypes;
 import org.tizen.nativeplatform.util.PackageUtil;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
@@ -139,6 +132,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
     protected boolean isLaunchFailed = false;
     protected TizenLaunchCommand tizenCommand = null;
     protected PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
+    protected IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType());
     protected static final String PROCESS_GET_PROCESS_ID_COMMAND = TizenPlatformConstants.SDK_ROOT_COMMAND
             + " process | grep '%s' | grep -v grep | awk '{print $1}'";
     protected static final String CHECK_RUNNING_GDBSERVER = String.format(
@@ -168,7 +162,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
             project = getProject(config);
 
-            boolean needSetConfiguration = !isSetProgramPath(config);
             activateProgressView();
             verifyDeviceReachability(config, new SubProgressMonitor(monitor, 1));
             setRootstrap(config);
@@ -176,14 +169,10 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             setPkgCommandTarget();
             tizenCommand = new TizenLaunchCommand(currentDevice, null);
 
-            if (needSetConfiguration) {
-                if (!setConfigurationAndInstallPackages(config, project, mode,
-                        new SubProgressMonitor(monitor, 1))) {
-                    newCoreException(PlatformLaunchMessages.CANNOT_LAUNCH, null);
-                }
-            } else {
-                // process changed attributes
-                processChanges(config, mode, new SubProgressMonitor(monitor, 1));
+            ILaunchConfigurationProcessor processor = getConfigurationProcessor(shell, config,
+                    project, mode, target, new SubProgressMonitor(monitor, 1));
+            if (!processor.process()) {
+                newCoreException(PlatformLaunchMessages.CANNOT_LAUNCH, null);
             }
 
             if (mode.equals(ILaunchManager.DEBUG_MODE)) {
@@ -208,7 +197,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
                 ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
                 launchManager.removeLaunch(launch);
             }
-            // Do not save failed configuration. 
+            // Do not save failed configuration.
             if (isLaunchFailed) {
                 config.delete();
                 isLaunchFailed = false;
@@ -218,19 +207,14 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
     }
 
-    protected void setSourceContainer(ILaunchConfiguration configuration) {
-
+    protected ILaunchConfigurationProcessor getConfigurationProcessor(Shell shell,
+            ILaunchConfiguration launchConfig, IProject project, String mode,
+            PkgCommandTarget target, IProgressMonitor monitor) {
+        return new LaunchConfigurationProcessor(shell, launchConfig, project, mode, target, monitor);
     }
 
-    protected void processChanges(ILaunchConfiguration config, String mode, IProgressMonitor monitor)
-            throws CoreException {
-        monitor.beginTask("", 2);
-        try {
-            checkChangedConfiguration(config, new SubProgressMonitor(monitor, 1));
-            installPackages(config, mode, new SubProgressMonitor(monitor, 1));
-        } finally {
-            monitor.done();
-        }
+    protected void setSourceContainer(ILaunchConfiguration configuration) {
+
     }
 
     protected void checkChangedConfiguration(ILaunchConfiguration config, IProgressMonitor monitor)
@@ -240,7 +224,8 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         try {
             boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
             if (isEflApp) {
-                programPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+                programPath = config.getAttribute(
+                        ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
                 String appId = PlatformLaunchUtil.getAppId(project, programPath);
                 killIfRunningApplication(appId);
             }
@@ -249,47 +234,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
     }
 
-    private boolean setConfigAndInstallEflPackage(ILaunchConfiguration config, IProject project,
-            String mode, IProgressMonitor monitor) throws CoreException {
-        ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
-        boolean reinstallOp = true;
-        boolean selectPkgOp = false;
-        String appProjectName = null;
-        List<IPackage> packages = null;
-        final String[] files = PlatformLaunchUtil.getProgramPath(project);
-        if (files != null) {
-            if (files.length > 1) {
-                SWTUtil.syncExec(new Runnable() {
-                    public void run() { 
-                        SelectItemDialog dlg = new SelectItemDialog(shell, files);
-                        dlg.create();
-                        if (Window.OK == dlg.open()) {
-                            programPath = dlg.getSelectedItem();
-                        } else {
-                            programPath = null;
-                        }
-                    }
-                });
-            } else if (files.length == 1) {
-                programPath = files[0];
-            } else {
-                programPath = null;
-            }
-            if (programPath == null) {
-                return false;
-            }
-        }
-        setOptionAttributes(wc, programPath, appProjectName, packages, reinstallOp, selectPkgOp);
-        if (isSetProgramPath(config)) {
-            String appId = PlatformLaunchUtil.getAppId(project, programPath);
-            killIfRunningApplication(appId);
-            installPackages(config, mode, monitor);
-        } else {
-            return false;
-        }
-        return true;
-    }
-
     protected void killIfRunningApplication(String appId) throws CoreException {
         IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
         boolean isRunning = commander.isRunningApp(appId);
@@ -298,95 +242,17 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
     }
 
-    private boolean setConfigAndInstallPackages(ILaunchConfiguration launchConfig,
-            final IProject project, final String mode, IProgressMonitor monitor)
-            throws CoreException {
-        monitor.beginTask("", 1);
-        final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
-        final IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
-        final Shell shell = getAvaiableShell();
-        try {
-            SWTUtil.syncExec(new Runnable() {
-                @Override
-                public void run() {
-                    PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, config,
-                            target,
-                            mode);
-                    PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
-                    dlg.create();
-                    if (Window.OK == dlg.open()) {
-                        String appProjectName = dlg.getAppProjectName();
-                        programPath = dlg.getProgramPath();
-                        List<IPackage> packages = dlg.getExtraPackages();
-                        boolean reinstallOp = dlg.getReinstallOp();
-                        boolean selectPkgOp = dlg.getSelectPkgOp();
-                        setOptionAttributes(wc, programPath, appProjectName, packages, reinstallOp,
-                                selectPkgOp);
-                    }
-                }
-            });
-        } finally {
-            monitor.done();
-        }
-        return isSetProgramPath(launchConfig);
-    }
-
-    protected boolean setConfigurationAndInstallPackages(ILaunchConfiguration launchConfig,
-            final IProject project, final String mode, IProgressMonitor monitor)
-            throws CoreException {
-        boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
-        // If the project is EFL app, do not need to run launch wizard.
-        if (isEflApp) {
-            return setConfigAndInstallEflPackage(launchConfig, project, mode, monitor);
-        } else {
-            return setConfigAndInstallPackages(launchConfig, project, mode, monitor);
-        }
-    }
-
-    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, String programPath,
-            String appProjectName, List<IPackage> ExtraPackages, boolean reinstallOp,
-            boolean selectPkgOp) {
-        if (programPath != null) {
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
-        }
-        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
-        if (appProjectName != null &&
-                !PlatformLaunchUtil.APP_PROJ_DEFAULT_SELECTION.equals(appProjectName)) {
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME,
-                    appProjectName);
-        }
-        if (ExtraPackages != null) {
-            List<String> strs = new ArrayList<String>();
-            for (IPackage p : ExtraPackages) {
-                strs.add(p.getPath());
-            }
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, strs);
-        }
-        try {
-            wc.doSave();
-        } catch (CoreException e) {
-            CDebugUIPlugin.log(e);
-            e.printStackTrace();
-        }
-    }
-
     protected Shell getAvaiableShell() {
         Shell shell = PlatformLaunchUtil.getAvaiableShell();
         return shell;
     }
 
-    protected void setConfiguration(ILaunchConfiguration config, String mode,
-            IProgressMonitor monitor) throws CoreException {
-        installPackages(config, mode, monitor);
-    }
-
     @Override
     public boolean buildForLaunch(ILaunchConfiguration configuration, String mode,
             IProgressMonitor monitor) throws CoreException {
         /*
-         * if parent's buildForLaunch() return false, monitor is not done in parent's. override
-         * buildForLaunch to monitor be done.
+         * if parent's buildForLaunch() return false, monitor is not done in
+         * parent's. override buildForLaunch to monitor be done.
          */
         monitor.beginTask("", 2);
         boolean result = super.buildForLaunch(configuration, mode, new SubProgressMonitor(monitor,
@@ -453,78 +319,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         return packagingResult;
     }
 
-    protected void installPackages(ILaunchConfiguration config, String mode,
-            IProgressMonitor monitor) throws CoreException {
-        boolean reinstallOp = config.getAttribute(
-                ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
-        boolean selectPkgOp = config.getAttribute(
-                ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
-        String appProjectName = config.getAttribute(
-                ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, "");
-        @SuppressWarnings("unchecked")
-        List<String> extraPkgs = (ArrayList<String>) config
-                .getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST,
-                        new ArrayList<String>());
-        List<IPackage> appPackages = new ArrayList<IPackage>();
-        List<IPackage> packages = new ArrayList<IPackage>();
-        IProject appProject = null;
-        IPkgLauncher appPkgLauncher = null;
-
-        int totalWorks = 2;
-        if (!appProjectName.isEmpty()) {
-            totalWorks += 2;
-        }
-        monitor.beginTask("", totalWorks);
-        String buildConfigName = getBuildConfigName(config);
-        IConfiguration buildConfig = getBuildConfiguration(buildConfigName, project);
-
-        // get packages
-        if (!appProjectName.isEmpty()) {
-            appProject = PlatformProjectUtil.getProjectInstance(appProjectName);
-            appPackages = getPackages(appProject, buildConfig, new SubProgressMonitor(monitor, 1));
-        }
-        List<IPackage> platformPkgs = getPackages(project, buildConfig,
-                new SubProgressMonitor(monitor, 1));
-        packages.addAll(platformPkgs);
-        if (!extraPkgs.isEmpty()) {
-            IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(target.getPkgType());
-            List<IPackage> extra = modelMaker.makeModels(extraPkgs, false);
-            packages.addAll(extra);
-        }
-
-        // create app package launcher and increase work count if app packages are existed
-        if (appProject != null && !appPackages.isEmpty()) {
-            appPkgLauncher = PkgLauncherFactory.getLauncher(appProject, target, appPackages,
-                    reinstallOp, selectPkgOp);
-        }
-        // create package launcher for platform and extra packages
-        IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target,
-                packages, reinstallOp, selectPkgOp);
-        try {
-            if (mode.equals(ILaunchManager.DEBUG_MODE)) {
-                // 1. launch platform and extra packages
-                pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, new SubProgressMonitor(
-                        monitor, 1));
-                // 2. launch application packages
-                if (appPkgLauncher != null) {
-                    appPkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, new SubProgressMonitor(
-                            monitor, 1));
-                }
-            } else {
-                // 1. launch platform and extra packages
-                pkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
-                // 2. launch application packages
-                if (appPkgLauncher != null) {
-                    appPkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
-                }
-            }
-        } catch (InterruptedException e) {
-            newCoreException(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e);
-        } finally {
-            monitor.done();
-        }
-    }
-
     protected void verifyPlatformProjectSettings(ILaunchConfiguration config) throws CoreException {
         String appPath = config
                 .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
@@ -730,24 +524,26 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             final IDevice[] devices = getDeploayableDevices(config);
             IDevice configDevice = null;
 
-            //1. Get device from configuration
+            // 1. Get device from configuration
             configDevice = LaunchUtils.getDeviceFromLaunchConfiguration(config, devices);
 
-            //2-1. Set device for launch configuration if there is no device matched with configuration or device is off-lined
+            // 2-1. Set device for launch configuration if there is no device
+            // matched with configuration or device is off-lined
             if (configDevice == null) {
-                //4. Get list of deployable devices for configuration
+                // 4. Get list of deployable devices for configuration
                 int device_count = devices.length;
 
                 if (device_count == 0) {
-                    //TODO: notify no deployable devices, open emulator manager? 
+                    // TODO: notify no deployable devices, open emulator
+                    // manager?
                     currentDevice = null;
                 }
-                //Found device more than 0
+                // Found device more than 0
                 else {
                     if (device_count == 1) {
                         currentDevice = devices[0];
                     }
-                    //if devices.length > 1
+                    // if devices.length > 1
                     else {
                         SWTUtil.syncExec(new Runnable() {
                             @Override
@@ -769,7 +565,8 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
                     }
                 }
             }
-            //2-2. Launch with the device if there is device info in configuration
+            // 2-2. Launch with the device if there is device info in
+            // configuration
             else {
                 currentDevice = configDevice;
             }
@@ -786,19 +583,15 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected void launchApplicationForRun(ILaunchConfiguration config, ILaunch launch,
             IProgressMonitor monitor) throws CoreException {
+        IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
+        LaunchCommandCancelThread cancelThread = new LaunchCommandCancelThread(commander, monitor);
         try {
             monitor.beginTask("", 1);
             monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
-            String appId = PlatformLaunchUtil.getAppId(project, programPath);
-            if (appId == null) {
-                String envCmd = getEnvironments(config);
-                String execArg = getArguments(config);
-                IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
-                commander.executeBinary(envCmd + execArg);
-            } else {
-                IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
-                commander.launchApp(appId);
-            }
+            cancelThread.start();
+            String envCmd = getEnvironments(config);
+            String execArg = getArguments(config);
+            ICommandStatus status = commander.executeBinary(envCmd + execArg);
         } catch (IOException e) {
             newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
         } catch (Exception e) {
@@ -806,6 +599,10 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         } finally {
             monitor.worked(1);
             monitor.done();
+            cancelThread.setTerminated();
+            if (cancelThread.isAlive()) {
+                cancelThread.interrupt();
+            }
         }
     }
 
@@ -839,7 +636,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             String gdbserverRunCommand = getGdbserverRunCommand(config);
             String resultCommand = null;
 
-            // is gdbserver running now ? then            
+            // is gdbserver running now ? then
             resultCommand = String.format(PROCESS_GET_PROCESS_ID_COMMAND,
                     gdbserverRunCommand.trim());
             tizenCommand.run(resultCommand, null);
@@ -869,9 +666,9 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected ICDISession getDebugSession(ILaunch launch, ILaunchConfiguration config,
             IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
-        TizenDebugger debugger = new TizenDebugger();
-        return ((ICDIDebugger2) debugger).createSession(launch,
-                getGDBClientArgument(exeFile), new SubProgressMonitor(monitor, 1));
+        TizenPlatformDebugger debugger = new TizenPlatformDebugger();
+        return ((ICDIDebugger2) debugger).createSession(launch, getGDBClientArgument(exeFile),
+                new SubProgressMonitor(monitor, 1));
     }
 
     protected void launchApplicationWithGDBClient(ILaunch launch, ILaunchConfiguration config,
@@ -970,7 +767,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         String envs = "";
         String[] envArray = getEnvironment(config);
         for (String env : envArray) {
-            envs = TizenPlatformConstants.ENVIRONMENT_SETTING_CMD + env + " && ";
+            envs += TizenPlatformConstants.ENVIRONMENT_SETTING_CMD + env + " && ";
         }
         return envs;
     }
@@ -978,10 +775,9 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
     protected String getArguments(ILaunchConfiguration config) throws CoreException {
         String appPath = config
                 .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
-        String arguments = config.getAttribute(
-                ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
+        String arguments = org.eclipse.cdt.launch.LaunchUtils.getProgramArguments(config);
         String executableWithArguments = "";
-        if (!arguments.equals("")) {
+        if (arguments != null && !arguments.equals("")) {
             executableWithArguments = appPath + " " + arguments;
         } else {
             executableWithArguments = appPath;
@@ -1034,10 +830,10 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected IPath getHostPath(String exePath, ILaunchConfiguration config) throws CoreException {
         IPath path = target.getRootstrap().getPath();
-        String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
-                path.toOSString());
+        String canonicalPath = target.getRootstrapCommander().canonicalizePath(exePath);
+        String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
         if (!rootstrapPath.equals("")) {
-            rootstrapPath = rootstrapPath.concat(exePath);
+            rootstrapPath = rootstrapPath.concat(canonicalPath);
         }
         return new Path(rootstrapPath);
     }
index 4d65d21..526f950 100644 (file)
@@ -116,7 +116,8 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
                     if (Window.OK == dlg.open()) {
                         String programPath = dlg.getProgramPath();
                         boolean reinstallOp = dlg.getReinstallOp();
-                        boolean selectPkgOp = dlg.getSelectPkgOp();
+                        //boolean selectPkgOp = dlg.getSelectPkgOp();
+                        boolean selectPkgOp = false;
                         String procName = dlg.getProcName();
                         int pid = dlg.getProcId();
                         setOptionAttributes(wc, programPath, procName, pid, reinstallOp,
@@ -138,7 +139,6 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
         wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, procName);
         wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, pid);
         wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
         try {
             wc.doSave();
         } catch (CoreException e) {
@@ -299,8 +299,7 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
         IProject platformProject = getProject(config);
         boolean reinstallOp = config.getAttribute(
                 ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
-        boolean selectPkgOp = config.getAttribute(
-                ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
+        
         List<IPackage> packages = new ArrayList<IPackage>();
 
         monitor.beginTask("", 1);
@@ -309,6 +308,7 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
         IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
         List<IPackage> platformPkgs = getPackages(platformProject, buildConfig, monitor);
         packages.addAll(platformPkgs);
+        /*
         IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(platformProject, target,
                 packages, reinstallOp, selectPkgOp);
         if (pkgLauncher == null) {
@@ -324,6 +324,7 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
         } finally {
             monitor.done();
         }
+        */
     }
 
     @Override
index b2fbc8d..baab91f 100644 (file)
@@ -37,8 +37,6 @@ import org.eclipse.cdt.debug.core.cdi.ICDISession;
 import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
 import org.eclipse.cdt.debug.mi.core.GDBCDIDebugger2;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -54,28 +52,17 @@ import org.eclipse.debug.core.model.ISourceLocator;
 import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
-import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.util.FileUtil;
-import org.tizen.common.util.SWTUtil;
 import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
-import org.tizen.nativeplatform.coredump.CSFileReader;
-import org.tizen.nativeplatform.coredump.model.CSVO;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.coredump.CoredumpSelectionHandler;
-import org.tizen.nativeplatform.coredump.model.CoredumpModel;
-import org.tizen.nativeplatform.launch.wizards.PlatformCoredumpLaunchWizard;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
 import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
 import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
-import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-import org.tizen.sdblib.service.FileEntry;
 
 @SuppressWarnings("restriction")
 public class PlatformLaunchDelegateForCoredump extends PlatformLaunchDelegate {
@@ -132,206 +119,10 @@ public class PlatformLaunchDelegateForCoredump extends PlatformLaunchDelegate {
         wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, targetPath);
         wc.doSave();
     }
-
-    protected boolean setConfigurationAndInstallPackages(ILaunchConfiguration launchConfig,
-            final IProject project, final String mode, IProgressMonitor monitor)
-            throws CoreException {
-        monitor.beginTask("", 1);
-        final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
-        final IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
-        final Shell shell = getAvaiableShell();
-        try {
-            SWTUtil.syncExec(new Runnable() {
-                @Override
-                public void run() {
-                    PlatformCoredumpLaunchWizard wizard =
-                            new PlatformCoredumpLaunchWizard(shell, project, config, target, mode);
-                    PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
-                    dlg.create();
-                    if (Window.OK == dlg.open()) {
-                        String programPath = dlg.getProgramPath();
-                        String coredumpPath = "";
-                        String originCoredumpPath = "";
-                        String coredumpLocation = "";
-                        CoredumpModel cmodel = dlg.getCoredumpModel();
-                        if (cmodel != null) {
-                            coredumpPath = dlg.getCoredumpModel().getPath();
-                            originCoredumpPath = dlg.getCoredumpModel().getOriginPath();
-                            coredumpLocation = dlg.getCoredumpModel().getLocation().toString();
-                        }
-                        rootstrap = dlg.getSelectedRootstrap();
-                        target.setRootstrap(rootstrap);
-                        String rootstrapName = rootstrap.getName();
-                        setOptionAttributes(wc, programPath, coredumpPath,
-                                originCoredumpPath, coredumpLocation, rootstrapName);
-                    }
-                }
-            });
-        } finally {
-            monitor.done();
-        }
-        return isSetProgramPath(launchConfig);
-    }
-
-    protected void setOptionAttributes(ILaunchConfigurationWorkingCopy wc, String programPath,
-            String coredumpPath, String originCoredumpPath,
-            String coredumpLocation, String rootstrapName) {
-        if (programPath != null) {
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
-        }
-        if (coredumpPath != null) {
-            wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, coredumpPath);
-        }
-        if (originCoredumpPath != null) {
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH,
-                    originCoredumpPath);
-        }
-        if (coredumpLocation != null) {
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION,
-                    coredumpLocation);
-        }
-        if (rootstrapName != null) {
-            wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_NAME, rootstrapName);
-        }
-
-        try {
-            wc.doSave();
-        } catch (CoreException e) {
-            CDebugUIPlugin.log(e);
-            e.printStackTrace();
-        }
-    }
-
-    protected void processChanges(ILaunchConfiguration config, String mode, IProgressMonitor monitor)
-            throws CoreException {
-        monitor.beginTask("", 2);
-        try {
-            checkChangedConfiguration(config, new SubProgressMonitor(monitor, 1));
-        } finally {
-            monitor.done();
-        }
-    }
-
-    protected void checkChangedConfiguration(ILaunchConfiguration config, IProgressMonitor monitor)
-            throws CoreException {
-        monitor.beginTask("", 1);
-        monitor.subTask("Setting coredump file...");
-        try {
-            String coredumpPath = config.getAttribute(
-                    ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH, "");
-            String rootstrapName = config.getAttribute(
-                    ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_NAME, "");
-            String coredumpLocation = config.getAttribute(
-                    ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION, "");
-            if (coredumpPath.isEmpty() || rootstrapName.isEmpty()) {
-                newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, null);
-            }
-            String rootstrapId = RootstrapManager.getRootstrapId(rootstrapName);
-            rootstrap = RootstrapManager.getRootstrap(rootstrapId);
-            if (rootstrap == null) {
-                newCoreException(
-                        String.format(PlatformLaunchMessages.CANNOT_FIND_ROOTSTRAP, rootstrapId),
-                        null);
-            }
-            target.setRootstrap(rootstrap);
-            changeBuildTarget();
-            if (coredumpLocation.equals(CoredumpModel.LOCATION.REMOTE.toString())) {
-                FileEntry coredumpEntry = currentDevice.getFileEntry(coredumpPath);
-                if (coredumpEntry.getDate() == null) {
-                    newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
-                }
-                processRemoteDumpfile(config, coredumpEntry, new SubProgressMonitor(monitor, 1));
-            } else {
-                File file = new File(coredumpPath);
-                if (!file.exists()) {
-                    newCoreException(PlatformLaunchMessages.CANNOT_FIND_COREDUMP, null);
-                }
-                processLocalDumpfile(config, coredumpPath, new SubProgressMonitor(monitor, 1));
-            }
-        } finally {
-            monitor.done();
-        }
-    }
-
-    private void processLocalDumpfile(ILaunchConfiguration config,
-            String coredumpFile, IProgressMonitor monitor) throws CoreException {
-        monitor.beginTask("", 2);
-        monitor.subTask("Extracting coredump archive...");
-        try {
-            CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
-            String[] coreFiles = handler.processLocalCorefile(coredumpFile,
-                    new SubProgressMonitor(monitor, 1));
-            if (coreFiles == null) {
-                newCoreException(PlatformLaunchMessages.FAILED_EXTRACT_COREDUMP, null);
-            }
-            monitor.subTask("Parsing coredump archive...");
-            String coredumpPath = coreFiles[0];
-            String csFile = coreFiles[1];
-            CSFileReader csReader = new CSFileReader(csFile);
-            CSVO csvo = csReader.parse();
-            monitor.worked(1);
-            checkCancelProcess(monitor);
-            monitor.subTask("Setting configuration...");
-            String programPath = csvo.getHeader().getCrashExePath();
-            setOptionAttributes(config.getWorkingCopy(), programPath, coredumpPath,
-                    null, null, null);
-            monitor.worked(1);
-        } catch (Exception e) {
-            newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, e);
-        } finally {
-            monitor.done();
-        }
-    }
-
-    private void processRemoteDumpfile(ILaunchConfiguration config,
-            FileEntry coredumpEntry, IProgressMonitor monitor) throws CoreException {
-        monitor.beginTask("", 3);
-        monitor.subTask("Downloading coredump archive...");
-        try {
-            CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
-            String[] coreFiles;
-            coreFiles = handler.processRemoteCorefile(coredumpEntry,
-                    new SubProgressMonitor(monitor, 1));
-            if (coreFiles == null) {
-                newCoreException(PlatformLaunchMessages.FAILED_DOWNLOAD_COREDUMP, null);
-            }
-            checkCancelProcess(monitor);
-            monitor.subTask("Parsing coredump archive...");
-            String coredumpPath = coreFiles[0];
-            String csFile = coreFiles[1];
-            CSFileReader csReader = new CSFileReader(csFile);
-            CSVO csvo = csReader.parse();
-            monitor.worked(1);
-            checkCancelProcess(monitor);
-            monitor.subTask("Setting configuration...");
-            /*
-             *  programPath should be "/usr/bin/launchpad_preloading_preinitializing_daemon" 
-             * because tizen application normally executes as launchpad.
-             *  if tizen application which is executed directly, programPath should be corePage.getBinaryPath()
-             */
-            //String programPath = csvo.getHeader().getCrashExePath();
-            String programPath = PlatformLaunchUtil.LAUNCHPAD_PATH;
-            setOptionAttributes(config.getWorkingCopy(), programPath, coredumpPath,
-                    null, null, null);
-            monitor.worked(1);
-        } catch (Exception e) {
-            newCoreException(PlatformLaunchMessages.FAILED_SET_COREDUMP, e);
-        } finally {
-            monitor.done();
-        }
-    }
-
-    private void changeBuildTarget() {
-        IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project);
-        String oldTargetId = PlatformConfigurationManager.getBuildTargetName(config);
-        SmartBuildInterface sbi = SmartBuildInterface.getInstance();
-        String toolchainId = sbi.getToolchainIDFromTargetID(oldTargetId);
-        String oldRootstrapId = sbi.getRootstrapIDFromTargetID(oldTargetId);
-        String rootstrapId = rootstrap.getId();
-        if (!rootstrapId.equals(oldRootstrapId)) {
-            String newTargetId = SmartBuildInterface.makeTargetID(rootstrapId, toolchainId);
-            PlatformConfigurationManager.setBuildTargetName(config, newTargetId);
-        }
+    
+    protected ILaunchConfigurationProcessor getConfigurationProcessor(Shell shell, ILaunchConfiguration launchConfig,
+            IProject project, String mode, PkgCommandTarget target, IProgressMonitor monitor) {
+        return new CoredumpLaunchConfigurationProcessor(shell, launchConfig, project, mode, target, monitor); 
     }
 
     private String moveCoredumpFileToTmp(String path) {
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenPlatformDebugger.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenPlatformDebugger.java
new file mode 100644 (file)
index 0000000..41227a1
--- /dev/null
@@ -0,0 +1,123 @@
+package org.tizen.nativeplatform.launch;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.mi.core.GDBServerCDIDebugger2;
+import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.MIPlugin;
+import org.eclipse.cdt.debug.mi.core.MISession;
+import org.eclipse.cdt.debug.mi.core.cdi.Session;
+import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
+import org.eclipse.cdt.debug.mi.core.command.Command;
+import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+public class TizenPlatformDebugger extends GDBServerCDIDebugger2 {
+    @Override
+    protected void doStartSession(ILaunch launch, Session session, IProgressMonitor monitor)
+            throws CoreException {
+        ILaunchConfiguration config = launch.getLaunchConfiguration();
+        if (monitor.isCanceled()) {
+            throw new OperationCanceledException();
+        }
+
+        setProgramEnvironments(config, session, monitor);
+        setProgramArguments(config, session, monitor);
+        startGDBServerSession(config, session, monitor);
+        // 'set solib-search-path' shoule be called after 'target remote'.
+        // Otherwise, breakpoint address is corrupted.
+        // 1) gdb
+        // 2) target remote :<port>
+        // 3) set solib-search-path <binary_path>
+        initializeLibraries(config, session);
+    }
+
+    protected void setProgramArguments(ILaunchConfiguration config, Session session,
+            IProgressMonitor monitor) throws CoreException {
+        ICDITarget[] targets = session.getTargets();
+        for (int i = 0; i < targets.length; ++i) {
+            if (monitor.isCanceled()) {
+                throw new OperationCanceledException();
+            }
+            Target target = (Target) targets[i];
+            MISession miSession = target.getMISession();
+            CommandFactory factory = miSession.getCommandFactory();
+            String[] args = getProgramArguments(config);
+            MIInfo info = null;
+            MIException ex = null;
+            if (args != null && args.length > 0) {
+                try {
+                    Command cmd = factory.createMIExecArguments(args);
+                    miSession.postCommand(cmd);
+                    info = cmd.getMIInfo();
+                } catch (MIException e) {
+                    ex = e;
+                }
+                if (info == null) {
+                    throw newCoreException(
+                            MIPlugin.getResourceString("src.GDBServerCDIDebugger.target_selection_failed"), ex); //$NON-NLS-1$
+                }
+            }
+        }
+    }
+
+    protected void setProgramEnvironments(ILaunchConfiguration config, Session session,
+            IProgressMonitor monitor) throws CoreException {
+        ICDITarget[] targets = session.getTargets();
+        for (int i = 0; i < targets.length; ++i) {
+            if (monitor.isCanceled()) {
+                throw new OperationCanceledException();
+            }
+            Target target = (Target) targets[i];
+            MISession miSession = target.getMISession();
+            CommandFactory factory = miSession.getCommandFactory();
+            String[] envs = getProgramEnvironments(config);
+            MIInfo info = null;
+            MIException ex = null;
+            if (envs != null && envs.length > 0) {
+                try {
+                    Command cmd = factory.createMIGDBSetEnvironment(envs);
+                    miSession.postCommand(cmd);
+                    info = cmd.getMIInfo();
+                } catch (MIException e) {
+                    ex = e;
+                }
+                if (info == null) {
+                    throw newCoreException(
+                            MIPlugin.getResourceString("src.GDBServerCDIDebugger.target_selection_failed"), ex); //$NON-NLS-1$
+                }
+            }
+        }
+    }
+
+    @Override
+    protected String[] getRunArguments(ILaunchConfiguration config) throws CoreException {
+        return new String[] { getWorkingDirectory(config), getCommandFile(config) };
+    }
+
+    private String[] getProgramArguments(ILaunchConfiguration config) throws CoreException {
+        String arguments = config.getAttribute(
+                ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
+        String[] args = arguments.replaceAll("\n", " ").split(" ");
+        return args;
+    }
+
+    private String[] getProgramEnvironments(ILaunchConfiguration config) throws CoreException {
+        String[] envs = DebugPlugin.getDefault().getLaunchManager().getEnvironment(config);
+        return envs;
+    }
+
+    @Override
+    protected String getCommandFile(ILaunchConfiguration config) throws CoreException {
+        String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT,
+                IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
+        return (gdbinit != null && gdbinit.length() > 0) ? "--command=" + gdbinit : "--nx"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/IAppIdChangeListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/IAppIdChangeListener.java
new file mode 100644 (file)
index 0000000..cce16a8
--- /dev/null
@@ -0,0 +1,5 @@
+package org.tizen.nativeplatform.launch.ui;
+
+public interface IAppIdChangeListener {
+    void appIdchanged(String prevId, String prevExec, String newId, String newExec);
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformArgumentsTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformArgumentsTab.java
new file mode 100644 (file)
index 0000000..4e072c9
--- /dev/null
@@ -0,0 +1,57 @@
+package org.tizen.nativeplatform.launch.ui;
+
+import org.eclipse.cdt.launch.ui.CArgumentsTab;
+import org.eclipse.swt.SWT;
+import org.tizen.common.util.DialogUtil;
+
+public class PlatformArgumentsTab extends CArgumentsTab implements IAppIdChangeListener {
+
+    private final String QUESTION_STRING = "Do you want to change following arguments?";
+    private final String TEMP_STRING_EXEC = "##changableexec##";
+    private final String TEMP_STRING_ID = "##changableid##";
+
+    public PlatformArgumentsTab() {
+        super();
+    }
+
+    @Override
+    public void appIdchanged(String prevId, String prevExec, String newId, String newExec) {
+        System.out.println(prevId + " : " + newId);
+        System.out.println(prevExec + " : " + newExec);
+        String arguments = fPrgmArgumentsText.getText();
+        boolean changedExec = false;
+        boolean changedId = false;
+        if (!prevExec.equals(newExec)) {
+            if (arguments.contains(prevExec)) {
+                arguments = arguments.replaceAll(prevExec, TEMP_STRING_EXEC);
+                changedExec = true;
+            }
+        }
+        if (!prevId.equals(newId)) {
+            if (arguments.contains(prevId)) {
+                arguments = arguments.replaceAll(prevId, TEMP_STRING_ID);
+                changedId = true;
+            }
+        }
+
+        String message = QUESTION_STRING;
+        if (changedExec) {
+            arguments = arguments.replaceAll(TEMP_STRING_EXEC, newExec);
+            message = String.format("%s\n[%s -> %s]", message, prevExec, newExec);
+        }
+        if (changedId) {
+            arguments = arguments.replaceAll(TEMP_STRING_ID, newId);
+            message = String.format("%s\n[%s -> %s]", message, prevId, newId);
+        }
+        if (changedExec || changedId) {
+            if (DialogUtil.openQuestionDialog(message) == SWT.YES) {
+                if (getLaunchConfigurationDialog() != null) {
+                    getLaunchConfigurationDialog().setActiveTab(this);
+                }
+                fPrgmArgumentsText.setText(arguments);
+                updateLaunchConfigurationDialog();
+            }
+        }
+    }
+
+}
\ No newline at end of file
index 4e05346..41f1d50 100644 (file)
@@ -33,7 +33,6 @@ public class PlatformCommonTab extends CMainTab {
 
     protected Text fBinPathText;
     protected Button fReinstallOp;
-    protected Button fSelectPkgOp;
 
     @Override
     protected String handleBrowseButtonSelected() {
@@ -57,8 +56,6 @@ public class PlatformCommonTab extends CMainTab {
 
         fReinstallOp = new Button(composite, SWT.CHECK);
         fReinstallOp.setText(resources.getString("Button.Reinstall.Op"));
-        fSelectPkgOp = new Button(composite, SWT.CHECK);
-        fSelectPkgOp.setText(resources.getString("Button.SelectPkg.Op"));
 
         fReinstallOp.addSelectionListener(new SelectionAdapter() {
             @Override
@@ -67,12 +64,6 @@ public class PlatformCommonTab extends CMainTab {
             }
         });
 
-        fSelectPkgOp.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent evt) {
-                updateLaunchConfigurationDialog();
-            }
-        });
     }
 
     protected FileEntry handleRemoteBrowseButtonSelected() {
@@ -98,7 +89,6 @@ public class PlatformCommonTab extends CMainTab {
         configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
                 ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
         configuration.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
-        configuration.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
         ICElement cElement = null;
         cElement = getContext(configuration, getPlatform(configuration));
         if (cElement != null) {
@@ -117,17 +107,6 @@ public class PlatformCommonTab extends CMainTab {
         fReinstallOp.setSelection(option);
     }
 
-    protected void updateSelectPkgOpFromConfig(ILaunchConfiguration config) {
-        boolean option = true;
-        try {
-            option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION,
-                    true);
-        } catch (CoreException ce) {
-            LaunchUIPlugin.log(ce);
-        }
-        fSelectPkgOp.setSelection(option);
-    }
-
     @Override
     protected void updateProjectFromConfig(ILaunchConfiguration config) {
         String projectName = EMPTY_STRING;
index f1d11ef..e863433 100644 (file)
@@ -27,7 +27,9 @@
 
 package org.tizen.nativeplatform.launch.ui;
 
+import org.eclipse.cdt.launch.ui.CArgumentsTab;
 import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.EnvironmentTab;
 import org.eclipse.debug.ui.ILaunchConfigurationDialog;
 import org.eclipse.debug.ui.ILaunchConfigurationTab;
 import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
@@ -37,12 +39,19 @@ public class PlatformLaunchConfigurationTabGroup extends AbstractLaunchConfigura
     @Override
     public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
         ILaunchConfigurationTab[] tabs = null;
+        
+        boolean isDebug = mode.equals("debug");
 
-        if (mode.equals("debug")) {
-            tabs = new ILaunchConfigurationTab[] { new TizenDebuggerTab(false),
+        if (isDebug) {
+            tabs = new ILaunchConfigurationTab[] { new PlatformMainTab(isDebug), new CArgumentsTab(), new EnvironmentTab(),
+                    new PlatformPackagesTab(isDebug), new TizenDebuggerTab(false),
                     new SourceLookupTab() };
         } else {
-            tabs = new ILaunchConfigurationTab[] {};
+            PlatformArgumentsTab argumentsTab = new PlatformArgumentsTab();
+            PlatformMainTab mainTab = new PlatformMainTab(isDebug);
+            mainTab.registerAppIdChangeListener(argumentsTab);
+            tabs = new ILaunchConfigurationTab[] { mainTab, argumentsTab, new EnvironmentTab(),
+                    new PlatformPackagesTab(isDebug) };
         }
 
         setTabs(tabs);
index 3080410..8d589e1 100644 (file)
@@ -133,7 +133,6 @@ public class PlatformMainAttachTab extends PlatformCommonTab {
         updateProjectFromConfig(configuration);
         updateProcessFromConfig(configuration);
         updateReinstallOpFromConfig(configuration);
-        updateSelectPkgOpFromConfig(configuration);
     }
 
     @Override
@@ -146,12 +145,10 @@ public class PlatformMainAttachTab extends PlatformCommonTab {
         String name = fProjText.getText().trim();
         String procName = fProcText.getText().trim();
         boolean reinstallOp = fReinstallOp.getSelection();
-        boolean selectPkgOp = fSelectPkgOp.getSelection();
 
         config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
         config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, procName);
         config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
     }
 
     protected void updateProcessFromConfig(ILaunchConfiguration config) {
index bf257cc..e006796 100644 (file)
@@ -32,6 +32,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.ResourceBundle;
 
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -71,14 +72,23 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
     private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
 
     private Text coredumpText;
+    private Text corefileText;
+    private Text csfileText;
+    private Text execText;
     private Combo rootstrapCombo;
+    private Button csRemoteBrowseButton;
+    private Button coreRemoteBrowseButton;
+    private Button archiveRemoteBrowseButton;
+    private Button archiveLocalBrowseButton;
     private IDevice device;
 
     private FileEntry originCoredumpFileEntry;
+    private FileEntry originCsFileEntry;
     private String originCoredumpPath = "";
+    private String originCsPath = "";
+    private String programPath = "";
     private List<PlatformRootstrap> rootstraps = new ArrayList<PlatformRootstrap>();
     private String coredumpLocation;
-
     protected final Logger logger = LoggerFactory.getLogger(PlatformMainCoreTab.class);
 
     public PlatformMainCoreTab() {
@@ -92,11 +102,13 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
         GridLayout topLayout = new GridLayout();
         comp.setLayout(topLayout);
         createVerticalSpacer(comp, 1);
-        createCoredumpGroup(comp, 1);
+        createCoredumpArchiveGroup(comp, 1);
+        createCorefileGroup(comp, 1);
+        createExecGroup(comp, 1);
         createRootstrapGroup(comp, 1);
     }
 
-    private void createCoredumpGroup(Composite parent, int colSpan) {
+    private void createCoredumpArchiveGroup(Composite parent, int colSpan) {
         Composite coredumpComp = new Composite(parent, SWT.NONE);
         GridLayout layout = new GridLayout();
         layout.numColumns = 3;
@@ -119,9 +131,9 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
         gd.horizontalSpan = 2;
         buttonComp.setLayoutData(gd);
 
-        Button remoteBrowseButton = createPushButton(buttonComp,
+        archiveRemoteBrowseButton = createPushButton(buttonComp,
                 resources.getString("Button.Browse"), null);
-        remoteBrowseButton.addSelectionListener(new SelectionAdapter() {
+        archiveRemoteBrowseButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
                 originCoredumpFileEntry = handleRemoteBrowseButtonSelected();
@@ -134,9 +146,9 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
             }
         });
 
-        Button localBrowseButton = createPushButton(buttonComp,
+        archiveLocalBrowseButton = createPushButton(buttonComp,
                 resources.getString("Button.Local.Browse"), null);
-        localBrowseButton.addSelectionListener(new SelectionAdapter() {
+        archiveLocalBrowseButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
                 FileDialog fd = new FileDialog(getAvailableShell(), SWT.OPEN | SWT.SINGLE);
@@ -165,7 +177,95 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
                 updateLaunchConfigurationDialog();
             }
         });
+    }
+
+    private void createCorefileGroup(Composite parent, int colSpan) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 3;
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        composite.setLayout(layout);
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        composite.setLayoutData(gd);
+
+        Label corefileLabel = new Label(composite, SWT.NONE);
+        corefileLabel.setText("File(.core):");
+
+        corefileText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+        corefileText.setLayoutData(gd);
+        coreRemoteBrowseButton = createPushButton(composite, resources.getString("Button.Browse"),
+                null);
+        coreRemoteBrowseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                originCoredumpFileEntry = handleRemoteBrowseButtonSelected();
+                if (originCoredumpFileEntry != null && originCoredumpFileEntry.getDate() != null) {
+                    originCoredumpPath = originCoredumpFileEntry.getFullPath();
+                    corefileText.setText(originCoredumpPath);
+                    coredumpLocation = CoredumpModel.LOCATION.REMOTE.toString();
+                    updateLaunchConfigurationDialog();
+                }
+            }
+        });
+
+        Label csfileLabel = new Label(composite, SWT.NONE);
+        csfileLabel.setText("File(.cs):");
 
+        csfileText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+        csfileText.setLayoutData(gd);
+        csRemoteBrowseButton = createPushButton(composite, resources.getString("Button.Browse"),
+                null);
+        csRemoteBrowseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                originCsFileEntry = handleRemoteBrowseButtonSelected();
+                if (originCsFileEntry != null && originCsFileEntry.getDate() != null) {
+                    originCsPath = originCsFileEntry.getFullPath();
+                    csfileText.setText(originCsPath);
+                    coredumpLocation = CoredumpModel.LOCATION.REMOTE.toString();
+                    updateLaunchConfigurationDialog();
+                }
+            }
+        });
+    }
+
+    private void createExecGroup(Composite parent, int colSpan) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        composite.setLayout(layout);
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        composite.setLayoutData(gd);
+
+        Label execLabel = new Label(composite, SWT.NONE);
+        execLabel.setText("Program path:");
+
+        execText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+        execText.setLayoutData(gd);
+        execText.setLayoutData(gd);
+    }
+
+    private void enableArchiveGroup(boolean enable) {
+        if (!enable) {
+            coredumpText.setText("");
+        }
+        coredumpText.setEnabled(enable);
+        archiveRemoteBrowseButton.setEnabled(enable);
+        archiveLocalBrowseButton.setEnabled(enable);
+    }
+
+    private void enableCorefileGroup(boolean enable) {
+        if (!enable) {
+            csfileText.setText("");
+            corefileText.setText("");
+        }
+        csfileText.setEnabled(enable);
+        corefileText.setEnabled(enable);
+        csRemoteBrowseButton.setEnabled(enable);
+        coreRemoteBrowseButton.setEnabled(enable);
     }
 
     private void createRootstrapGroup(Composite parent, int colSpan) {
@@ -190,7 +290,6 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
             @Override
             public void widgetSelected(SelectionEvent e) {
                 fPreviouslyCheckedProgram = null;
-
                 updateBuildConfigCombo(""); //$NON-NLS-1$
                 updateLaunchConfigurationDialog();
             }
@@ -205,6 +304,7 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
     public void initializeFrom(ILaunchConfiguration configuration) {
         setErrorMessage(null);
         updateCoredumpFromConfig(configuration);
+        updateProgramPathFromConfig(configuration);
         updateRootstrapFromConfig(configuration);
     }
 
@@ -217,9 +317,13 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
     public void performApply(ILaunchConfigurationWorkingCopy config) {
         String coreLocation = coredumpLocation.toString();
         String rootstrapName = rootstrapCombo.getText();
+        String exec = execText.getText();
 
+        config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, exec);
         config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH,
                 originCoredumpPath);
+        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ORIGIN_CSFILE_PATH,
+                originCsPath);
         config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION, coreLocation);
         config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_NAME, rootstrapName);
     }
@@ -255,37 +359,87 @@ public class PlatformMainCoreTab extends PlatformCommonTab {
     @SuppressWarnings("restriction")
     protected void updateCoredumpFromConfig(ILaunchConfiguration config) {
         originCoredumpPath = EMPTY_STRING;
+        originCsPath = EMPTY_STRING;
         coredumpLocation = EMPTY_STRING;
         try {
             originCoredumpPath = config.getAttribute(
                     ITizenLaunchConfigurationConstants.ATTR_ORIGIN_COREFILE_PATH, EMPTY_STRING);
+            originCsPath = config.getAttribute(
+                    ITizenLaunchConfigurationConstants.ATTR_ORIGIN_CSFILE_PATH, EMPTY_STRING);
             coredumpLocation = config.getAttribute(
                     ITizenLaunchConfigurationConstants.ATTR_COREFILE_LOCATION, EMPTY_STRING);
         } catch (CoreException ce) {
             LaunchUIPlugin.log(ce);
         }
-        coredumpText.setText(originCoredumpPath);
-        if (originCoredumpPath.isEmpty()) {
-            setErrorMessages("Please set coredump archive");
-            return;
-        }
-        String fileName = FileUtil.getFileNameFromPath(originCoredumpPath);
-        if (CoredumpModel.LOCATION.REMOTE.toString().equals(coredumpLocation)) {
-            if (device != null) {
-                FileEntry entry = device.getFileEntry(originCoredumpPath);
-                if (entry == null || entry.getDate() == null) {
+        if (originCsPath.isEmpty()) {
+            enableArchiveGroup(true);
+            enableCorefileGroup(false);
+            coredumpText.setText(originCoredumpPath);
+            if (originCoredumpPath.isEmpty()) {
+                setErrorMessages("Please set coredump archive");
+                return;
+            }
+            String fileName = FileUtil.getFileNameFromPath(originCoredumpPath);
+            if (CoredumpModel.LOCATION.REMOTE.toString().equals(coredumpLocation)) {
+                if (device != null) {
+                    FileEntry entry = device.getFileEntry(originCoredumpPath);
+                    if (entry == null || entry.getDate() == null) {
+                        setErrorMessages(String.format(
+                                "\"%s\" device does not have coredump file (%s)",
+                                device.getDeviceName(), fileName));
+                    }
+                }
+            } else if (CoredumpModel.LOCATION.LOCAL.toString().equals(coredumpLocation)) {
+                File file = new File(originCoredumpPath);
+                if (!file.exists()) {
                     setErrorMessages(String.format(
-                            "\"%s\" device does not have coredump file (%s)",
-                            device.getDeviceName(), fileName));
+                            "The coredump file does not exist on local (%s)", fileName));
                 }
             }
-        } else if (CoredumpModel.LOCATION.LOCAL.toString().equals(coredumpLocation)) {
-            File file = new File(originCoredumpPath);
-            if (!file.exists()) {
-                setErrorMessages(String.format("The coredump file does not exist on local (%s)",
-                        fileName));
+        } else {
+            enableArchiveGroup(false);
+            enableCorefileGroup(true);
+            corefileText.setText(originCoredumpPath);
+            csfileText.setText(originCsPath);
+            if (originCoredumpPath.isEmpty() || originCsPath.isEmpty()) {
+                setErrorMessages("Please set coredump file and cs file");
+                return;
             }
+            String corefileName = FileUtil.getFileNameFromPath(originCoredumpPath);
+            String csfileName = FileUtil.getFileNameFromPath(originCsPath);
+            if (CoredumpModel.LOCATION.REMOTE.toString().equals(coredumpLocation)) {
+                if (device != null) {
+                    FileEntry entry = device.getFileEntry(originCoredumpPath);
+                    if (entry == null || entry.getDate() == null) {
+                        setErrorMessages(String.format(
+                                "\"%s\" device does not have coredump file (%s)",
+                                device.getDeviceName(), corefileName));
+                        return;
+                    }
+                    entry = device.getFileEntry(originCsPath);
+                    if (entry == null || entry.getDate() == null) {
+                        setErrorMessages(String.format("\"%s\" device does not have cs file (%s)",
+                                device.getDeviceName(), csfileName));
+                        return;
+                    }
+                }
+            }
+        }
+    }
+
+    protected void updateProgramPathFromConfig(ILaunchConfiguration config) {
+        programPath = EMPTY_STRING;
+        try {
+            programPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
+                    EMPTY_STRING);
+        } catch (CoreException ce) {
+            LaunchUIPlugin.log(ce);
+        }
+        if (programPath.isEmpty()) {
+            setErrorMessages("Please set executable file");
+            return;
         }
+        execText.setText(programPath);
     }
 
     private void setErrorMessages(String message) {
index a5dbcd1..6fac36a 100644 (file)
@@ -31,79 +31,63 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.ResourceBundle;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.cdt.ui.CElementLabelProvider;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.tizen.common.util.ImageUtil;
-import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
-import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.ui.adapter.ExtraPkgTableViewerAdapter;
-import org.tizen.nativeplatform.ui.listener.ExtraPkgTableHoverListener;
-import org.tizen.nativeplatform.ui.provider.ExtraPkgTableViewerProvider;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
 import org.tizen.sdblib.service.FileEntry;
 
-@SuppressWarnings({ "deprecation", "restriction" })
+@SuppressWarnings({ "restriction" })
 public class PlatformMainTab extends PlatformCommonTab {
 
     private final String BUNDLE_NAME = PlatformMainTab.class.getPackage().getName()
             + ".LaunchTabUIMessages";//$NON-NLS-1$
     private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
 
+    private String[] appId;
+    private String[] executablePath;
+    private String selectedAppId;
+    private String selectedExec;
+    private String appIdLabelText;
+    private String progLabelText;
+    private List<IAppIdChangeListener> idChangeListeners = new ArrayList<IAppIdChangeListener>();
+
+    private Combo appIdCombo;
     private Label fProgLabel;
-    private Text fAppProjText;
-    private Button fAppProjButton;
-    private Button removeBt;
-    private TableViewer tableViewer;
-    private boolean fSpecifyCoreFile;
     private List<IPackage> packages = new ArrayList<IPackage>();
-    private String selectedFileList = "";
 
     public PlatformMainTab() {
         this(false);
     }
 
-    public PlatformMainTab(boolean specifyCoreFile) {
-        fSpecifyCoreFile = specifyCoreFile;
+    public PlatformMainTab(boolean isDebug) {
+        if (isDebug) {
+            appIdLabelText = "Application to be debug:";
+            progLabelText = "Executable file:";
+        } else {
+            appIdLabelText = "Application to be run:";
+            progLabelText = "Command:";
+        }
     }
 
     @Override
@@ -116,184 +100,12 @@ public class PlatformMainTab extends PlatformCommonTab {
 
         createVerticalSpacer(comp, 1);
         createProjectGroup(comp, 1);
-        createAppProjectGroup(comp, 1);
+        createAppComboComposite(comp);
         createExeFileField(comp, 1);
-        createExtraTableGroup(comp);
-        createOptionGroupComposite(comp);
-
-        if (fSpecifyCoreFile) {
-            createCoreFileGroup(comp, 1);
-        }
         createVerticalSpacer(comp, 1);
     }
 
-    private void createTableTitleComposite(Composite parent) {
-        Label tableLabel = new Label(parent, SWT.NONE);
-        tableLabel.setText(resources.getString("Label.AdditionPkgs"));
-    }
-
-    private void createTableGroupComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        // composite.setLayout(new GridLayout(2, false));
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 2;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        GridData gridData = new GridData(GridData.FILL_BOTH);
-        gridData.minimumHeight = 100;
-        gridData.minimumWidth = 300;
-
-        composite.setLayout(gridLayout);
-        composite.setLayoutData(gridData);
-
-        createTableComposite(composite);
-        createTableButtonComposite(composite);
-    }
-
-    private void createTableComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayout(new FillLayout());
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        tableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
-        Table table = tableViewer.getTable();
-        table.setHeaderVisible(true);
-        table.setLinesVisible(true);
-
-        String[] columnNames = new String[] { "File Name" };
-
-        int[] columnWidths = new int[] { 300 };
-        for (int i = 0; i < columnNames.length; i++) {
-            TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-            tableColumn.setText(columnNames[i]);
-            tableColumn.setWidth(columnWidths[i]);
-            tableColumn.setResizable(true);
-            ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(tableViewer);
-            tableColumn.addSelectionListener(adapter);
-        }
-
-        tableViewer.setLabelProvider(new ExtraPkgTableViewerProvider());
-        tableViewer.setContentProvider(new ArrayContentProvider());
-        tableViewer.setInput(RootstrapManager.getRootstraps());
-
-        ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(),
-                tableViewer);
-        table.addListener(SWT.Dispose, hoverListener);
-        table.addListener(SWT.KeyDown, hoverListener);
-        table.addListener(SWT.MouseMove, hoverListener);
-        table.addListener(SWT.MouseHover, hoverListener);
-    }
-
-    private void createTableButtonComposite(Composite parent) {
-
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-        composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
-        Button addBt = new Button(composite, SWT.PUSH);
-        Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
-        addBt.setImage(addIcon);
-        addBt.addMouseListener(new MouseListener() {
-
-            @Override
-            public void mouseDoubleClick(MouseEvent e) {
-            }
-
-            @Override
-            public void mouseDown(MouseEvent e) {
-                FileDialog fd = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
-                fd.setText(resources.getString("File.Dialog.Title.File"));
-                String[] filterExt = { "*.rpm" };
-                fd.setFilterExtensions(filterExt);
-                selectedFileList = fd.open();
-                if (selectedFileList != null) {
-                    String[] files = fd.getFileNames();
-                    String path = fd.getFilterPath();
-                    for (String f : files) {
-                        String filePath = new Path(path).append(f).toOSString();
-                        IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil
-                                .getPkgType());
-                        IPackage p = maker.makeModel(filePath);
-                        if (!existsPkg(p)) {
-                            packages.add(p);
-                        }
-                    }
-                    tableViewer.refresh();
-                    if (packages.size() > 0) {
-                        removeBt.setEnabled(true);
-                    }
-                    updateLaunchConfigurationDialog();
-                }
-            }
-
-            @Override
-            public void mouseUp(MouseEvent e) {
-            }
-
-        });
-
-        removeBt = new Button(composite, SWT.PUSH);
-        Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
-        removeBt.setImage(removeIcon);
-        removeBt.setEnabled(false);
-        removeBt.addMouseListener(new MouseListener() {
-            @Override
-            public void mouseDoubleClick(MouseEvent e) {
-            }
-
-            @Override
-            public void mouseDown(MouseEvent e) {
-                TableItem[] items = tableViewer.getTable().getSelection();
-                for (TableItem item : items) {
-                    Object data = item.getData();
-                    if (data instanceof IPackage) {
-                        IPackage pkg = (IPackage) data;
-                        if (packages.contains(pkg)) {
-                            packages.remove(pkg);
-                            tableViewer.refresh();
-                            if (packages.size() <= 0) {
-                                removeBt.setEnabled(false);
-                            }
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void mouseUp(MouseEvent e) {
-            }
-        });
-    }
-
-    private void createExtraTableGroup(Composite parent) {
-
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout projLayout = new GridLayout();
-        projLayout.numColumns = 1;
-        projLayout.marginHeight = 0;
-        projLayout.marginWidth = 0;
-        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-        composite.setLayout(projLayout);
-        composite.setLayoutData(gd);
-
-        createTableTitleComposite(composite);
-        createTableGroupComposite(composite);
-    }
-
-    private boolean existsPkg(IPackage pkg) {
-        for (IPackage p : packages) {
-            if (pkg.getPath().equals(p.getPath())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void createAppProjectGroup(Composite parent, int colSpan) {
+    protected void createProjectGroup(Composite parent, int colSpan) {
         Composite projComp = new Composite(parent, SWT.NONE);
         GridLayout projLayout = new GridLayout();
         projLayout.numColumns = 2;
@@ -305,100 +117,59 @@ public class PlatformMainTab extends PlatformCommonTab {
         projComp.setLayoutData(gd);
 
         fProjLabel = new Label(projComp, SWT.NONE);
-        fProjLabel.setText(resources.getString("Label.App.Project"));
-        gd = new GridData();
-        gd.horizontalSpan = 2;
-        fProjLabel.setLayoutData(gd);
+        fProjLabel.setText(LaunchMessages.CMainTab_ProjectColon);
 
-        fAppProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+        fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
         gd = new GridData(GridData.FILL_HORIZONTAL);
-        fAppProjText.setLayoutData(gd);
-        fAppProjText.addModifyListener(new ModifyListener() {
-
-            public void modifyText(ModifyEvent evt) {
-                // if project changes, invalidate program name cache
-                fPreviouslyCheckedProgram = null;
-
-                updateBuildConfigCombo(""); //$NON-NLS-1$
-                updateLaunchConfigurationDialog();
-            }
-        });
+        fProjText.setLayoutData(gd);
+    }
 
-        fAppProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null);
-        fAppProjButton.addSelectionListener(new SelectionAdapter() {
+    public void registerAppIdChangeListener(IAppIdChangeListener listener) {
+        idChangeListeners.add(listener);
+    }
 
+    private void createAppComboComposite(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 2;
+        gridLayout.marginHeight = 0;
+        gridLayout.marginWidth = 0;
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label appIdLabel = new Label(composite, SWT.NONE);
+        appIdLabel.setText(appIdLabelText);
+        appIdCombo = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
+        GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        appIdCombo.setLayoutData(gridData);
+        appIdCombo.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
-                handleAppProjectButtonSelected();
-                updateLaunchConfigurationDialog();
+                String newAppId = ((Combo) evt.getSource()).getText();
+                int index = ((Combo) evt.getSource()).getSelectionIndex();
+                String newExec = executablePath[index];
+                if (!selectedAppId.equals(newAppId)) {
+                    changeCommand(selectedAppId, selectedExec, newAppId, newExec);
+                    notifyIdChanges(selectedAppId, selectedExec, newAppId, newExec);
+                    selectedAppId = newAppId;
+                }
             }
         });
     }
 
-    protected void handleAppProjectButtonSelected() {
-        String currentProjectName = fProjText.getText();
-        ICProject project = chooseCAppProject(currentProjectName);
-        if (project == null) {
-            return;
-        }
-
-        String projectName = project.getElementName();
-        fAppProjText.setText(projectName);
-    }
-
-    protected ICProject chooseCAppProject(String currentProjectName) {
-
-        try {
-            ICProject[] projects = getCProjects(currentProjectName);
-
-            ILabelProvider labelProvider = new CElementLabelProvider();
-            ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(),
-                    labelProvider);
-            dialog.setTitle(LaunchMessages.CMainTab_Project_Selection);
-            dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program);
-            dialog.setElements(projects);
-
-            ICProject cProject = getCProject();
-            if (cProject != null) {
-                dialog.setInitialSelections(new Object[] { cProject });
-            }
-            if (dialog.open() == Window.OK) {
-                return (ICProject) dialog.getFirstResult();
-            }
-        } catch (CModelException e) {
-            LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$                   
+    private void changeCommand(String prevId, String prevExec, String newId, String newExec) {
+        String command = fBinPathText.getText();
+        String changed = PlatformLaunchUtil
+                .changeCommand(command, prevId, prevExec, newId, newExec);
+        if (changed != null) {
+            fBinPathText.setText(changed);
         }
-        return null;
     }
 
-    protected ICProject[] getCProjects(String currentProjectName) throws CModelException {
-        ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
-        ArrayList<ICProject> list = new ArrayList<ICProject>(cproject.length);
-
-        for (int i = 0; i < cproject.length; i++) {
-            if (currentProjectName.length() != 0
-                    && cproject[i].getProject().getName().equals(currentProjectName)) {
-                continue;
-            }
-            ICDescriptor cdesciptor = null;
-            try {
-                cdesciptor = CCorePlugin.getDefault().getCProjectDescription(
-                        (IProject) cproject[i].getResource(), false);
-                if (cdesciptor != null) {
-                    String projectPlatform = cdesciptor.getPlatform();
-                    if (filterPlatform.equals("*") //$NON-NLS-1$
-                            || projectPlatform.equals("*") //$NON-NLS-1$
-                            || filterPlatform.equalsIgnoreCase(projectPlatform) == true) {
-                        list.add(cproject[i]);
-                    }
-                } else {
-                    list.add(cproject[i]);
-                }
-            } catch (CoreException e) {
-                list.add(cproject[i]);
-            }
+    private void notifyIdChanges(String prevId, String prevExec, String newId, String newExec) {
+        for (IAppIdChangeListener l : idChangeListeners) {
+            l.appIdchanged(prevId, prevExec, newId, newExec);
         }
-        return list.toArray(new ICProject[list.size()]);
     }
 
     private void createExeFileField(Composite parent, int colSpan) {
@@ -412,7 +183,7 @@ public class PlatformMainTab extends PlatformCommonTab {
         gd.horizontalSpan = colSpan;
         mainComp.setLayoutData(gd);
         fProgLabel = new Label(mainComp, SWT.NONE);
-        fProgLabel.setText(resources.getString("Label.App.Path")); // $NON-NLS-1$
+        fProgLabel.setText(progLabelText); // $NON-NLS-1$
         gd = new GridData();
         gd.horizontalSpan = 3;
         fProgLabel.setLayoutData(gd);
@@ -445,14 +216,48 @@ public class PlatformMainTab extends PlatformCommonTab {
 
     @Override
     public void initializeFrom(ILaunchConfiguration configuration) {
+
         updateProgramFromConfig(configuration);
         updateProjectFromConfig(configuration);
-        updateAppProjectFromConfig(configuration);
-        updateExtraTableFromConfig(configuration);
-        updateReinstallOpFromConfig(configuration);
-        updateSelectPkgOpFromConfig(configuration);
-        if (fSpecifyCoreFile) {
-            updateCoreFromConfig(configuration);
+        updateAppIdFromConfig(configuration);
+
+        ICProject cproj = getCProject();
+        appIdCombo.removeAll();
+        if (cproj != null) {
+            IProject proj = cproj.getProject();
+            boolean isEflProj = PlatformProjectUtil.isEFLApplication(proj);
+            appId = PlatformLaunchUtil.getAppId(proj);
+            if (appId == null || appId.length == 0) {
+                if (isEflProj) {
+                    String msg = String.format(
+                            "Failed to get application ID. Build \"%s\" project first",
+                            proj.getName());
+                    setErrorMessage(msg);
+                } else {
+                    String msg = String
+                            .format("\"%s\" project is not EFL application. Input command to test \"%s\" project",
+                                    proj.getName(), proj.getName());
+                    setErrorMessage(null);
+                    setMessage(msg);
+                }
+            } else {
+                executablePath = PlatformLaunchUtil.getProgramPath(proj);
+                appIdCombo.setItems(appId);
+                int index = appIdCombo.indexOf(selectedAppId);
+                if (index < 0) {
+                    selectedAppId = appId[0];
+                    index = 0;
+                }
+                appIdCombo.select(index);
+                selectedExec = executablePath[index];
+                String msg = String
+                        .format("\"%s\" project is EFL application. Choose application ID to be run or debug.",
+                                proj.getName());
+                setErrorMessage(null);
+                setMessage(msg);
+            }
+        } else {
+            setErrorMessage("Failed to get project.");
         }
     }
 
@@ -472,9 +277,7 @@ public class PlatformMainTab extends PlatformCommonTab {
     public void performApply(ILaunchConfigurationWorkingCopy config) {
         String programPath = fBinPathText.getText().trim();
         String name = fProjText.getText().trim();
-        String appProj = fAppProjText.getText().trim();
-        boolean reinstallOp = fReinstallOp.getSelection();
-        boolean selectPkgOp = fSelectPkgOp.getSelection();
+        String appId = appIdCombo.getText().trim();
         List<String> pkgs = new ArrayList<String>();
 
         for (IPackage p : packages) {
@@ -483,34 +286,17 @@ public class PlatformMainTab extends PlatformCommonTab {
 
         config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
         config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
-        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, appProj);
-        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, pkgs);
-        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
-    }
-
-    protected void updateAppProjectFromConfig(ILaunchConfiguration config) {
-        String projectName = EMPTY_STRING;
-        try {
-            projectName = config.getAttribute(
-                    ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, EMPTY_STRING);
-        } catch (CoreException ce) {
-            LaunchUIPlugin.log(ce);
-        }
-        fAppProjText.setText(projectName);
+        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APPLICATION_ID, appId);
     }
 
-    @SuppressWarnings("unchecked")
-    protected void updateExtraTableFromConfig(ILaunchConfiguration config) {
+    protected void updateAppIdFromConfig(ILaunchConfiguration config) {
+        String id = EMPTY_STRING;
         try {
-            List<String> pkgs = (ArrayList<String>) config.getAttribute(
-                    ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST,
-                    new ArrayList<String>());
-            IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType());
-            packages = maker.makeModels(pkgs);
-            tableViewer.setInput(packages);
+            id = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_APPLICATION_ID,
+                    EMPTY_STRING);
         } catch (CoreException ce) {
             LaunchUIPlugin.log(ce);
         }
+        selectedAppId = id;
     }
 }
\ No newline at end of file
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformPackagesTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformPackagesTab.java
new file mode 100644 (file)
index 0000000..f1ff2c3
--- /dev/null
@@ -0,0 +1,524 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.tizen.common.util.ImageUtil;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
+import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
+import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.ui.adapter.ExtraPkgTableViewerAdapter;
+import org.tizen.nativeplatform.ui.listener.ExtraPkgTableHoverListener;
+import org.tizen.nativeplatform.ui.provider.ExtraPkgTableViewerProvider;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
+
+@SuppressWarnings({ "deprecation", "restriction" })
+public class PlatformPackagesTab extends PlatformCommonTab {
+
+    private final String BUNDLE_NAME = PlatformPackagesTab.class.getPackage().getName()
+            + ".LaunchTabUIMessages";//$NON-NLS-1$
+    private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+    private Button rootstrapRemoveBt;
+    private Button deviceRemoveBt;
+    private TableViewer rootstrapTableViewer;
+    private TableViewer deviceTableViewer;
+    private List<IPackage> devicePackages = new ArrayList<IPackage>();
+    private List<IPackage> rootstrapPackages = new ArrayList<IPackage>();
+    private String selectedFileList = "";
+    private boolean isDebug;
+
+    public PlatformPackagesTab(boolean isDebug) {
+        super();
+        this.isDebug = isDebug;
+    }
+
+    public String getName() {
+        return "Packages";
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        Composite comp = new Composite(parent, SWT.NONE);
+        setControl(comp);
+
+        GridLayout topLayout = new GridLayout();
+        comp.setLayout(topLayout);
+
+        if (isDebug) {
+            createDeviceTableGroup(comp, 130);
+            createRootstrapTableGroup(comp, 130);
+        } else {
+            createDeviceTableGroup(comp, 260);
+        }
+        createOptionGroupComposite(comp);
+        createVerticalSpacer(comp, 1);
+    }
+
+    private void createDeviceTableGroupComposite(Composite parent, int heightHint) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 2;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        gridData.minimumHeight = heightHint;
+        gridData.minimumWidth = 300;
+
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(gridData);
+
+        createLabelComposite(composite, "Packages to be installed to the device:");
+        createDeviceTableComposite(composite, heightHint);
+        createDeviceTableButtonComposite(composite);
+    }
+
+    private void createLabelComposite(Composite parent, String label) {
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        gridData.horizontalSpan = 2;
+        Label descLabel = new Label(parent, SWT.NONE);
+        descLabel.setText(label);
+        descLabel.setLayoutData(gridData);
+    }
+
+    private void createRootstrapTableGroupComposite(Composite parent, int heightHint) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 2;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        gridData.minimumHeight = heightHint;
+        gridData.minimumWidth = 300;
+
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(gridData);
+
+        createLabelComposite(composite, "Packages to be installed to the rootstrap:");
+        createRootstrapTableComposite(composite, heightHint);
+        createRootstrapTableButtonComposite(composite);
+    }
+
+    private void createDeviceTableComposite(Composite parent, int heightHint) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayout(new FillLayout());
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        gridData.minimumWidth = 350;
+        gridData.heightHint = heightHint;
+        composite.setLayoutData(gridData);
+
+        deviceTableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+        Table table = deviceTableViewer.getTable();
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        String[] columnNames = new String[] { "Package Name" };
+
+        int[] columnWidths = new int[] { 300 };
+        for (int i = 0; i < columnNames.length; i++) {
+            TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+            tableColumn.setText(columnNames[i]);
+            tableColumn.setWidth(columnWidths[i]);
+            tableColumn.setResizable(true);
+            ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(deviceTableViewer);
+            tableColumn.addSelectionListener(adapter);
+        }
+
+        deviceTableViewer.setLabelProvider(new ExtraPkgTableViewerProvider());
+        deviceTableViewer.setContentProvider(new ArrayContentProvider());
+        deviceTableViewer.setInput(RootstrapManager.getRootstraps());
+
+        ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(),
+                deviceTableViewer);
+        table.addListener(SWT.Dispose, hoverListener);
+        table.addListener(SWT.KeyDown, hoverListener);
+        table.addListener(SWT.MouseMove, hoverListener);
+        table.addListener(SWT.MouseHover, hoverListener);
+    }
+
+    private void createDeviceTableButtonComposite(Composite parent) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 1;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+        Button addBt = new Button(composite, SWT.PUSH);
+        Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
+        addBt.setImage(addIcon);
+        addBt.addMouseListener(new MouseListener() {
+
+            @Override
+            public void mouseDoubleClick(MouseEvent e) {
+            }
+
+            @Override
+            public void mouseDown(MouseEvent e) {
+                FileDialog fd = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
+                fd.setText(resources.getString("File.Dialog.Title.File"));
+                String[] filterExt = { "*.rpm" };
+                fd.setFilterExtensions(filterExt);
+                selectedFileList = fd.open();
+                if (selectedFileList != null) {
+                    String[] files = fd.getFileNames();
+                    String path = fd.getFilterPath();
+                    for (String f : files) {
+                        String filePath = new Path(path).append(f).toOSString();
+                        IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil
+                                .getPkgType());
+                        IPackage p = maker.makeModel(filePath);
+                        if (!existsPkg(p, devicePackages)) {
+                            devicePackages.add(p);
+                        }
+                    }
+                    deviceTableViewer.refresh();
+                    if (devicePackages.size() > 0) {
+                        deviceRemoveBt.setEnabled(true);
+                    }
+                    updateLaunchConfigurationDialog();
+                }
+            }
+
+            @Override
+            public void mouseUp(MouseEvent e) {
+            }
+
+        });
+
+        deviceRemoveBt = new Button(composite, SWT.PUSH);
+        Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+        deviceRemoveBt.setImage(removeIcon);
+        if (devicePackages.size() > 0) {
+            deviceRemoveBt.setEnabled(true);
+        }
+        deviceRemoveBt.addMouseListener(new MouseListener() {
+            @Override
+            public void mouseDoubleClick(MouseEvent e) {
+            }
+
+            @Override
+            public void mouseDown(MouseEvent e) {
+                TableItem[] items = deviceTableViewer.getTable().getSelection();
+                for (TableItem item : items) {
+                    Object data = item.getData();
+                    if (data instanceof IPackage) {
+                        IPackage pkg = (IPackage) data;
+                        if (devicePackages.contains(pkg)) {
+                            devicePackages.remove(pkg);
+                            deviceTableViewer.refresh();
+                            if (devicePackages.size() <= 0) {
+                                deviceRemoveBt.setEnabled(false);
+                            }
+                            updateLaunchConfigurationDialog();
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public void mouseUp(MouseEvent e) {
+            }
+        });
+    }
+
+    private void createRootstrapTableComposite(Composite parent, int heightHint) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayout(new FillLayout());
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        gridData.minimumWidth = 350;
+        gridData.heightHint = heightHint;
+        composite.setLayoutData(gridData);
+
+        rootstrapTableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+        Table table = rootstrapTableViewer.getTable();
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        String[] columnNames = new String[] { "Package Name" };
+
+        int[] columnWidths = new int[] { 300 };
+        for (int i = 0; i < columnNames.length; i++) {
+            TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+            tableColumn.setText(columnNames[i]);
+            tableColumn.setWidth(columnWidths[i]);
+            tableColumn.setResizable(true);
+            ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(
+                    rootstrapTableViewer);
+            tableColumn.addSelectionListener(adapter);
+        }
+
+        rootstrapTableViewer.setLabelProvider(new ExtraPkgTableViewerProvider());
+        rootstrapTableViewer.setContentProvider(new ArrayContentProvider());
+        rootstrapTableViewer.setInput(RootstrapManager.getRootstraps());
+
+        ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(),
+                rootstrapTableViewer);
+        table.addListener(SWT.Dispose, hoverListener);
+        table.addListener(SWT.KeyDown, hoverListener);
+        table.addListener(SWT.MouseMove, hoverListener);
+        table.addListener(SWT.MouseHover, hoverListener);
+    }
+
+    private void createRootstrapTableButtonComposite(Composite parent) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 1;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        composite.setLayout(gridLayout);
+        composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+        Button addBt = new Button(composite, SWT.PUSH);
+        Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
+        addBt.setImage(addIcon);
+        addBt.addMouseListener(new MouseListener() {
+
+            @Override
+            public void mouseDoubleClick(MouseEvent e) {
+            }
+
+            @Override
+            public void mouseDown(MouseEvent e) {
+                FileDialog fd = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
+                fd.setText(resources.getString("File.Dialog.Title.File"));
+                String[] filterExt = { "*.rpm" };
+                fd.setFilterExtensions(filterExt);
+                selectedFileList = fd.open();
+                if (selectedFileList != null) {
+                    String[] files = fd.getFileNames();
+                    String path = fd.getFilterPath();
+                    for (String f : files) {
+                        String filePath = new Path(path).append(f).toOSString();
+                        IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil
+                                .getPkgType());
+                        IPackage p = maker.makeModel(filePath);
+                        if (!existsPkg(p, rootstrapPackages)) {
+                            rootstrapPackages.add(p);
+                        }
+                    }
+                    rootstrapTableViewer.refresh();
+                    if (rootstrapPackages.size() > 0) {
+                        rootstrapRemoveBt.setEnabled(true);
+                    }
+                    updateLaunchConfigurationDialog();
+                }
+            }
+
+            @Override
+            public void mouseUp(MouseEvent e) {
+            }
+
+        });
+
+        rootstrapRemoveBt = new Button(composite, SWT.PUSH);
+        Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+        rootstrapRemoveBt.setImage(removeIcon);
+        if (rootstrapPackages.size() > 0) {
+            rootstrapRemoveBt.setEnabled(true);
+        }
+        rootstrapRemoveBt.addMouseListener(new MouseListener() {
+            @Override
+            public void mouseDoubleClick(MouseEvent e) {
+            }
+
+            @Override
+            public void mouseDown(MouseEvent e) {
+                TableItem[] items = rootstrapTableViewer.getTable().getSelection();
+                for (TableItem item : items) {
+                    Object data = item.getData();
+                    if (data instanceof IPackage) {
+                        IPackage pkg = (IPackage) data;
+                        if (rootstrapPackages.contains(pkg)) {
+                            rootstrapPackages.remove(pkg);
+                            rootstrapTableViewer.refresh();
+                            if (rootstrapPackages.size() <= 0) {
+                                rootstrapRemoveBt.setEnabled(false);
+                            }
+                            updateLaunchConfigurationDialog();
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public void mouseUp(MouseEvent e) {
+            }
+        });
+    }
+
+    private void createDeviceTableGroup(Composite parent, int heightHint) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout projLayout = new GridLayout();
+        projLayout.numColumns = 1;
+        projLayout.marginHeight = 0;
+        projLayout.marginWidth = 0;
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        composite.setLayout(projLayout);
+        composite.setLayoutData(gd);
+
+        createDeviceTableGroupComposite(composite, heightHint);
+    }
+
+    private void createRootstrapTableGroup(Composite parent, int heightHint) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout projLayout = new GridLayout();
+        projLayout.numColumns = 1;
+        projLayout.marginHeight = 0;
+        projLayout.marginWidth = 0;
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        composite.setLayout(projLayout);
+        composite.setLayoutData(gd);
+
+        createRootstrapTableGroupComposite(composite, heightHint);
+    }
+
+    private boolean existsPkg(IPackage pkg, List<IPackage> list) {
+        for (IPackage p : list) {
+            if (pkg.getPath().equals(p.getPath())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void initializeFrom(ILaunchConfiguration configuration) {
+        updatePackageTableFromConfig(configuration);
+        updateReinstallOpFromConfig(configuration);
+    }
+
+    @Override
+    public boolean isValid(ILaunchConfiguration config) {
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.eclipse.cdt.launch.ui.CMainTab#performApply(org.eclipse.debug.core
+     * .ILaunchConfigurationWorkingCopy)
+     */
+    @Override
+    public void performApply(ILaunchConfigurationWorkingCopy config) {
+        boolean reinstallOp = fReinstallOp.getSelection();
+        List<String> devicePkgs = new ArrayList<String>();
+        for (IPackage p : devicePackages) {
+            devicePkgs.add(p.getPath());
+        }
+        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_DEVICE_PACKAGE_LIST, devicePkgs);
+
+        if (isDebug) {
+            List<String> rootstrapPkgs = new ArrayList<String>();
+            for (IPackage p : rootstrapPackages) {
+                rootstrapPkgs.add(p.getPath());
+            }
+            config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_PACKAGE_LIST,
+                    rootstrapPkgs);
+        }
+        config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
+    }
+
+    @SuppressWarnings("unchecked")
+    private void updateDevicePackageFromConfig(ILaunchConfiguration config) throws CoreException {
+        List<String> devicePkgs = (List<String>) config.getAttribute(
+                ITizenLaunchConfigurationConstants.ATTR_DEVICE_PACKAGE_LIST,
+                new ArrayList<String>());
+        devicePackages.clear();
+        deviceTableViewer.getTable().clearAll();
+        if (devicePkgs.isEmpty()) {
+            setErrorMessage("Failed to get packages. Build a project first");
+        } else {
+            IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType());
+            devicePackages.addAll(maker.makeModels(devicePkgs));
+            deviceTableViewer.setInput(devicePackages);
+            setErrorMessage(null);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void updateRootstrapPackageFromConfig(ILaunchConfiguration config) throws CoreException {
+        List<String> rootstrapPkgs = (List<String>) config.getAttribute(
+                ITizenLaunchConfigurationConstants.ATTR_ROOTSTRAP_PACKAGE_LIST,
+                new ArrayList<String>());
+        rootstrapPackages.clear();
+        rootstrapTableViewer.getTable().clearAll();
+        if (rootstrapPkgs.isEmpty()) {
+            setErrorMessage("Failed to get packages. Build a project first");
+        } else {
+            IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType());
+            rootstrapPackages.addAll(maker.makeModels(rootstrapPkgs));
+            rootstrapTableViewer.setInput(rootstrapPackages);
+            setErrorMessage(null);
+        }
+    }
+
+    protected void updatePackageTableFromConfig(ILaunchConfiguration config) {
+        try {
+            updateDevicePackageFromConfig(config);
+            if (isDebug) {
+                updateRootstrapPackageFromConfig(config);
+            }
+        } catch (CoreException ce) {
+            LaunchUIPlugin.log(ce);
+        }
+    }
+}
\ No newline at end of file
index 108827a..4d97904 100644 (file)
@@ -85,7 +85,6 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
 
     protected String programPath = null;
     protected boolean reinstallOp = true;
-    protected boolean selectPkgOp = true;
     protected IDevice device = null;
     protected PkgCommandTarget target = null;
     private PackageUtil pkgUtil = null;
@@ -332,7 +331,6 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
 
     protected void setOptionsAttr(ILaunchConfigurationWorkingCopy wc) {
         wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
-        wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
         wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
     }
 
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectDebugShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectDebugShortcut.java
new file mode 100644 (file)
index 0000000..b69ac94
--- /dev/null
@@ -0,0 +1,11 @@
+package org.tizen.nativeplatform.launch.ui.shortcut;
+
+import org.eclipse.debug.core.ILaunchConfigurationType;
+
+public class PlatformProjectDebugShortcut extends PlatformProjectLaunchShortcut {
+    @Override
+    protected ILaunchConfigurationType getCLaunchConfigType() {
+        return getLaunchManager().getLaunchConfigurationType(
+                "org.tizen.nativeplatform.debug.PlatformLaunchConfigurationType");
+    }
+}
index 2dc0840..2f4a542 100644 (file)
@@ -9,6 +9,9 @@ BinPage.Desc = Please set a path for test binary
 BinPage.Button.Browse = Remote Browse...
 BinPage.Remote.Dialog.Title = Select an Application
 
+EFLBinPage.Title = Setting Launch Command
+EFLBinPage.Desc = Please set launch command.
+
 ProcPage.Title = Select Process
 ProcPage.Desc = Please select a process for attach debugging
 ProcPage.Label.ProcName = Process:
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformEFLLaunchSettingPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformEFLLaunchSettingPage.java
new file mode 100644 (file)
index 0000000..ad65bde
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizard.pages;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
+
+public class PlatformEFLLaunchSettingPage extends PlatformLaunchSettingPage {
+
+    private final String BUNDLE_NAME = PlatformEFLLaunchSettingPage.class.getPackage().getName()
+            + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
+    private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+    private String[] appId;
+    private String[] executablePath;
+    private String prevAppId;
+    private String prevExec;
+    private String appIdLabelText;
+
+    private Combo appIdCombo;
+
+    public PlatformEFLLaunchSettingPage(PlatformLaunchWizard wizard, Shell shell,
+            String pageName, IProject project, IConfiguration config, PkgCommandTarget cmdTarget,
+            String descMsg, String mode) {
+        super(wizard, shell, pageName, project, config, cmdTarget, descMsg, mode);
+
+        appId = PlatformLaunchUtil.getAppId(project);
+        executablePath = PlatformLaunchUtil.getProgramPath(project);
+        prevAppId = appId[0];
+        prevExec = executablePath[0];
+
+        if (isDebug) {
+            commandInitText = executablePath[0];
+            appIdLabelText = "Application to be debug:";
+        } else {
+            commandInitText = LAUNCH_APP_COMMAND;
+            argumentsInitText = appId[0];
+            appIdLabelText = "Application to be run:";
+        }
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 1;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        composite.setLayout(gridLayout);
+        createInfoComposite(composite);
+        createAppComboComposite(composite);
+        createRunCommandComposite(composite, false);
+
+        setControl(composite);
+        validate();
+    }
+
+    private void createAppComboComposite(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        composite.setLayout(new GridLayout(2, false));
+        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        Label appIdLabel = new Label(composite, SWT.NONE);
+        appIdLabel.setText(appIdLabelText);
+        appIdCombo = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
+        GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        appIdCombo.setLayoutData(gridData);
+        appIdCombo.setItems(appId);
+        appIdCombo.select(0);
+        appIdCombo.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                String newAppId = ((Combo) evt.getSource()).getText();
+                int index = ((Combo) evt.getSource()).getSelectionIndex();
+                String newExec = executablePath[index];
+                String command = commandText.getText().trim();
+                String args = argumentsText.getText().trim();
+
+                if (!prevAppId.equals(newAppId)) {
+                    String newCommand = PlatformLaunchUtil.changeCommand(command, prevAppId,
+                            prevExec, newAppId, newExec);
+                    if (newCommand != null) {
+                        commandText.setText(newCommand);
+                    }
+                    String newArgs = PlatformLaunchUtil.changeCommand(args, prevAppId, prevExec,
+                            newAppId, newExec);
+                    if (newArgs != null) {
+                        argumentsText.setText(newArgs);
+                    }
+                    prevAppId = newAppId;
+                    prevExec = newExec;
+                }
+            }
+        });
+    }
+
+    public String getSelectedApp() {
+        return appIdCombo.getText();
+    }
+}
index 8ea407c..edbacca 100644 (file)
@@ -10,8 +10,11 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.pkg.commander.IPkgFilter;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.commander.factory.PkgFilterFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.types.CmdTargetTypes;
 import org.tizen.nativeplatform.util.PackageUtil;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
@@ -20,16 +23,19 @@ import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 public class PlatformLaunchCommonPage extends WizardPage {
 
     protected Button reinstallOp;
-    protected Button selectPkgOp;
 
     protected IProject platformProject;
     protected IConfiguration config;
     protected List<IPackage> platformPackages = new ArrayList<IPackage>();
     protected List<IPackage> packages = new ArrayList<IPackage>();
+    protected List<IPackage> devicePackages = new ArrayList<IPackage>();
+    protected List<IPackage> rootstrapPackages = new ArrayList<IPackage>();
     protected PlatformRootstrap rootstrap;
     protected String rootPath = "";
     protected Shell shell;
     protected PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
+    protected IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil
+            .getPkgType());
 
     protected PlatformLaunchCommonPage(String pageName) {
         super(pageName);
@@ -63,21 +69,27 @@ public class PlatformLaunchCommonPage extends WizardPage {
         // (PlatformProjectLaunchShortcut)
         if (!platformPackages.isEmpty()) {
             packages.addAll(platformPackages);
+            devicePackages.addAll(pkgFilter.filter(CmdTargetTypes.DEVICE, packages));
+            rootstrapPackages.addAll(pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, packages));
         }
     }
 
     public List<IPackage> getPackages() {
         return packages;
     }
+    
+    public List<IPackage> getDevicePackages() {
+        return devicePackages;
+    }
+    
+    public List<IPackage> getRootstrapPackages() {
+        return rootstrapPackages;
+    }
 
     public boolean getReinstallOp() {
         return reinstallOp.getSelection();
     }
 
-    public boolean getSelectPkgOp() {
-        return selectPkgOp.getSelection();
-    }
-
     public String getRootstrapPath() {
         return rootPath;
     }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java
deleted file mode 100644 (file)
index 6a13256..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.wizard.pages;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.tizen.common.util.ImageUtil;
-import org.tizen.nativecommon.build.CommonBuildMessages;
-import org.tizen.nativeplatform.Activator;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
-import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
-import org.tizen.nativeplatform.pkg.model.IPackage;
-import org.tizen.nativeplatform.ui.adapter.ExtraPkgTableViewerAdapter;
-import org.tizen.nativeplatform.ui.listener.ExtraPkgTableHoverListener;
-import org.tizen.nativeplatform.ui.provider.ExtraPkgTableViewerProvider;
-import org.tizen.nativeplatform.util.PlatformLaunchUtil;
-import org.tizen.nativeplatform.util.PlatformProjectUtil;
-
-public class PlatformLaunchSettingAppPage extends PlatformLaunchCommonPage {
-
-    private final String BUNDLE_NAME = PlatformLaunchSettingAppPage.class.getPackage().getName()
-            + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
-    private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
-    private TableViewer tableViewer;
-    private FileDialog fd;
-    private Combo projectCombo;
-    private Button removeBt;
-    private IProject appProj;
-    private String selectedFileList = "";
-    private String binaryPath = "";
-    private boolean packagingResult;
-    private List<IPackage> appPackages = new ArrayList<IPackage>();
-    private List<IPackage> extraPackages = new ArrayList<IPackage>();
-    private List<String> projectNames = new ArrayList<String>();
-    private Map<String, IProject> projectMap = new HashMap<String, IProject>();
-    private IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil
-            .getPkgType());
-
-    public PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project,
-            IConfiguration config, PkgCommandTarget target) {
-        super(pageName, shell, project, config, target);
-
-        setTitle(resources.getString("AppPage.Title"));
-        setDescription(resources.getString("AppPage.Desc"));
-        setPageComplete(true);
-        setProjectMap();
-        setPlatformPackages();
-    }
-
-    // if package files exist, set application packages
-    // if it does not exist, packaging the project.
-    private void setAppPackages() {
-        appPackages.clear();
-        appPackages = pkgUtil.getPackages(appProj, config);
-        if (appPackages.isEmpty()) {
-            if (PlatformLaunchUtil.questionPackaging(appProj)) {
-                if (packagingProject(appProj)) {
-                    setAppPackages();
-                }
-            }
-        }
-    }
-
-    private void setProjectMap() {
-        IWorkspace works = ResourcesPlugin.getWorkspace();
-        IProject[] projs = works.getRoot().getProjects();
-        projectNames.add(PlatformLaunchUtil.APP_PROJ_DEFAULT_SELECTION);
-        for (IProject p : projs) {
-            IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(p);
-            if (info == null) {
-                continue;
-            }
-            IConfiguration cfg = info.getDefaultConfiguration();
-            if (cfg == null) {
-                continue;
-            }
-            IManagedProject managedProject = cfg.getManagedProject();
-            if (managedProject == null) {
-                continue;
-            }
-            String projectArtifactType = managedProject.getProjectType() != null ? managedProject
-                    .getProjectType().getBuildArtefactType().getId() : null;
-            if (projectArtifactType != null
-                    && projectArtifactType
-                            .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)
-                    && !platformProject.getName().equals(p.getName())) {
-                String name = p.getName();
-                projectMap.put(name, p);
-                projectNames.add(name);
-            }
-        }
-    }
-
-    @Override
-    public void createControl(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        composite.setLayout(new GridLayout(1, false));
-        GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-        gridData.minimumHeight = 0;
-        composite.setLayoutData(gridData);
-
-        createProjectsComposite(composite);
-        createTableTitleComposite(composite);
-        createTableGroupComposite(composite);
-        createOptionGroupComposite(composite);
-
-        setControl(composite);
-    }
-
-    private void createOptionGroupComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-
-        reinstallOp = new Button(composite, SWT.CHECK);
-        reinstallOp.setText(resources.getString("Button.Reinstall.Op"));
-        reinstallOp.setSelection(true);
-        selectPkgOp = new Button(composite, SWT.CHECK);
-        selectPkgOp.setText(resources.getString("Button.SelectPkg.Op"));
-        selectPkgOp.setSelection(false);
-    }
-
-    private void createTableTitleComposite(Composite parent) {
-        Label tableLabel = new Label(parent, SWT.NONE);
-        tableLabel.setText(resources.getString("AppPage.Label.AdditionPkgs"));
-    }
-
-    private void createProjectsComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 2;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-        Label projectLabel = new Label(composite, SWT.NONE);
-        projectLabel.setText(resources.getString("AppPage.Label.Project"));
-
-        GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-        composite.setLayoutData(gridData);
-
-        projectCombo = new Combo(composite, SWT.READ_ONLY);
-        projectCombo.setLayoutData(gridData);
-        projectCombo.setItems(projectNames.toArray(new String[0]));
-        projectCombo.addSelectionListener(new SelectionListener() {
-
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                String selected = projectCombo.getText().trim();
-                if (PlatformLaunchUtil.APP_PROJ_DEFAULT_SELECTION.equals(selected)) {
-                    packages.clear();
-                    appPackages.clear();
-                    packages.addAll(platformPackages);
-                    packages.addAll(extraPackages);
-                } else {
-                    appProj = projectMap.get(selected);
-                    setAppPackages();
-                    packages.clear();
-                    packages.addAll(platformPackages);
-                    // packages.addAll(appPackages);
-                    packages.addAll(extraPackages);
-
-                    // if project is efl application, return app binary path.
-                    if (PlatformProjectUtil.isEFLApplication(appProj)) {
-                        String[] files = PlatformLaunchUtil.getProgramPath(appProj);
-                        if (files != null && files.length > 0) {
-                            binaryPath = files[0];
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void widgetDefaultSelected(SelectionEvent e) {
-            }
-        });
-
-        projectCombo.select(0);
-    }
-
-    private void createTableComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-        GridData gridData = new GridData(GridData.FILL_BOTH);
-        gridData.minimumWidth = 350;
-        gridData.minimumHeight = 200;
-        composite.setLayoutData(gridData);
-
-        Composite t_composite = new Composite(composite, SWT.NONE);
-        t_composite.setLayout(new FillLayout());
-        t_composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        tableViewer = new TableViewer(t_composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
-        Table table = tableViewer.getTable();
-
-        table.setHeaderVisible(true);
-        table.setLinesVisible(true);
-
-        String[] columnNames = new String[] { "RPM files" };
-
-        int[] columnWidths = new int[] { 450 };
-        for (int i = 0; i < columnNames.length; i++) {
-            TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-
-            tableColumn.setText(columnNames[i]);
-            tableColumn.setWidth(columnWidths[i]);
-            tableColumn.setResizable(true);
-            ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(tableViewer);
-            tableColumn.addSelectionListener(adapter);
-        }
-
-        tableViewer.setLabelProvider(new ExtraPkgTableViewerProvider());
-        tableViewer.setContentProvider(new ArrayContentProvider());
-        packages.addAll(extraPackages);
-        tableViewer.setInput(extraPackages);
-
-        ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(),
-                tableViewer);
-        table.addListener(SWT.Dispose, hoverListener);
-        table.addListener(SWT.KeyDown, hoverListener);
-        table.addListener(SWT.MouseMove, hoverListener);
-        table.addListener(SWT.MouseHover, hoverListener);
-    }
-
-    private void createTableButtonsComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 1;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-
-        Button addBt = new Button(composite, SWT.PUSH);
-        Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
-        addBt.setImage(addIcon);
-        addBt.addMouseListener(new MouseListener() {
-
-            @Override
-            public void mouseDoubleClick(MouseEvent e) {
-            }
-
-            @Override
-            public void mouseDown(MouseEvent e) {
-                fd = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
-                fd.setText(resources.getString("AppPage.Dialog.Title.File"));
-                String[] filterExt = { "*.rpm" };
-                fd.setFilterExtensions(filterExt);
-                selectedFileList = fd.open();
-                System.out.println(selectedFileList);
-                if (selectedFileList != null) {
-                    String[] files = fd.getFileNames();
-                    String path = fd.getFilterPath();
-                    for (String f : files) {
-                        String filePath = new Path(path).append(f).toOSString();
-                        IPackage p = modelMaker.makeModel(filePath, false);
-                        extraPackages.add(p);
-                    }
-                    packages.clear();
-                    packages.addAll(platformPackages);
-                    // packages.addAll(appPackages);
-                    packages.addAll(extraPackages);
-                    tableViewer.refresh();
-                    if (extraPackages.size() > 0) {
-                        removeBt.setEnabled(true);
-                    }
-                }
-            }
-
-            @Override
-            public void mouseUp(MouseEvent e) {
-            }
-
-        });
-
-        removeBt = new Button(composite, SWT.PUSH);
-        Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
-        removeBt.setImage(removeIcon);
-        removeBt.setEnabled(false);
-        removeBt.addMouseListener(new MouseListener() {
-
-            @Override
-            public void mouseDoubleClick(MouseEvent e) {
-            }
-
-            @Override
-            public void mouseDown(MouseEvent e) {
-                TableItem[] items = tableViewer.getTable().getSelection();
-                for (TableItem item : items) {
-                    Object data = item.getData();
-                    if (data instanceof IPackage) {
-                        IPackage pkg = (IPackage) data;
-                        if (packages.contains(pkg)) {
-                            packages.remove(pkg);
-                            extraPackages.remove(pkg);
-                            tableViewer.refresh();
-                            if (extraPackages.size() <= 0) {
-                                removeBt.setEnabled(false);
-                            }
-                        }
-                    }
-                }
-            }
-
-            @Override
-            public void mouseUp(MouseEvent e) {
-            }
-        });
-    }
-
-    private void createTableGroupComposite(Composite parent) {
-
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        GridLayout gridLayout = new GridLayout();
-        gridLayout.numColumns = 2;
-        gridLayout.marginWidth = 0;
-        gridLayout.marginHeight = 0;
-        composite.setLayout(gridLayout);
-
-        createTableComposite(composite);
-        createTableButtonsComposite(composite);
-    }
-
-    private boolean packagingProject(final IProject targetProj) {
-        boolean result = false;
-
-        try {
-            if (getContainer() == null) {
-                ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-                dialog.run(true, true, new IRunnableWithProgress() {
-                    @Override
-                    public void run(IProgressMonitor monitor) throws InvocationTargetException,
-                            InterruptedException {
-                        packagingResult = pkgUtil.pakaging(targetProj, config, monitor);
-                    }
-                });
-            } else {
-                getContainer().run(true, true, new IRunnableWithProgress() {
-                    public void run(IProgressMonitor monitor) throws InvocationTargetException,
-                            InterruptedException {
-                        packagingResult = pkgUtil.pakaging(targetProj, config, monitor);
-                    }
-                });
-            }
-        } catch (InvocationTargetException e) {
-            e.printStackTrace();
-            MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT, e.getMessage());
-            return false;
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-            MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT, e.getMessage());
-            return false;
-        }
-
-        if (packagingResult) {
-            Display.getDefault().asyncExec(new Runnable() {
-                public void run() {
-                    pkgUtil.cachePkgChecksum(targetProj, config);
-                }
-            });
-            MessageDialog.openInformation(shell, CommonBuildMessages.BUILD_RESULT,
-                    CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);
-            result = true;
-        } else {
-            MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT,
-                    CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
-            result = false;
-        }
-
-        return result;
-    }
-
-    public List<IPackage> getExtraPackages() {
-        return extraPackages;
-    }
-
-    public String getAppProjectName() {
-        return projectCombo.getText().trim();
-    }
-
-    public IProject getAppProject() {
-        return appProj;
-    }
-
-    public List<IPackage> getAppPackages() {
-        return appPackages;
-    }
-
-    public String getBinaryPath() {
-        return binaryPath;
-    }
-}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java
deleted file mode 100644 (file)
index a3f0d47..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.wizard.pages;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
-import org.tizen.nativeplatform.util.PlatformLaunchUtil;
-import org.tizen.sdblib.service.FileEntry;
-
-public class PlatformLaunchSettingBinPage extends PlatformLaunchCommonPage {
-
-    private final String BUNDLE_NAME = PlatformLaunchSettingBinPage.class.getPackage().getName()
-            + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
-    private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-    private PlatformLaunchWizard wizard;
-
-    private Text text;
-
-    public PlatformLaunchSettingBinPage(PlatformLaunchWizard wizard, String pageName) {
-        super(pageName);
-
-        this.wizard = wizard;
-        setTitle(resources.getString("BinPage.Title"));
-        setDescription(resources.getString("BinPage.Desc"));
-        setPageComplete(true);
-    }
-
-    @Override
-    public void createControl(Composite parent) {
-        // TODO Auto-generated method stub
-        Composite composite = new Composite(parent, SWT.NULL);
-        composite.setLayout(new GridLayout(2, false));
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-        text = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
-        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-        text.setLayoutData(data);
-
-        text.addModifyListener(new ModifyListener() {
-            @Override
-            public void modifyText(ModifyEvent e) {
-                String path = text.getText();
-                if (path != null && !path.isEmpty()) {
-                    wizard.setEnableFinish(true);
-                    wizard.getContainer().updateButtons();
-                } else {
-                    wizard.setEnableFinish(false);
-                    wizard.getContainer().updateButtons();
-                }
-            }
-        });
-
-        Button browseButton = new Button(composite, SWT.PUSH);
-        browseButton.setText(resources.getString("BinPage.Button.Browse"));
-        browseButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent evt) {
-                String path = handleBrowseButtonSelected();
-                if (path != null) {
-                    text.setText(path);
-                    wizard.setEnableFinish(true);
-                    wizard.getContainer().updateButtons();
-                } else {
-                    wizard.setEnableFinish(false);
-                    wizard.getContainer().updateButtons();
-                }
-            }
-        });
-
-        setControl(composite);
-    }
-
-    protected String handleBrowseButtonSelected() {
-        final Shell shell = getAvailableShell();
-        FileEntry path = PlatformLaunchUtil.selectRemoteFile(shell,
-                resources.getString("BinPage.Remote.Dialog.Title"));
-        if (path != null) {
-            return path.getFullPath();
-        }
-        return null;
-    }
-
-    public void setBinaryPath(String path) {
-        if (text != null && path != null && !path.isEmpty()) {
-            text.setText(path);
-        }
-    }
-
-    public String getPath() {
-        return text.getText().trim();
-    }
-
-}
index 8a0df21..5097ce8 100644 (file)
@@ -31,9 +31,9 @@ import org.slf4j.LoggerFactory;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.util.FileUtil;
 import org.tizen.nativeplatform.coredump.CSFileReader;
+import org.tizen.nativeplatform.coredump.CoredumpSelectionHandler;
 import org.tizen.nativeplatform.coredump.model.CSVO;
 import org.tizen.nativeplatform.coredump.model.CoredumpModel;
-import org.tizen.nativeplatform.coredump.CoredumpSelectionHandler;
 import org.tizen.nativeplatform.launch.wizards.PlatformCoredumpLaunchWizard;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
@@ -48,13 +48,13 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
     private PlatformCoredumpLaunchWizard wizard;
     private PkgCommandTarget target;
 
-    private Group swInfoGroup;
-    private Group pkgInfoGroup;
-    private Group crashInfoGroup;
+    private Group coredumpInfoGroup;
     private Text tFilePath;
+    private Text corefilePath;
+    private Text csfilePath;
+    private FileEntry remoteCorefile;
+    private FileEntry remoteCsfile;
     private FileEntry remoteDumpFile;
-    private String localDumpFile;
-    private CSVO csvo = null;
 
     private Label lPkgName;
     private Label lPkgVer;
@@ -63,9 +63,16 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
     private Label lExec;
     private Label lModel;
     private Label lBuildNum;
+    private Button archiveBrowseButton;
+    private Button archiveLocalButton;
+    private Button coreBrowseButton;
+    private Button csBrowseButton;
 
+    private CSVO csvo = null;
     private CoredumpModel coredumpModel;
+    private String localDumpFile;
     private String originCoredumpPath = "";
+    private String originCsfilePath = "";
     private String errorMessage = "";
     private String binaryPath = "";
     private String coredumpPath = "";
@@ -94,76 +101,261 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
         gridData.minimumHeight = 0;
         composite.setLayoutData(gridData);
 
-        createCorefileControl(composite);
-        createSwInfoControl(composite);
-        createPkgInfoControl(composite);
-        createCrashInfoControl(composite);
+        Button archiveFileButton = new Button(composite, SWT.RADIO);
+        archiveFileButton.setText("Use archive file (*.tar.gz)");
+        archiveFileButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                enableArchivefileGroup(true);
+                enableCorefileGroup(false);
+                resetVariable();
+                resetControl();
+            }
+        });
+        createArchiveFileControl(composite);
+        Button coreFileButton = new Button(composite, SWT.RADIO);
+        coreFileButton.setText("Use coredump and cs file (*.core/*.cs)");
+        coreFileButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                enableArchivefileGroup(false);
+                enableCorefileGroup(true);
+                resetVariable();
+                resetControl();
+            }
+        });
+        createCoreFileControl(composite);
+        createCoredumpInfoControl(composite);
+
+        archiveFileButton.setSelection(true);
+        enableArchivefileGroup(true);
+        enableCorefileGroup(false);
+
         setControl(composite);
     }
 
-    public void createSwInfoControl(Composite parent) {
-        swInfoGroup = new Group(parent, SWT.NONE);
-        swInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-        swInfoGroup.setLayout(new GridLayout(2, false));
-        swInfoGroup.setText(resources.getString("CorePage.Group.Swinfo"));
+    private void enableArchivefileGroup(boolean enable) {
+        if (!enable) {
+            tFilePath.setText("");
+        }
+        tFilePath.setEnabled(enable);
+        archiveBrowseButton.setEnabled(enable);
+        archiveLocalButton.setEnabled(enable);
+    }
+
+    private void enableCorefileGroup(boolean enable) {
+        if (!enable) {
+            corefilePath.setText("");
+            csfilePath.setText("");
+        }
+        corefilePath.setEnabled(enable);
+        csfilePath.setEnabled(enable);
+        coreBrowseButton.setEnabled(enable);
+        csBrowseButton.setEnabled(enable);
+    }
+
+    public void createArchiveFileControl(Composite parent) {
+        Group inputFileGroup = new Group(parent, SWT.NONE);
+        inputFileGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+        // inputFileGroup.setLayout(new GridLayout(1, false));
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 1;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        inputFileGroup.setLayout(layout);
+        inputFileGroup.setText("Setting .tar.gz file");
+        createInputArchiveFileControl(inputFileGroup);
+    }
+
+    public void createCoreFileControl(Composite parent) {
+        Group inputFileGroup = new Group(parent, SWT.NONE);
+        inputFileGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 1;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        inputFileGroup.setLayout(layout);
+        inputFileGroup.setText("Setting .core and .cs file");
+        createInputCoreFileControl(inputFileGroup);
+    }
+
+    public void createCoredumpInfoControl(Composite parent) {
+        coredumpInfoGroup = new Group(parent, SWT.NONE);
+        coredumpInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+        coredumpInfoGroup.setLayout(new GridLayout(2, false));
+        coredumpInfoGroup.setText("Coredump Information");
+        createSwInfoControl(coredumpInfoGroup);
+        createPkgInfoControl(coredumpInfoGroup);
+        createCrashInfoControl(coredumpInfoGroup);
+    }
 
-        Label Model = new Label(swInfoGroup, SWT.NONE);
+    public void createSwInfoControl(Composite parent) {
+        Label Model = new Label(parent, SWT.NONE);
         Model.setText(resources.getString("CorePage.Label.Model"));
-        lModel = new Label(swInfoGroup, SWT.NONE);
+        lModel = new Label(parent, SWT.NONE);
         lModel.setText("");
-        Label BuildNum = new Label(swInfoGroup, SWT.NONE);
+        Label BuildNum = new Label(parent, SWT.NONE);
         BuildNum.setText(resources.getString("CorePage.Label.BuildNum"));
-        lBuildNum = new Label(swInfoGroup, SWT.NONE);
+        lBuildNum = new Label(parent, SWT.NONE);
         lBuildNum.setText("");
     }
 
     public void createCrashInfoControl(Composite parent) {
-        crashInfoGroup = new Group(parent, SWT.NONE);
-        crashInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-        crashInfoGroup.setLayout(new GridLayout(2, false));
-        crashInfoGroup.setText(resources.getString("CorePage.Group.Crashinfo"));
-
-        Label ProcName = new Label(crashInfoGroup, SWT.NONE);
+        Label ProcName = new Label(parent, SWT.NONE);
         ProcName.setText(resources.getString("CorePage.Label.Procname"));
-        lProcName = new Label(crashInfoGroup, SWT.NONE);
+        lProcName = new Label(parent, SWT.NONE);
         lProcName.setText("");
-        Label Date = new Label(crashInfoGroup, SWT.NONE);
+        Label Date = new Label(parent, SWT.NONE);
         Date.setText(resources.getString("CorePage.Label.Date"));
-        lDate = new Label(crashInfoGroup, SWT.NONE);
+        lDate = new Label(parent, SWT.NONE);
         lDate.setText("");
-        Label PkgExec = new Label(crashInfoGroup, SWT.NONE);
+        Label PkgExec = new Label(parent, SWT.NONE);
         PkgExec.setText(resources.getString("CorePage.Label.Exec"));
-        lExec = new Label(crashInfoGroup, SWT.NONE);
+        lExec = new Label(parent, SWT.NONE);
         lExec.setText("");
     }
 
     public void createPkgInfoControl(Composite parent) {
-        pkgInfoGroup = new Group(parent, SWT.NONE);
-        pkgInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-        pkgInfoGroup.setLayout(new GridLayout(2, false));
-        pkgInfoGroup.setText(resources.getString("CorePage.Group.Pkginfo"));
-
-        Label PkgName = new Label(pkgInfoGroup, SWT.NONE);
+        Label PkgName = new Label(parent, SWT.NONE);
         PkgName.setText(resources.getString("CorePage.Label.Pkgname"));
-        lPkgName = new Label(pkgInfoGroup, SWT.NONE);
+        lPkgName = new Label(parent, SWT.NONE);
         lPkgName.setText("");
-        Label PkgVer = new Label(pkgInfoGroup, SWT.NONE);
+        Label PkgVer = new Label(parent, SWT.NONE);
         PkgVer.setText(resources.getString("CorePage.Label.Pkgver"));
-        lPkgVer = new Label(pkgInfoGroup, SWT.NONE);
+        lPkgVer = new Label(parent, SWT.NONE);
         lPkgVer.setText("");
     }
 
-    private void createCorefileControl(Composite parent) {
+    private void createInputCoreFileControl(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 3;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+        Label corefileLabel = new Label(composite, SWT.NONE);
+        corefileLabel.setText("File(.core):");
+        corefilePath = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        corefilePath.setLayoutData(data);
+
+        coreBrowseButton = new Button(composite, SWT.PUSH);
+        coreBrowseButton.setText(resources.getString("BinPage.Button.Browse"));
+        coreBrowseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                remoteCorefile = handleBrowseButtonSelected();
+                if (remoteCorefile != null && remoteCorefile.getDate() != null) {
+                    localDumpFile = null;
+
+                    originCoredumpPath = remoteCorefile.getFullPath();
+
+                    // check archive file type (.core)
+                    boolean isCorefile = false;
+                    String fileName = FileUtil.getFileNameFromPath(originCoredumpPath);
+                    String[] exts = fileName.split("\\.");
+
+                    int length = exts.length;
+                    if (exts[length - 1].equals("core")) {
+                        isCorefile = true;
+                    }
+                    if (!isCorefile) {
+                        setErrorMessage("The file should be *.core");
+                        corefilePath.setText("");
+                        setPageComplete(false);
+                        return;
+                    }
+                    processRemoteCorefile(originCoredumpPath);
+
+                    if (coredumpPath != null && !coredumpPath.isEmpty() && coredumpModel != null) {
+                        if (target.getCommander(CmdTargetTypes.HOST).is80386File(coredumpPath)) {
+                            coredumpModel.setX86coredump(true);
+                        } else if (target.getCommander(CmdTargetTypes.HOST).isArmFile(coredumpPath)) {
+                            coredumpModel.setArmcoredump(true);
+                        }
+                    }
+                }
+            }
+        });
+
+        Label csfileLabel = new Label(composite, SWT.NONE);
+        csfileLabel.setText("File(.cs):");
+        csfilePath = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+        data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        csfilePath.setLayoutData(data);
+
+        csBrowseButton = new Button(composite, SWT.PUSH);
+        csBrowseButton.setText(resources.getString("BinPage.Button.Browse"));
+        csBrowseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                remoteCsfile = handleBrowseButtonSelected();
+                if (remoteCsfile != null && remoteCsfile.getDate() != null) {
+                    localDumpFile = null;
+                    csvo = null;
+                    resetControl();
+
+                    originCsfilePath = remoteCsfile.getFullPath();
+
+                    // check archive file type (.cs)
+                    boolean isCsfile = false;
+                    String fileName = FileUtil.getFileNameFromPath(originCsfilePath);
+                    String[] exts = fileName.split("\\.");
+
+                    int length = exts.length;
+                    if (exts[length - 1].equals("cs")) {
+                        isCsfile = true;
+                    }
+                    if (!isCsfile) {
+                        setErrorMessage("The file should be *.cs");
+                        csfilePath.setText("");
+                        setPageComplete(false);
+                        return;
+                    }
+
+                    processRemoteCsfile(originCsfilePath);
+
+                    if (csvo != null) {
+                        coredumpModel = new CoredumpModel(originCoredumpPath, originCsfilePath,
+                                coredumpPath, csvo, CoredumpModel.LOCATION.REMOTE);
+                        if (coredumpPath != null && !coredumpPath.isEmpty()) {
+                            if (target.getCommander(CmdTargetTypes.HOST).is80386File(coredumpPath)) {
+                                coredumpModel.setX86coredump(true);
+                            } else if (target.getCommander(CmdTargetTypes.HOST).isArmFile(
+                                    coredumpPath)) {
+                                coredumpModel.setArmcoredump(true);
+                            }
+                        }
+                        updateControl();
+                    } else {
+                        setErrorMessage(errorMessage);
+                        csfilePath.setText("");
+                        setPageComplete(false);
+                    }
+                }
+            }
+        });
+        setControl(composite);
+    }
+
+    private void createInputArchiveFileControl(Composite parent) {
         Composite composite = new Composite(parent, SWT.NULL);
-        composite.setLayout(new GridLayout(3, false));
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 3;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        composite.setLayout(layout);
         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
         tFilePath = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
         GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
         tFilePath.setLayoutData(data);
 
-        Button browseButton = new Button(composite, SWT.PUSH);
-        browseButton.setText(resources.getString("BinPage.Button.Browse"));
-        browseButton.addSelectionListener(new SelectionAdapter() {
+        archiveBrowseButton = new Button(composite, SWT.PUSH);
+        archiveBrowseButton.setText(resources.getString("BinPage.Button.Browse"));
+        archiveBrowseButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
                 remoteDumpFile = handleBrowseButtonSelected();
@@ -192,11 +384,11 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
                     }
 
                     // extract archive file and pull *.coredump and *.cs files
-                    processRemoteDumpfile(originCoredumpPath);
+                    processRemoteArchivefile(originCoredumpPath);
 
                     if (csvo != null) {
-                        coredumpModel = new CoredumpModel(originCoredumpPath, coredumpPath, csvo,
-                                CoredumpModel.LOCATION.REMOTE);
+                        coredumpModel = new CoredumpModel(originCoredumpPath, null, coredumpPath,
+                                csvo, CoredumpModel.LOCATION.REMOTE);
                         if (target.getCommander(CmdTargetTypes.HOST).is80386File(coredumpPath)) {
                             coredumpModel.setX86coredump(true);
                         } else if (target.getCommander(CmdTargetTypes.HOST).isArmFile(coredumpPath)) {
@@ -212,9 +404,9 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
             }
         });
 
-        Button localButton = new Button(composite, SWT.PUSH);
-        localButton.setText(resources.getString("CorePage.Button.Localbrowse"));
-        localButton.addSelectionListener(new SelectionAdapter() {
+        archiveLocalButton = new Button(composite, SWT.PUSH);
+        archiveLocalButton.setText(resources.getString("CorePage.Button.Localbrowse"));
+        archiveLocalButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent evt) {
                 FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.SINGLE);
@@ -249,8 +441,8 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
                     processLocalDumpfile(localDumpFile);
 
                     if (csvo != null) {
-                        coredumpModel = new CoredumpModel(originCoredumpPath, coredumpPath, csvo,
-                                CoredumpModel.LOCATION.LOCAL);
+                        coredumpModel = new CoredumpModel(originCoredumpPath, null, coredumpPath,
+                                csvo, CoredumpModel.LOCATION.LOCAL);
                         if (target.getCommander(CmdTargetTypes.HOST).is80386File(coredumpPath)) {
                             coredumpModel.setX86coredump(true);
                         } else if (target.getCommander(CmdTargetTypes.HOST).isArmFile(coredumpPath)) {
@@ -268,7 +460,91 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
         setControl(composite);
     }
 
-    private void processRemoteDumpfile(final String filePath) {
+    private void processRemoteCsfile(final String filePath) {
+        csfilePath.setText(filePath);
+        final IWizardContainer container = getContainer();
+        try {
+            container.run(true, false, new IRunnableWithProgress() {
+                public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                        InterruptedException {
+                    monitor.beginTask("", 2);
+                    monitor.subTask("Downloading cs file...");
+                    try {
+                        CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
+                        String csfile = handler.processRemoteCsfile(remoteCsfile,
+                                new SubProgressMonitor(monitor, 1));
+                        if (csfile == null) {
+                            errorMessage = resources
+                                    .getString("CorePage.ErrorMsg.FailedDownloadCoredump");
+                            wizard.openErrorDialog(errorMessage);
+                            return;
+                        }
+                        monitor.subTask("Parsing cs file...");
+                        CSFileReader csReader = new CSFileReader(csfile);
+                        csvo = csReader.parse();
+                        monitor.worked(1);
+                        monitor.subTask("Reading .cs file...");
+                        csFileContent = readCsFile(csfile);
+                        monitor.worked(1);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        errorMessage = resources.getString("CorePage.ErrorMsg.FailedSetCoredump");
+                        wizard.openErrorDialog(e.toString());
+                        logger.error(errorMessage, e);
+                    } finally {
+                        monitor.done();
+                    }
+                }
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            errorMessage = resources.getString("CorePage.ErrorMsg.FailedSetCoredump");
+            wizard.openErrorDialog(e.toString());
+            logger.error(errorMessage, e);
+        }
+    }
+
+    private void processRemoteCorefile(final String filePath) {
+        corefilePath.setText(filePath);
+        final IWizardContainer container = getContainer();
+        try {
+            container.run(true, false, new IRunnableWithProgress() {
+                public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                        InterruptedException {
+                    monitor.beginTask("", 2);
+                    monitor.subTask("Downloading coredump file...");
+                    try {
+                        CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
+                        String corefile = handler.processRemoteCorefile(remoteCorefile,
+                                new SubProgressMonitor(monitor, 1));
+                        if (corefile == null) {
+                            errorMessage = resources
+                                    .getString("CorePage.ErrorMsg.FailedDownloadCoredump");
+                            wizard.openErrorDialog(errorMessage);
+                            return;
+                        }
+                        monitor.subTask("Parsing coredump file...");
+                        coredumpPath = corefile;
+                        monitor.worked(1);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        errorMessage = resources.getString("CorePage.ErrorMsg.FailedSetCoredump");
+                        wizard.openErrorDialog(e.toString());
+                        logger.error(errorMessage, e);
+                    } finally {
+                        monitor.done();
+                    }
+                }
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            errorMessage = resources.getString("CorePage.ErrorMsg.FailedSetCoredump");
+            wizard.openErrorDialog(e.toString());
+            logger.error(errorMessage, e);
+        }
+    }
+
+    private void processRemoteArchivefile(final String filePath) {
         tFilePath.setText(filePath);
         final IWizardContainer container = getContainer();
         try {
@@ -279,7 +555,7 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
                     monitor.subTask("Downloading coredump archive...");
                     try {
                         CoredumpSelectionHandler handler = new CoredumpSelectionHandler(target);
-                        String[] coreFiles = handler.processRemoteCorefile(remoteDumpFile,
+                        String[] coreFiles = handler.processRemoteArchiveFile(remoteDumpFile,
                                 new SubProgressMonitor(monitor, 1));
                         if (coreFiles == null) {
                             errorMessage = resources
@@ -368,13 +644,22 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
         lProcName.setText("");
         lDate.setText("");
         lExec.setText("");
-        swInfoGroup.layout();
-        pkgInfoGroup.layout();
-        crashInfoGroup.layout();
+        coredumpInfoGroup.layout();
         setErrorMessage(null);
         setPageComplete(false);
     }
 
+    private void resetVariable() {
+        csvo = null;
+        coredumpModel = null;
+        localDumpFile = "";
+        originCoredumpPath = "";
+        errorMessage = "";
+        binaryPath = "";
+        coredumpPath = "";
+        csFileContent = "";
+    }
+
     private void updateControl() {
         lModel.setText(": " + csvo.getHeader().getModel());
         lBuildNum.setText(": " + csvo.getHeader().getBuildNumber());
@@ -389,9 +674,7 @@ public class PlatformLaunchSettingCorePage extends PlatformLaunchCommonPage {
         lDate.setText(": " + csvo.getHeader().getCrashDate());
         binaryPath = csvo.getHeader().getCrashExePath();
         lExec.setText(": " + binaryPath);
-        swInfoGroup.layout();
-        pkgInfoGroup.layout();
-        crashInfoGroup.layout();
+        coredumpInfoGroup.layout();
         setErrorMessage(null);
         String arch = "";
         if (coredumpModel.isX86coredump()) {
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingPage.java
new file mode 100644 (file)
index 0000000..879b385
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizard.pages;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmDebugPackagesResolver;
+import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
+import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
+import org.tizen.sdblib.service.FileEntry;
+
+public class PlatformLaunchSettingPage extends PlatformLaunchCommonPage {
+
+    private final String BUNDLE_NAME = PlatformLaunchSettingPage.class.getPackage().getName()
+            + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
+    private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+    
+    protected PlatformLaunchWizard wizard;
+    protected String mode;
+    protected PkgCommandTarget cmdTarget;
+    protected String commandInitText = "";
+    protected String argumentsInitText = "";
+    protected boolean findDebugPkg;
+    protected boolean isDebug;
+    protected String COMMAND_LABEL_TEXT = "Command:";
+        
+    protected Text commandText;
+    protected Text argumentsText;
+    protected Color originColor;
+    protected final String DEBUGGER_COMMAND = "/usr/bin/gdb";
+    protected final String LAUNCH_APP_COMMAND = "/usr/bin/launch_app";    
+    protected final String GUIDE_STRING = "Ex) /opt/apps/org.tizen.eflapp/bin/eflapp";
+
+    public PlatformLaunchSettingPage(PlatformLaunchWizard wizard, Shell shell, String pageName, IProject project,
+            IConfiguration config, PkgCommandTarget cmdTarget, String descMsg, String mode) {
+        super(pageName, shell, project, config, cmdTarget);
+
+        setTitle(resources.getString("EFLBinPage.Title"));
+        if (descMsg.isEmpty()) {
+            setDescription(resources.getString("EFLBinPage.Desc"));
+        } else {
+            setErrorMessage(descMsg);
+        }                
+        setPageComplete(true);
+        setPlatformPackages();        
+        this.wizard = wizard;
+        this.mode = mode;
+        this.cmdTarget = cmdTarget;
+        commandInitText = GUIDE_STRING;
+        originColor = wizard.getShell().getForeground();
+        isDebug = mode.equals(ILaunchManager.DEBUG_MODE);
+        if (isDebug) {
+            COMMAND_LABEL_TEXT = "Executable file:";
+        }
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 1;
+        gridLayout.marginWidth = 0;
+        gridLayout.marginHeight = 0;
+        composite.setLayout(gridLayout);
+        createInfoComposite(composite);
+        createRunCommandComposite(composite, true);       
+        setControl(composite);
+        validate();
+    }
+    
+    protected void createInfoComposite(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        composite.setLayout(new GridLayout(3, false));
+        composite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+        Button logBt = new Button(composite, SWT.PUSH);
+        logBt.setText("View internal log");
+        logBt.setLayoutData(gridData);
+        logBt.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                wizard.openLogTabDialog();                
+            }
+        });
+        Button setEnvBt = new Button(composite, SWT.PUSH);
+        setEnvBt.setText("Set environments");
+        setEnvBt.setLayoutData(gridData);
+        setEnvBt.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                wizard.openSetEnvDialog();            
+            }
+        });
+        Button pkgMgrBt = new Button(composite, SWT.PUSH);
+        pkgMgrBt.setText("Install other packages");
+        pkgMgrBt.setLayoutData(gridData);
+        pkgMgrBt.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                handleClickPackageManager();                
+            }
+        });
+    }
+    
+    protected void createRunCommandComposite(Composite parent, boolean useGuideString) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        composite.setLayout(new GridLayout(3, false));
+        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        
+        GridData spanData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        spanData.horizontalSpan = 2;
+        Label binaryLabel = new Label(composite, SWT.NONE);
+        binaryLabel.setText(COMMAND_LABEL_TEXT);        
+        commandText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        commandText.setLayoutData(data);
+        if (useGuideString) {
+            commandText.setForeground(wizard.getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));            
+            commandText.addFocusListener(new FocusListener() {
+                @Override
+                public void focusGained(FocusEvent e) {
+                    // remove guide text
+                    commandText.setForeground(originColor);
+                    String value = commandText.getText();
+                    if (value.equals(GUIDE_STRING)) {
+                        commandText.setText("");
+                    }
+                }
+    
+                @Override
+                public void focusLost(FocusEvent e) {
+                }
+            });
+        }
+        commandText.setText(commandInitText);
+        commandText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {                
+                validate();
+            }
+        });
+        
+        Button browseButton = new Button(composite, SWT.PUSH);
+        browseButton.setText(resources.getString("BinPage.Button.Browse"));
+        browseButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                String path = handleBrowseButtonSelected();
+                if (path != null && !path.isEmpty()) {
+                    commandText.setForeground(originColor);
+                    commandText.setText(path);
+                }
+            }
+        });
+        
+        Label argumentsLabel = new Label(composite, SWT.NONE);
+        argumentsLabel.setText("Arguments:");
+        argumentsText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+        argumentsText.setLayoutData(spanData);
+        argumentsText.setText(argumentsInitText);
+    }
+    
+    protected void validate() {
+        final String command = commandText.getText().trim();
+        String projName = platformProject.getName();
+        if (command.isEmpty() || command.equals(GUIDE_STRING)) {
+            if (isDebug) {
+                String msg = String.format("Input executable file to debug \"%s\" project", projName);
+                pageNotCompleted(msg);
+            } else {
+                String msg = String.format("Input command to test \"%s\" project", projName);
+                pageNotCompleted(msg);    
+            }            
+            return;
+        }
+        if (command.contains(" ")) {
+            pageNotCompleted("Command contains an argument.");
+            return;
+        }        
+        
+        if (!cmdTarget.getDeviceCommander().existsFile(command)) {
+            String msg = String.format("\"%s\" does not exist on the device.", command);
+            pageNotCompleted(msg);
+            return;
+        }
+        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+            final IPkgCommander rootstrapCommander = cmdTarget.getRootstrapCommander();
+            findDebugPkg = true;
+            IWizardContainer container = getContainer();
+            try {
+                container.run(true, true, new IRunnableWithProgress() {
+                    public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                            InterruptedException {
+                        RpmDebugPackagesResolver resolver = new RpmDebugPackagesResolver(cmdTarget, monitor);
+                        findDebugPkg = resolver.resolve(command);
+                    }
+                });
+            } catch (Exception e1) {
+                wizard.openErrorDialog(e1.toString());
+                e1.printStackTrace();
+            }
+            if (!rootstrapCommander.existsFile(command)) {
+                String msg = String.format("\"%s\" does not exist on the rootstrap. The binary should be in the rootstrap", command);
+                pageNotCompleted(msg);
+                return;
+            }
+            if (!findDebugPkg) {
+                String msg = "Failed to find debug packages or install packages";
+                pageCompleted(msg, true);
+                return;
+            }
+            if (command.startsWith("/opt/usr/apps/")) {
+                String recommend = command.replaceAll("/opt/usr/apps/", "/opt/apps/");
+                String msg = String.format("Debugging can be failed if you use the command. Recommand using \"%s\" command",
+                        command, recommend);
+                pageCompleted(msg, true);
+                return;
+            }
+        }
+        
+        pageCompleted();
+    }
+    
+    protected void pageNotCompleted(String errorMsg) {
+        setErrorMessage(errorMsg);
+        setPageComplete(false);
+        wizard.setEnableFinish(false);
+        getContainer().updateButtons();
+    }
+    
+    protected void pageCompleted(String msg, boolean isError) {
+        setErrorMessage(null); 
+        if (isError) {
+            setErrorMessage(msg);
+        } else {
+            setMessage(msg, NONE);
+        }
+        setPageComplete(true);
+        wizard.setEnableFinish(true);
+        getContainer().updateButtons();
+    }
+    
+    protected void pageCompleted() {
+        pageCompleted("Click Finish button", false);
+    }
+    
+    public String getBinaryPath() {
+        return commandText.getText().trim();        
+    }
+    
+    public String getArguments() {
+        return argumentsText.getText().trim();                        
+    }
+    
+    public String getSelectedApp() {
+        return null;
+    }
+    
+
+    protected String handleBrowseButtonSelected() {
+        final Shell shell = getAvailableShell();
+        FileEntry path = PlatformLaunchUtil.selectRemoteFile(shell,
+                resources.getString("BinPage.Remote.Dialog.Title"), "/opt/apps");
+        if (path != null) {
+            return path.getFullPath();
+        }
+        return null;
+    }
+    
+    protected void handleClickPackageManager() {
+        IWizardContainer container = getContainer();
+        final PkgMgrInitializer initializer = new PkgMgrInitializer(cmdTarget);
+        try {
+            container.run(true, true, new IRunnableWithProgress() {
+                public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                        InterruptedException {
+                    monitor.beginTask("", 1);
+                    monitor.subTask("Initializing Package Manager...");
+                    try {
+                        initializer.fastInitData(new SubProgressMonitor(monitor, 1));
+                    } finally {
+                        monitor.done();
+                    }
+                }
+            });
+            RPMPackageDialog dlg = new RPMPackageDialog(shell, cmdTarget);
+            dlg.open();
+            validate();            
+        } catch (Exception e1) {
+            wizard.openErrorDialog(e1.toString());
+            e1.printStackTrace();
+        }       
+    }
+
+}
index 9a1dfe6..5227757 100644 (file)
@@ -44,6 +44,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.tizen.nativeplatform.launch.wizards.PlatformCommonLaunchWizard;
 import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.util.ProcessSelector;
@@ -60,10 +61,10 @@ public class PlatformLaunchSettingProcPage extends PlatformLaunchCommonPage {
     private int pid;
     private IProcessInfo procInfo;
     private String procName = "";
-    private PlatformLaunchWizard wizard;
+    private PlatformCommonLaunchWizard wizard;
     private IDevice device;
 
-    public PlatformLaunchSettingProcPage(PlatformLaunchWizard wizard, Shell shell, String pageName,
+    public PlatformLaunchSettingProcPage(PlatformCommonLaunchWizard wizard, Shell shell, String pageName,
             IProject project, IConfiguration config, PkgCommandTarget target) {
         super(pageName, shell, project, config, target);
 
@@ -104,9 +105,6 @@ public class PlatformLaunchSettingProcPage extends PlatformLaunchCommonPage {
         reinstallOp = new Button(composite, SWT.CHECK);
         reinstallOp.setText(resources.getString("Button.Reinstall.Op"));
         reinstallOp.setSelection(true);
-        selectPkgOp = new Button(composite, SWT.CHECK);
-        selectPkgOp.setText(resources.getString("Button.SelectPkg.Op"));
-        selectPkgOp.setSelection(false);
     }
 
     private void createProcessComposite(Composite parent) {
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/EnvironmentDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/EnvironmentDialog.java
new file mode 100644 (file)
index 0000000..96526b7
--- /dev/null
@@ -0,0 +1,639 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.AbstractDebugCheckboxSelectionDialog;
+import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.MultipleInputDialog;
+import org.eclipse.debug.internal.ui.launchConfigurations.EnvironmentVariable;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+@SuppressWarnings("restriction")
+public class EnvironmentDialog extends Dialog {
+
+    private int x = 0;
+    private int y = 0;
+    private final int width = 600;
+    private final int height = 400;
+
+    protected ILaunchConfiguration launchConfig;
+    protected Map envMap;
+    protected Map defaultEnvMap;
+    protected Button envAddButton;
+    protected Button envEditButton;
+    protected Button envRemoveButton;
+    protected Button appendEnvironment;
+    protected Button replaceEnvironment;
+    protected Button envSelectButton;
+    protected TableViewer environmentTable;
+    protected String[] envTableColumnHeaders = {
+            LaunchConfigurationsMessages.EnvironmentTab_Variable_1, 
+            LaunchConfigurationsMessages.EnvironmentTab_Value_2, 
+        };
+    protected static final String NAME_LABEL= LaunchConfigurationsMessages.EnvironmentTab_8; 
+    protected static final String VALUE_LABEL= LaunchConfigurationsMessages.EnvironmentTab_9;        
+       
+    protected static final String TITLE = "Environment variable Configuration";
+    protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
+    protected static final String P_VALUE = "value"; //$NON-NLS-1$
+
+    protected EnvironmentDialog(Shell parentShell, Map defaultEnvMap) {
+        super(parentShell);
+        Rectangle bounds = parentShell.getBounds();
+        x = bounds.x + (bounds.width - width) / 2;
+        y = bounds.y + (bounds.height - height) / 2;
+        this.defaultEnvMap = defaultEnvMap;
+    }
+
+    @Override
+    protected void configureShell(Shell newShell) {
+        super.configureShell(newShell);
+
+        newShell.setText(TITLE);
+        newShell.setLocation(x, y);
+        newShell.setSize(width, height);
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        composite.setLayout(new GridLayout(2, false));
+
+        createDescComposite(composite);
+        //createTextAreaComposite(composite);
+        createEnvironmentTable(composite);
+        createTableButtons(composite);
+        
+        updateEnvironment();
+        return composite;
+    }
+    
+    /**
+     * Updates the environment table for the given launch configuration
+     * @param configuration
+     */
+    protected void updateEnvironment() {
+        environmentTable.setInput(defaultEnvMap);
+    }
+    
+    protected void createEnvironmentTable(Composite parent) {        
+        // Create table composite        
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout(1, false);
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout(layout);
+        GridData gd = new GridData(GridData.FILL_BOTH);
+        composite.setLayoutData(gd);
+        // Create table
+        environmentTable = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
+        Table table = environmentTable.getTable();
+        table.setLayout(new GridLayout());
+        table.setLayoutData(new GridData(GridData.FILL_BOTH));
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+        environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
+        environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
+        environmentTable.setColumnProperties(new String[] {P_VARIABLE, P_VALUE});
+        environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+                handleTableSelectionChanged(event);
+            }
+        });
+        environmentTable.addDoubleClickListener(new IDoubleClickListener() {
+            public void doubleClick(DoubleClickEvent event) {
+                if (!environmentTable.getSelection().isEmpty()) {
+                    handleEnvEditButtonSelected();
+                }
+            }
+        });
+        // Create columns
+        final TableColumn tc1 = new TableColumn(table, SWT.NONE, 0);
+        tc1.setText(envTableColumnHeaders[0]);
+        final TableColumn tc2 = new TableColumn(table, SWT.NONE, 1);
+        tc2.setText(envTableColumnHeaders[1]);
+        final Table tref = table;
+        final Composite comp = composite;
+        composite.addControlListener(new ControlAdapter() {
+            public void controlResized(ControlEvent e) {
+                Rectangle area = comp.getClientArea();
+                Point size = tref.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+                ScrollBar vBar = tref.getVerticalBar();
+                int width = area.width - tref.computeTrim(0,0,0,0).width - 2;
+                if (size.y > area.height + tref.getHeaderHeight()) {
+                    Point vBarSize = vBar.getSize();
+                    width -= vBarSize.x;
+                }
+                Point oldSize = tref.getSize();
+                if (oldSize.x > area.width) {
+                    tc1.setWidth(width/2-1);
+                    tc2.setWidth(width - tc1.getWidth());
+                    tref.setSize(area.width, area.height);
+                } else {
+                    tref.setSize(area.width, area.height);
+                    tc1.setWidth(width/2-1);
+                    tc2.setWidth(width - tc1.getWidth());
+                }
+            }
+        });
+    }
+    
+    /**
+     * Creates the add/edit/remove buttons for the environment table
+     * @param parent the composite in which the buttons should be created
+     */
+    protected void createTableButtons(Composite parent) {
+        // Create button composite
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout(1, false);
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout(layout);
+        GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+        composite.setLayoutData(gd);
+        
+        GridData btgd = new GridData(GridData.FILL_HORIZONTAL);
+
+        // Create buttons
+        envAddButton = new Button(composite, SWT.PUSH);
+        envAddButton.setLayoutData(btgd);
+        envAddButton.setText(LaunchConfigurationsMessages.EnvironmentTab_New_4); 
+        envAddButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                handleEnvAddButtonSelected();
+            }
+        });
+        envSelectButton = new Button(composite, SWT.PUSH);
+        envSelectButton.setLayoutData(btgd);
+        envSelectButton.setText(LaunchConfigurationsMessages.EnvironmentTab_18); 
+        envSelectButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                handleEnvSelectButtonSelected();
+            }
+        });
+        envEditButton = new Button(composite, SWT.PUSH);
+        envEditButton.setLayoutData(btgd);
+        envEditButton.setText(LaunchConfigurationsMessages.EnvironmentTab_Edit_5); 
+        envEditButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                handleEnvEditButtonSelected();
+            }
+        });
+        envEditButton.setEnabled(false);        
+        envRemoveButton = new Button(composite, SWT.PUSH);
+        envRemoveButton.setLayoutData(btgd);
+        envRemoveButton.setText(LaunchConfigurationsMessages.EnvironmentTab_Remove_6); 
+        envRemoveButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                handleEnvRemoveButtonSelected();
+            }
+        });
+        envRemoveButton.setEnabled(false);
+    }
+    
+    /**
+     * Responds to a selection changed event in the environment table
+     * @param event the selection change event
+     */
+    protected void handleTableSelectionChanged(SelectionChangedEvent event) {
+        int size = ((IStructuredSelection)event.getSelection()).size();
+        envEditButton.setEnabled(size == 1);
+        envRemoveButton.setEnabled(size > 0);
+    }
+    
+    /**
+     * Adds a new environment variable to the table.
+     */    
+    protected void handleEnvAddButtonSelected() {
+        MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_22); 
+        dialog.addTextField(NAME_LABEL, null, false);
+        dialog.addVariablesField(VALUE_LABEL, null, true);
+        
+        if (dialog.open() != Window.OK) {
+            return;
+        }
+        
+        String name = dialog.getStringValue(NAME_LABEL);
+        String value = dialog.getStringValue(VALUE_LABEL);
+        
+        if (name != null && value != null && name.length() > 0 && value.length() >0) {
+            addVariable(new EnvironmentVariable(name.trim(), value.trim()));
+            updateAppendReplace();
+        }
+    }
+    
+    /**
+     * Displays a dialog that allows user to select native environment variables 
+     * to add to the table.
+     */
+    private void handleEnvSelectButtonSelected() {
+        //get Environment Variables from the OS
+        Map envVariables = getNativeEnvironment();
+        
+        //get Environment Variables from the table
+        TableItem[] items = environmentTable.getTable().getItems();
+        for (int i = 0; i < items.length; i++) {
+            EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
+            envVariables.remove(var.getName());
+        }
+        
+        NativeEnvironmentSelectionDialog dialog = new NativeEnvironmentSelectionDialog(getShell(), envVariables); 
+        dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); 
+        
+        int button = dialog.open();
+        if (button == Window.OK) {
+            Object[] selected = dialog.getResult();     
+            for (int i = 0; i < selected.length; i++) {
+                environmentTable.add(selected[i]);              
+            }
+        }
+        
+        updateAppendReplace();     
+    }
+    
+    /**
+     * Removes the selected environment variable from the table.
+     */    
+    private void handleEnvRemoveButtonSelected() {
+        IStructuredSelection sel = (IStructuredSelection) environmentTable.getSelection();
+        environmentTable.getControl().setRedraw(false);
+        for (Iterator i = sel.iterator(); i.hasNext(); ) {
+            EnvironmentVariable var = (EnvironmentVariable) i.next();   
+        environmentTable.remove(var);
+        }
+        environmentTable.getControl().setRedraw(true);
+        updateAppendReplace();
+    }
+    
+    /**
+     * Updates the enablement of the append/replace widgets. The
+     * widgets should disable when there are no environment variables specified.
+     */
+    protected void updateAppendReplace() {
+        //boolean enable= environmentTable.getTable().getItemCount() > 0;
+        //appendEnvironment.setEnabled(enable);
+        //replaceEnvironment.setEnabled(enable);
+    }    
+    
+    /**
+     * Creates an editor for the value of the selected environment variable.
+     */
+    private void handleEnvEditButtonSelected() {
+        IStructuredSelection sel= (IStructuredSelection) environmentTable.getSelection();
+        EnvironmentVariable var= (EnvironmentVariable) sel.getFirstElement();
+        if (var == null) {
+            return;
+        }
+        String originalName= var.getName();
+        String value= var.getValue();
+        MultipleInputDialog dialog= new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11); 
+        dialog.addTextField(NAME_LABEL, originalName, false);
+        dialog.addVariablesField(VALUE_LABEL, value, true);
+        
+        if (dialog.open() != Window.OK) {
+            return;
+        }
+        String name= dialog.getStringValue(NAME_LABEL);
+        value= dialog.getStringValue(VALUE_LABEL);
+        if (!originalName.equals(name)) {
+            if (addVariable(new EnvironmentVariable(name, value))) {
+                environmentTable.remove(var);
+            }
+        } else {
+            var.setValue(value);
+            environmentTable.update(var, null);
+        }
+    }
+    
+    /**
+     * Attempts to add the given variable. Returns whether the variable
+     * was added or not (as when the user answers not to overwrite an
+     * existing variable).
+     * @param variable the variable to add
+     * @return whether the variable was added
+     */
+    protected boolean addVariable(EnvironmentVariable variable) {
+        String name= variable.getName();
+        TableItem[] items = environmentTable.getTable().getItems();
+        for (int i = 0; i < items.length; i++) {
+            EnvironmentVariable existingVariable = (EnvironmentVariable) items[i].getData();
+            if (existingVariable.getName().equals(name)) {
+                boolean overWrite= MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_12, MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, new String[] {name})); // 
+                if (!overWrite) {
+                    return false;
+                }
+                environmentTable.remove(existingVariable);
+                break;
+            }
+        }
+        environmentTable.add(variable);
+        return true;
+    }
+
+    private void createDescComposite(Composite parent) {
+        Label l = new Label(parent, SWT.NONE);
+        l.setFont(parent.getFont());
+        l.setText(LaunchConfigurationsMessages.EnvironmentTab_Environment_variables_to_set__3);
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 2;
+        gd.grabExcessHorizontalSpace = false;
+        l.setLayoutData(gd);
+    }
+
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
+    }
+
+    @Override
+    protected void okPressed() {
+     // Convert the table's items into a Map so that this can be saved in the
+        // configuration's attributes.
+        TableItem[] items = environmentTable.getTable().getItems();
+        envMap = new HashMap(items.length);
+        for (int i = 0; i < items.length; i++)
+        {
+            EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
+            envMap.put(var.getName(), var.getValue());
+        }
+        super.okPressed();
+    }
+    
+    public Map getEnvs() {
+        return envMap;
+    }
+    
+    /**
+     * Content provider for the environment table
+     */
+    protected class EnvironmentVariableContentProvider implements IStructuredContentProvider {
+        public Object[] getElements(Object inputElement) {
+            EnvironmentVariable[] elements = new EnvironmentVariable[0];
+            //ILaunchConfiguration config = (ILaunchConfiguration) inputElement;
+            Map m = (Map)inputElement;
+            /*
+            try {
+                m = config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
+            } catch (CoreException e) {
+                DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Error reading configuration", e)); //$NON-NLS-1$
+                return elements;
+            }
+            */
+            if (m != null && !m.isEmpty()) {
+                elements = new EnvironmentVariable[m.size()];
+                String[] varNames = new String[m.size()];
+                m.keySet().toArray(varNames);
+                for (int i = 0; i < m.size(); i++) {
+                    elements[i] = new EnvironmentVariable(varNames[i], (String) m.get(varNames[i]));
+                }
+            }
+            return elements;
+        }
+        public void dispose() {
+        }
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+            if (newInput == null){
+                return;
+            }
+            if (viewer instanceof TableViewer){
+                TableViewer tableViewer= (TableViewer) viewer;
+                if (tableViewer.getTable().isDisposed()) {
+                    return;
+                }
+                tableViewer.setComparator(new ViewerComparator() {
+                    public int compare(Viewer iviewer, Object e1, Object e2) {
+                        if (e1 == null) {
+                            return -1;
+                        } else if (e2 == null) {
+                            return 1;
+                        } else {
+                            return ((EnvironmentVariable)e1).getName().compareToIgnoreCase(((EnvironmentVariable)e2).getName());
+                        }
+                    }
+                });
+            }
+        }
+    }
+    
+    /**
+     * Label provider for the environment table
+     */
+    public class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
+        public String getColumnText(Object element, int columnIndex)    {
+            String result = null;
+            if (element != null) {
+                EnvironmentVariable var = (EnvironmentVariable) element;
+                switch (columnIndex) {
+                    case 0: // variable
+                        result = var.getName();
+                        break;
+                    case 1: // value
+                        result = var.getValue();
+                        break;
+                }
+            }
+            return result;
+        }
+        public Image getColumnImage(Object element, int columnIndex) {
+            if (columnIndex == 0) {
+                return DebugPluginImages.getImage(IDebugUIConstants.IMG_OBJS_ENV_VAR);
+            }
+            return null;
+        }
+    }
+
+    /**
+     * Gets native environment variable from the LaunchManager. Creates EnvironmentVariable objects.
+     * @return Map of name - EnvironmentVariable pairs based on native environment.
+     */
+    private Map getNativeEnvironment() {
+        Map stringVars = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironmentCasePreserved();
+        HashMap vars = new HashMap();
+        for (Iterator i = stringVars.keySet().iterator(); i.hasNext(); ) {
+            String key = (String) i.next();
+            String value = (String) stringVars.get(key);
+            vars.put(key, new EnvironmentVariable(key, value));
+        }
+        return vars;
+    }
+    
+    /**
+     * This dialog allows users to select one or more known native environment variables from a list.
+     */
+    private class NativeEnvironmentSelectionDialog extends AbstractDebugCheckboxSelectionDialog {
+        
+        private Object fInput;
+        
+        public NativeEnvironmentSelectionDialog(Shell parentShell, Object input) {
+            super(parentShell);
+            fInput = input;
+            setShellStyle(getShellStyle() | SWT.RESIZE);
+            setShowSelectAllButtons(true);
+        }
+        
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId()
+         */
+        protected String getDialogSettingsId() {
+            return IDebugUIConstants.PLUGIN_ID + ".ENVIRONMENT_TAB.NATIVE_ENVIROMENT_DIALOG"; //$NON-NLS-1$
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId()
+         */
+        protected String getHelpContextId() {
+            return IDebugHelpContextIds.SELECT_NATIVE_ENVIRONMENT_DIALOG;
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput()
+         */
+        protected Object getViewerInput() {
+            return fInput;
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerLabel()
+         */
+        protected String getViewerLabel() {
+            return LaunchConfigurationsMessages.EnvironmentTab_19;
+        }
+        
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getLabelProvider()
+         */
+        protected IBaseLabelProvider getLabelProvider() {
+            return new ILabelProvider() {
+                public Image getImage(Object element) {
+                    return DebugPluginImages.getImage(IDebugUIConstants.IMG_OBJS_ENVIRONMENT);
+                }
+                public String getText(Object element) {
+                    EnvironmentVariable var = (EnvironmentVariable) element;
+                    return MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_7, new String[] {var.getName(), var.getValue()}); 
+                }
+                public void addListener(ILabelProviderListener listener) {
+                }
+                public void dispose() {
+                }
+                public boolean isLabelProperty(Object element, String property) {
+                    return false;
+                }
+                public void removeListener(ILabelProviderListener listener) {
+                }               
+            };
+        }
+        
+        /* (non-Javadoc)
+         * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getContentProvider()
+         */
+        protected IContentProvider getContentProvider() {
+            return new IStructuredContentProvider() {
+                public Object[] getElements(Object inputElement) {
+                    EnvironmentVariable[] elements = null;
+                    if (inputElement instanceof HashMap) {
+                        Comparator comparator = new Comparator() {
+                            public int compare(Object o1, Object o2) {
+                                String s1 = (String)o1;
+                                String s2 = (String)o2;
+                                return s1.compareTo(s2);
+                            }
+                        };
+                        TreeMap envVars = new TreeMap(comparator);
+                        envVars.putAll((Map)inputElement);
+                        elements = new EnvironmentVariable[envVars.size()];
+                        int index = 0;
+                        for (Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
+                            Object key = iterator.next();
+                            elements[index] = (EnvironmentVariable) envVars.get(key);
+                        }
+                    }
+                    return elements;
+                }
+                public void dispose() { 
+                }
+                public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                }
+            };
+        }
+    }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LogTabDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LogTabDialog.java
new file mode 100644 (file)
index 0000000..eab6e86
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizards;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+public class LogTabDialog extends Dialog {
+
+    private int x = 0;
+    private int y = 0;
+    private final int width = 700;
+    private final int height = 500;
+    private String deviceLog = "";
+    private String rootstrapLog = "";
+
+    private static final String TITLE = "Show log";
+
+    protected LogTabDialog(Shell parentShell, String deviceLog, String rootstrapLog) {
+        super(parentShell);
+        Rectangle bounds = parentShell.getBounds();
+        x = bounds.x + (bounds.width - width) / 2;
+        y = bounds.y + (bounds.height - height) / 2;
+
+        this.deviceLog = deviceLog;
+        this.rootstrapLog = rootstrapLog;
+    }
+
+    @Override
+    protected void configureShell(Shell newShell) {
+        super.configureShell(newShell);
+
+        newShell.setText(TITLE);
+        newShell.setLocation(x, y);
+        newShell.setSize(width, height);
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        composite.setLayout(new GridLayout(1, false));
+
+        createTabs(composite);
+        return null;
+    }
+
+    private void createTabs(Composite parent) {
+        TabFolder tabFolder = new TabFolder(parent, SWT.BORDER);
+        GridData data = new GridData(GridData.FILL_BOTH);
+        tabFolder.setLayoutData(data);
+        tabFolder.setLayout(new GridLayout(1, false));
+
+        createDeviceLogTab(tabFolder);
+        createRootstrapLogTab(tabFolder);
+    }
+
+    private void createDeviceLogTab(TabFolder parent) {
+        TabItem tab = new TabItem(parent, SWT.NULL);
+        tab.setText("Internal log (Device)");
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        tab.setControl(composite);
+        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+                | GridData.VERTICAL_ALIGN_BEGINNING));
+        composite.setLayout(new GridLayout(1, false));
+        createTextAreaComposite(composite, deviceLog);
+    }
+
+    private void createRootstrapLogTab(TabFolder parent) {
+        TabItem tab = new TabItem(parent, SWT.NULL);
+        tab.setText("Internal log (Rootstrap)");
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        tab.setControl(composite);
+        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+                | GridData.VERTICAL_ALIGN_BEGINNING));
+        composite.setLayout(new GridLayout(1, false));
+        createTextAreaComposite(composite, rootstrapLog);
+    }
+
+    private void createTextAreaComposite(Composite parent, String log) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        composite.setLayout(new GridLayout(1, false));
+
+        Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL
+                | SWT.V_SCROLL);
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        text.setLayoutData(gridData);
+        text.setText(log);
+    }
+
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
+    }
+
+}
index 7b39464..f11a58c 100644 (file)
@@ -47,7 +47,7 @@ import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
 import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory;
 import org.tizen.nativeplatform.types.LaunchTypes;
 
-public class PlatformAttachLaunchWizard extends PlatformLaunchWizard {
+public class PlatformAttachLaunchWizard extends PlatformCommonLaunchWizard {
 
     private int pid;
     private String procName;
@@ -89,10 +89,10 @@ public class PlatformAttachLaunchWizard extends PlatformLaunchWizard {
         }
         programPath = page.getProgramPath();
         pid = page.getPid();
-        packages = page.getPackages();
+        //packages = page.getPackages();
         IWizardContainer container = getContainer();
         reinstallOp = page.getReinstallOp();
-        selectPkgOp = page.getSelectPkgOp();
+        //selectPkgOp = page.getSelectPkgOp();
         procName = page.getProcName();
         pid = page.getPid();
 
@@ -102,7 +102,7 @@ public class PlatformAttachLaunchWizard extends PlatformLaunchWizard {
                         InterruptedException {
                     monitor.beginTask("", 1);
                     monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
-
+                    /*
                     IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target,
                             packages, reinstallOp, selectPkgOp);
                     if (pkgLauncher == null) {
@@ -112,6 +112,7 @@ public class PlatformAttachLaunchWizard extends PlatformLaunchWizard {
                         pkgLauncher.debugLaunchPkgs(LaunchTypes.ATTACH, shell,
                                 new SubProgressMonitor(monitor, 1));
                     }
+                    */
                     monitor.done();
                 }
             });
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformCommonLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformCommonLaunchWizard.java
new file mode 100644 (file)
index 0000000..582a842
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.IPageChangingListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.jface.dialogs.PageChangingEvent;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.pkg.model.PkgStatus;
+
+public class PlatformCommonLaunchWizard extends Wizard implements IPageChangingListener,
+        IPageChangedListener {
+
+    protected IProject project;
+    protected IConfiguration config;
+    protected PkgCommandTarget target;
+    protected ILaunchConfiguration launchConfig;
+    protected Shell shell;
+    protected String programPath = "";
+    protected String arguments = "";
+    protected String selectedApp = "";
+    protected Map<String, String> envs;
+    protected boolean reinstallOp;
+    protected List<IPackage> devicePackages = new ArrayList<IPackage>();
+    protected List<IPackage> rootstrapPackages = new ArrayList<IPackage>();
+    protected String mode = "";
+    protected boolean result;
+    protected boolean canFinish = false;
+    protected String deviceLog = "";
+    protected String rootstrapLog = "";
+
+    public PlatformCommonLaunchWizard() {
+    }
+
+    public PlatformCommonLaunchWizard(Shell shell, IProject project, IConfiguration config,
+            PkgCommandTarget target, String mode) {
+        this.project = project;
+        this.config = config;
+        this.shell = shell;
+        this.target = target;
+        this.mode = mode;
+        setWindowTitle("Launch Configuration");
+        setNeedsProgressMonitor(true);
+        TrayDialog.setDialogHelpAvailable(false);
+    }
+
+    public PlatformCommonLaunchWizard(Shell shell, ILaunchConfiguration launchConfig,
+            IProject project, IConfiguration config, PkgCommandTarget target, String mode) {
+        this.project = project;
+        this.config = config;
+        this.shell = shell;
+        this.target = target;
+        this.mode = mode;
+        this.launchConfig = launchConfig;
+        setWindowTitle("Launch Configuration");
+        setNeedsProgressMonitor(true);
+        TrayDialog.setDialogHelpAvailable(false);
+    }
+
+    @Override
+    public boolean needsProgressMonitor() {
+        return true;
+    }
+
+    @Override
+    public boolean canFinish() {
+        return canFinish;
+    }
+
+    public void setEnableFinish(boolean value) {
+        canFinish = value;
+    }
+
+    @Override
+    public boolean performFinish() {
+        return true;
+    }
+
+    public String getProgramPath() {
+        return programPath;
+    }
+
+    public String getArguments() {
+        return arguments;
+    }
+
+    public List<IPackage> getDevicePackage() {
+        return devicePackages;
+    }
+
+    public List<IPackage> getRootstrapPackage() {
+        return rootstrapPackages;
+    }
+
+    public boolean getReinstallOp() {
+        return reinstallOp;
+    }
+
+    public String getSelectedApp() {
+        return selectedApp;
+    }
+
+    public Map<String, String> getEnvironments() {
+        return envs;
+    }
+
+    @Override
+    public void addPages() {
+
+    }
+
+    @Override
+    public void pageChanged(PageChangedEvent event) {
+    }
+
+    @Override
+    public void handlePageChanging(final PageChangingEvent event) {
+
+    }
+
+    public void cancelChanging(PageChangingEvent event) {
+        event.doit = false;
+    }
+
+    public void openLogDialog(final String desc, final String log) {
+        SWTUtil.syncExec(new Runnable() {
+            public void run() {
+                ShowLogDialog dialog = new ShowLogDialog(shell, desc, log);
+                dialog.open();
+            }
+        });
+    }
+
+    public void openLogTabDialog() {
+        deviceLog = target.getDeviceCommander().getLogs();
+        rootstrapLog = target.getRootstrapCommander().getLogs();
+        SWTUtil.syncExec(new Runnable() {
+            public void run() {
+                LogTabDialog dialog = new LogTabDialog(shell, deviceLog, rootstrapLog);
+                dialog.open();
+            }
+        });
+    }
+
+    public void openSetEnvDialog() {
+        SWTUtil.syncExec(new Runnable() {
+            public void run() {
+                EnvironmentDialog dialog = new EnvironmentDialog(shell, envs);
+                if (dialog.open() == Dialog.OK) {
+                    envs = dialog.getEnvs();
+                }
+            }
+        });
+    }
+
+    public void openErrorDialog(final String error) {
+        SWTUtil.syncExec(new Runnable() {
+            public void run() {
+                DialogUtil.openErrorDialog(error);
+            }
+        });
+    }
+
+    public boolean openPkgStatusDialog(final List<PkgStatus> BuildSystemPkgStatus,
+            final List<PkgStatus> DevicePkgStatus) {
+        SWTUtil.syncExec(new Runnable() {
+            public void run() {
+                ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell,
+                        BuildSystemPkgStatus, DevicePkgStatus);
+                if (Window.OK == statusDlg.open()) {
+                    result = true;
+                } else {
+                    result = false;
+                }
+            }
+        });
+
+        return result;
+    }
+}
index 30a31b0..42ecfd3 100644 (file)
@@ -63,7 +63,7 @@ import org.tizen.nativeplatform.util.GBSArchitectureChecker;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 
-public class PlatformCoredumpLaunchWizard extends PlatformLaunchWizard {
+public class PlatformCoredumpLaunchWizard extends PlatformCommonLaunchWizard {
 
     private PlatformRootstrap selectedRootstrap;
     private CoredumpModel coredumpModel;
index 6df393b..3a0537e 100644 (file)
 
 package org.tizen.nativeplatform.launch.wizards;
 
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.IPageChangingListener;
+import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.jface.dialogs.PageChangedEvent;
 import org.eclipse.jface.dialogs.PageChangingEvent;
-import org.eclipse.jface.dialogs.TrayDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.common.util.DialogUtil;
-import org.tizen.common.util.SWTUtil;
-import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
-import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingAppPage;
-import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingBinPage;
-import org.tizen.nativeplatform.pkg.commander.IPkgLauncher;
+import org.tizen.nativeplatform.launch.wizard.pages.PlatformEFLLaunchSettingPage;
+import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingPage;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory;
-import org.tizen.nativeplatform.pkg.model.IPackage;
-import org.tizen.nativeplatform.pkg.model.PkgStatus;
-import org.tizen.nativeplatform.types.LaunchTypes;
 
-public class PlatformLaunchWizard extends Wizard implements IPageChangingListener,
-        IPageChangedListener {
+public class PlatformLaunchWizard extends PlatformCommonLaunchWizard {
 
-    protected IProject project;
-    protected IConfiguration config;
-    protected PkgCommandTarget target;
-    protected Shell shell;
-    protected String programPath = "";
-    protected String appProjectName = "";
-    protected boolean reinstallOp;
-    protected boolean selectPkgOp;
-    protected List<IPackage> packages = new ArrayList<IPackage>();
-    protected List<IPackage> appPackages = new ArrayList<IPackage>();
-    protected List<IPackage> extraPackages = new ArrayList<IPackage>();
-    protected String appProject = "";
-    protected String mode = "";
-    protected boolean result;
-    protected boolean canFinish = false;
+    protected String deviceLog = "";
+    protected String rootstrapLog = "";
+    protected String descMsg = "";
+    protected boolean isEFL;
 
-    private static final String SETTING_APP_PAGE = "setting_app";
     private static final String SETTING_BIN_PAGE = "setting_bin";
 
     public PlatformLaunchWizard() {
+        super();
     }
 
-    public PlatformLaunchWizard(Shell shell, IProject project, IConfiguration config,
-            PkgCommandTarget target, String mode) {
-        this.project = project;
-        this.config = config;
-        this.shell = shell;
-        this.target = target;
-        this.mode = mode;
-        setWindowTitle("Launch Configuration");
-        setNeedsProgressMonitor(true);
-        TrayDialog.setDialogHelpAvailable(false);
-    }
-
-    @Override
-    public boolean needsProgressMonitor() {
-        return true;
-    }
-
-    @Override
-    public boolean canFinish() {
-        return canFinish;
-    }
-
-    public void setEnableFinish(boolean value) {
-        canFinish = value;
+    public PlatformLaunchWizard(Shell shell, ILaunchConfiguration launchConfig,
+            IProject project, IConfiguration config,
+            PkgCommandTarget target, String mode, String deviceLog, String rootstrapLog,
+            String descMsg, boolean isEFL) {
+        super(shell, launchConfig, project, config, target, mode);
+        this.deviceLog = deviceLog;     
+        this.rootstrapLog = rootstrapLog;
+        this.descMsg = descMsg;
+        this.isEFL = isEFL;
     }
 
     @Override
     public boolean performFinish() {
-        PlatformLaunchSettingBinPage binPage = (PlatformLaunchSettingBinPage) getPage(SETTING_BIN_PAGE);
-        if (binPage != null) {
-            programPath = binPage.getPath();
-        }
-        PlatformLaunchSettingAppPage appPage = (PlatformLaunchSettingAppPage) getPage(SETTING_APP_PAGE);
-        if (appPage != null) {
-            appProjectName = appPage.getAppProjectName();
-            extraPackages = appPage.getExtraPackages();
+        if (isEFL) {
+            PlatformEFLLaunchSettingPage binPage = (PlatformEFLLaunchSettingPage) getPage(SETTING_BIN_PAGE);
+            if (binPage != null) {
+                programPath = binPage.getBinaryPath();
+                arguments = binPage.getArguments();
+                selectedApp = binPage.getSelectedApp();
+            }
+        } else {
+            PlatformLaunchSettingPage binPage = (PlatformLaunchSettingPage) getPage(SETTING_BIN_PAGE);
+            if (binPage != null) {
+                programPath = binPage.getBinaryPath();
+                arguments = binPage.getArguments();
+                selectedApp = binPage.getSelectedApp();
+            }
         }
         return true;
     }
 
-    public String getProgramPath() {
-        return programPath;
-    }
-
-    public List<IPackage> getPackages() {
-        return packages;
-    }
-
-    public List<IPackage> getExtraPackages() {
-        return extraPackages;
-    }
-
-    public String getAppProjectName() {
-        return appProjectName;
-    }
-
-    public boolean getReinstallOp() {
-        return reinstallOp;
-    }
-
-    public boolean getSelectPkgOp() {
-        return selectPkgOp;
-    }
-
     @Override
     public void addPages() {
-        addPage(new PlatformLaunchSettingAppPage(shell, SETTING_APP_PAGE, project, config, target));
-        addPage(new PlatformLaunchSettingBinPage(this, SETTING_BIN_PAGE));
+        if (isEFL) {
+            addPage(new PlatformEFLLaunchSettingPage(this, shell, SETTING_BIN_PAGE, project,
+                    config, target, descMsg, mode));
+        } else {
+            addPage(new PlatformLaunchSettingPage(this, shell, SETTING_BIN_PAGE, project, config,
+                    target, descMsg, mode));
+        }
 
         WizardDialog dialog = (WizardDialog) getContainer();
         dialog.addPageChangedListener(this);
@@ -165,123 +103,5 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene
 
     @Override
     public void handlePageChanging(final PageChangingEvent event) {
-        // TODO Auto-generated method stub
-        WizardPage currentPage = (WizardPage) event.getCurrentPage();
-        WizardPage targetPage = (WizardPage) event.getTargetPage();
-
-        if (currentPage.getName().equals(SETTING_APP_PAGE)
-                && targetPage.getName().equals(SETTING_BIN_PAGE)) {
-            PlatformLaunchSettingAppPage page = (PlatformLaunchSettingAppPage) currentPage;
-            IWizardContainer container = getContainer();
-            packages = page.getPackages();
-            extraPackages = page.getExtraPackages();
-            appPackages = page.getAppPackages();
-            final IProject appProj = page.getAppProject();
-            programPath = page.getBinaryPath();
-            reinstallOp = page.getReinstallOp();
-            selectPkgOp = page.getSelectPkgOp();
-
-            if (programPath != null && !programPath.isEmpty()) {
-                ((PlatformLaunchSettingBinPage) targetPage).setBinaryPath(programPath);
-            }
-
-            try {
-                container.run(true, true, new IRunnableWithProgress() {
-                    public void run(IProgressMonitor monitor) throws InvocationTargetException,
-                            InterruptedException {
-                        int totalWorks = 1;
-                        IPkgLauncher appPkgLauncher = null;
-
-                        if (appProj != null) {
-                            totalWorks++;
-
-                        }
-                        monitor.beginTask("", totalWorks);
-
-                        // create app package launcher and increase work count if app packages are
-                        // existed
-                        if (appProj != null) {
-                            appPkgLauncher = PkgLauncherFactory.getLauncher(appProj, target,
-                                    appPackages, reinstallOp, selectPkgOp);
-                        }
-                        // create package launcher for platform and extra packages
-                        IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target,
-                                packages, reinstallOp, selectPkgOp);
-
-                        if (pkgLauncher == null) {
-                            throw new InterruptedException();
-                        }
-                        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
-                            // 1. launch platform and extra packages
-                            pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell,
-                                    new SubProgressMonitor(monitor, 1));
-                            // 2. launch application packages
-                            if (appPkgLauncher != null) {
-                                appPkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell,
-                                        new SubProgressMonitor(monitor, 1));
-                            }
-                        } else {
-                            // 1. launch platform and extra packages
-                            pkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
-                            // 2. launch application packages
-                            if (appPkgLauncher != null) {
-                                appPkgLauncher
-                                        .launchPkgs(shell, new SubProgressMonitor(monitor, 1));
-                            }
-                        }
-                        monitor.done();
-                    }
-                });
-            } catch (InvocationTargetException e) {
-                e.printStackTrace();
-                openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
-                cancelChanging(event);
-            } catch (InterruptedException e) {
-                // This exception is occurred if device is not root on or failed
-                // to install
-                e.printStackTrace();
-                openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
-                cancelChanging(event);
-            }
-        }
-    }
-
-    public void cancelChanging(PageChangingEvent event) {
-        event.doit = false;
-    }
-
-    public void openLogDialog(final String desc, final String log) {
-        SWTUtil.syncExec(new Runnable() {
-            public void run() {
-                ShowLogDialog dialog = new ShowLogDialog(shell, desc, log);
-                dialog.open();
-            }
-        });
-    }
-
-    public void openErrorDialog(final String error) {
-        SWTUtil.syncExec(new Runnable() {
-            public void run() {
-                DialogUtil.openErrorDialog(error);
-            }
-        });
-    }
-
-    public boolean openPkgStatusDialog(final List<PkgStatus> BuildSystemPkgStatus,
-            final List<PkgStatus> DevicePkgStatus) {
-        SWTUtil.syncExec(new Runnable() {
-            public void run() {
-                ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell,
-                        BuildSystemPkgStatus, DevicePkgStatus);
-                if (Window.OK == statusDlg.open()) {
-                    result = true;
-                } else {
-                    result = false;
-                }
-            }
-        });
-
-        return result;
     }
-
 }
index e7b10e9..a606f08 100644 (file)
 
 package org.tizen.nativeplatform.launch.wizards;
 
-import java.util.List;
+import java.util.Map;
 
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.nativeplatform.coredump.model.CoredumpModel;
-import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 
 public class PlatformLaunchWizardDialog extends WizardDialog {
@@ -67,38 +66,33 @@ public class PlatformLaunchWizardDialog extends WizardDialog {
             return null;
         }
     }
-
-    public List<IPackage> getExtraPackages() {
+    
+    public String getArguments() {
         if (wizard != null) {
-            return wizard.getExtraPackages();
-        } else {
-            return null;
+            return wizard.getArguments();
         }
+        return null;
     }
-
-    public String getAppProjectName() {
+    
+    public String getSelectedApp() {
         if (wizard != null) {
-            return wizard.getAppProjectName();
-        } else {
-            return null;
+            return wizard.getSelectedApp();
         }
+        return null;
     }
-
-    public boolean getReinstallOp() {
+    
+    public Map<String, String> getEnvironments() {
         if (wizard != null) {
-            return wizard.getReinstallOp();
-        } else if (attachWizard != null) {
-            return attachWizard.getReinstallOp();
-        } else {
-            return true;
+            return wizard.getEnvironments();
         }
+        return null;
     }
 
-    public boolean getSelectPkgOp() {
+    public boolean getReinstallOp() {
         if (wizard != null) {
-            return wizard.getSelectPkgOp();
+            return wizard.getReinstallOp();
         } else if (attachWizard != null) {
-            return attachWizard.getSelectPkgOp();
+            return attachWizard.getReinstallOp();
         } else {
             return true;
         }
index 4f77c1b..fe19bba 100644 (file)
@@ -202,4 +202,15 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
         }
         return "";
     }
+
+    public String[] getAppId() {
+        List<String> idList = new ArrayList<String>();
+        for (PlatformManifestModel m : models) {
+            String id = m.getAppId();
+            if (id != null && !id.isEmpty()) {
+                idList.add(id);
+            }
+        }
+        return idList.toArray(new String[0]);
+    }
 }
index 02d3eb8..fcbe3ca 100644 (file)
@@ -94,7 +94,7 @@ public interface IPkgCommander {
 
     Map<String, PkgStatus> getLocalPkgList();
 
-    Map<String, PkgStatus> getWhatProvides(String capability);
+    Map<String, PkgStatus> getWhatProvides(String capability, TOOL tool);
 
     List<Repository> getRepoList();
 
@@ -114,6 +114,8 @@ public interface IPkgCommander {
 
     boolean existsFile(String file);
 
+    String canonicalizePath(String path);
+
     ICommandStatus getMd5Checksum(String path);
 
     ICommandStatus makeDir(String path);
@@ -139,4 +141,6 @@ public interface IPkgCommander {
     String getSrcPkgName(String pkg);
 
     String getLogs();
+
+    void cancelExecution();
 }
index 0a8c4e0..eed4d42 100644 (file)
@@ -37,4 +37,8 @@ public interface IPkgLauncher {
             throws InterruptedException;
 
     void launchPkgs(Shell shell, IProgressMonitor monitor) throws InterruptedException;
+
+    String getRootstrapLog();
+
+    String getDeviceLog();
 }
index 3680ac8..f0e30bd 100644 (file)
@@ -150,7 +150,7 @@ public class DebCommanderHost implements IPkgCommander {
     }
 
     @Override
-    public Map<String, PkgStatus> getWhatProvides(String capability) {
+    public Map<String, PkgStatus> getWhatProvides(String capability, TOOL tool) {
         return null;
     }
 
@@ -301,4 +301,13 @@ public class DebCommanderHost implements IPkgCommander {
     public ICommandStatus executeBinary(String binary) {
         return null;
     }
+
+    @Override
+    public String canonicalizePath(String path) {
+        return null;
+    }
+
+    @Override
+    public void cancelExecution() {
+    }
 }
index 24e3107..bc8a143 100644 (file)
@@ -38,11 +38,11 @@ import org.tizen.nativeplatform.types.PkgTypes;
 
 public class PkgLauncherFactory {
     public static IPkgLauncher getLauncher(IProject project, PkgCommandTarget target,
-            List<IPackage> packages, boolean reinstallOp, boolean selectPkgOp) {
+            List<IPackage> devicePackages, List<IPackage> rootstrapPackage, boolean reinstallOp) {
         PkgTypes type = target.getPkgType();
         if (type.equals(PkgTypes.RPM)) {
-            IPkgLauncher launcher = new RpmPackageLauncher(project, target, packages, reinstallOp,
-                    selectPkgOp);
+            IPkgLauncher launcher = new RpmPackageLauncher(project, target, 
+                    devicePackages, rootstrapPackage, reinstallOp);
             return launcher;
         } else {
             return null;
index 18be286..4e7ddd0 100644 (file)
@@ -70,6 +70,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     protected final String CMD_RESET_RPM_DB = "rm -f /var/lib/rpm/__db*";
     protected final String CMD_FILE_FILE = "ls %s 2>/dev/null";
     protected final String CMD_EXPORT_PROXY = "export http_proxy=%s";
+    protected final String CMD_READLINK = "/usr/bin/readlink -f %s";
 
     protected final Logger logger = LoggerFactory.getLogger(RpmCommanderCommon.class);
     protected String http_proxy;
@@ -131,6 +132,12 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     public PackageManagerOutputReceiver getOutputReceiver() {
         return rec;
     }
+    
+    public void cancelExecution() {
+        if (rec != null) {
+            rec.setCancel(true);
+        }
+    }
 
     public String getLogs() {
         if (rec == null || rec.getLog() == null) {
@@ -378,15 +385,15 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
             if (type == TOOL.RPM) {
                 String command = makeCommand(getResetRpmDb(),
                         RpmTool.installCommand(value.toArray(new String[0])));
-                status = execute(command, monitor);
+                status = execute(command, 50000, monitor);
             } else if (type == TOOL.ZYPPER) {
                 String command = makeCommand(getResetRpmDb(),
                         ZypperTool.installLocalCommand(value.toArray(new String[0])));
-                status = execute(command, monitor);
+                status = execute(command, 50000, monitor);
             } else if (type == TOOL.PKGCMD) {
                 for (String pkg : value) {
                     String command = makeCommand(getResetRpmDb(), PkgcmdTool.installCommand(pkg));
-                    status = execute(command, monitor);
+                    status = execute(command, 50000, monitor);
                 }
             }
         }
@@ -508,6 +515,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         String repo = "";
         String vendor = "";
         String summary = "";
+        String installed = "";
         boolean isInstalled = false;
         StringBuffer sbDesc = new StringBuffer();
         List<String> installedFiles = new ArrayList<String>();
@@ -537,6 +545,8 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
                     vendor = (strs[1] != null) ? strs[1].trim() : "";
                 } else if (key.equals(ZypperTool.TITLE_SUMMARY)) {
                     summary = (strs[1] != null) ? strs[1].trim() : "";
+                } else if (key.equals(ZypperTool.TITLE_INSTALLED)) {
+                    installed = (strs[1] != null) ? strs[1].trim() : "";
                 }
             } else if (strs.length == 1) {
                 String key = strs[0].trim();
@@ -559,10 +569,19 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
             isInstalled = true;
             dependencies.addAll(getPkgDependencies(pkg));
             installedFiles.addAll(getPkgInstalledFiles(pkg));
+        } else if (type == TOOL.ZYPPER) {
+            if (installed.equals("Yes")) {
+                isInstalled = true;
+            } else if (installed.equals("No")) {
+                isInstalled = false;
+            }
         }
         if (!rel.isEmpty()) {
             ver = ver + "-" + rel;
         }
+        if (name.isEmpty()) {
+            return null;
+        }
         PkgInfo info = new PkgInfo().setName(name).setArch(arch).setVer(ver).setSize(size)
                 .setStatus(isInstalled).setRepo(repo).setVendor(vendor).setDesc(sbDesc.toString())
                 .setSummary(summary).setDependencies(dependencies)
@@ -917,7 +936,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         boolean ret = false;
         String command = String.format(CMD_FILE_FILE, file);
         PackageManagerOutputReceiver hrec = getNewOuputReceiver();
-        ICommandStatus status = execute(command, hrec, null);
+        ICommandStatus status = execute(command, hrec, null, false);
         if (!status.isOk()) {
             return ret;
         }
@@ -937,6 +956,25 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         }
         return ret;
     }
+    
+    public String canonicalizePath(String path) {
+        String command = String.format(CMD_READLINK, path);
+        PackageManagerOutputReceiver hrec = getNewOuputReceiver();
+        ICommandStatus status = execute(command, hrec, null, false);
+        if (!status.isOk()) {
+            return null;
+        }
+        List<String> value = status.getValues();
+        if (value != null) {
+            for (String s : value) {
+                String resultPath = s.trim();
+                if (existsFile(resultPath)) {
+                    return resultPath;
+                }
+            }
+        }
+        return null;
+    }
 
     public void resetRepo() {
         String command = makeCommand(CMD_RESET_REPO);
@@ -948,12 +986,11 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         printResultLog("Reset repository");
     }
 
-    @Override
-    public Map<String, PkgStatus> getWhatProvides(String capability) {
+    private Map<String, PkgStatus> getWhatProvidesWithZypper(String capability) {
         String command = makeCommand(getProxyCommand(),
                 ZypperTool.whatProvideCommandXmlOut(capability));
         PackageManagerOutputReceiver hrec = getNewOuputReceiver();
-        ICommandStatus status = execute(command, hrec, null);
+        ICommandStatus status = execute(command, hrec, 10000, null);
 
         Map<String, PkgStatus> result = null;
         List<String> value = status.getValues();
@@ -972,6 +1009,57 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
         }
         return result;
     }
+    
+    private Map<String, PkgStatus> getWhatProvidesWithRpm(String capability) {
+        String command = makeCommand(RpmTool.whatProvideCommand(capability));
+        PackageManagerOutputReceiver hrec = getNewOuputReceiver();
+        ICommandStatus status  = execute(command, null, true);
+        
+        Map<String, PkgStatus> result = new HashMap<String, PkgStatus>();
+        List<String> values = status.getValues();
+        String pkgName = "";
+        String pkgVersion = "";
+        String pkgArchitecture = "";
+        if (values != null && values.size() > 0) {
+            for (String s : values) {
+                int index = s.indexOf(':');
+                if (index < 0) {
+                    continue;
+                }
+                String key = s.substring(0, index).trim();
+                String value = s.substring(index+1).trim();
+                if (key.equals("Name")) {
+                    pkgName = value;
+                } else if (key.equals("Version")) {
+                    pkgVersion = value;
+                } else if (key.equals("Architecture")) {
+                    pkgArchitecture = value;
+                } else if (key.equals("Release")) {
+                    if (!value.isEmpty()) {
+                        pkgVersion += "-" + value;
+                    }
+                }                
+            }            
+        }
+        Package pkg = new Package(pkgName, pkgVersion, pkgArchitecture);
+        PkgStatus newStatus = new PkgStatus(pkg);
+        newStatus.setInstalledVer(pkgVersion);
+        newStatus.setInstallInfo(PkgInstallTypes.INSTALLED);
+        result.put(pkgName, newStatus);
+        return result;
+    }
+    
+    @Override
+    public Map<String, PkgStatus> getWhatProvides(String capability, TOOL type) {
+        ICommandStatus status;
+        if (type == TOOL.ZYPPER) {
+            return getWhatProvidesWithZypper(capability);
+        } else if (type == TOOL.RPM) {
+            return getWhatProvidesWithRpm(capability);
+        } else {
+            return null;
+        }
+    }
 
     public PkgInstallTypes searchPkg(String pkg) {
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
@@ -1122,12 +1210,19 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     protected void pringInfoLog(String log) {
         printLog(getInfoString(log));
     }
+    
+    protected void activateConsole() {
+        if (rec != null) {
+            rec.getMsgConsoleStream().getConsole().activate();
+        }
+    }
 
     protected void printCommandLog(String command) {
         if (rec == null) {
             return;
         }
         String[] log = { NL + LOG_COMMAND_PREFIX + WS + command };
+        activateConsole();
         rec.setPrintConsole(true);
         rec.processNewLines(log);
     }
index 78d83cb..e3bdb01 100644 (file)
@@ -185,6 +185,12 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
     @Override
     public ICommandStatus executeBinary(String command) {
         ICommandStatus status = execute(command, null);
+        if (!status.isOk()) {
+            String cmdLog = status.getCommand();
+            String msgLog = status.getException().toString();
+            String log = String.format("[Exception]%s:%s", cmdLog, msgLog);
+            printResultLog(log);
+        }            
         return status;
     }
 
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmDebugPackagesResolver.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmDebugPackagesResolver.java
new file mode 100644 (file)
index 0000000..fd9eb7c
--- /dev/null
@@ -0,0 +1,154 @@
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander.TOOL;
+import org.tizen.nativeplatform.pkg.model.PkgInfo;
+import org.tizen.nativeplatform.pkg.model.PkgStatus;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
+
+public class RpmDebugPackagesResolver {
+
+    private IProgressMonitor monitor;
+    private PkgCommandTarget target;
+    private IPkgCommander rootstrapCommander;
+    private IPkgCommander deviceCommander;
+
+    public RpmDebugPackagesResolver(PkgCommandTarget target, IProgressMonitor monitor) {
+        this.target = target;
+        this.rootstrapCommander = target.getRootstrapCommander();
+        this.deviceCommander = target.getDeviceCommander();
+        this.monitor = monitor;
+    }
+
+    public boolean resolve(String command) {
+        monitor.beginTask("", 2);
+        monitor.subTask("Checking the package is installed to rootstrap...");
+        ICommandStatus status = null;
+        Map<String, PkgStatus> provides = deviceCommander.getWhatProvides(command, TOOL.RPM);
+        List<String> installablePackages = new ArrayList<String>();
+        String pkgName = "";
+        String pkgList = "";
+        String installedPkgList = "";
+        String notFoundPkgList = "";
+        StringBuffer msg = new StringBuffer();
+
+        boolean notFoundPkgs = false;
+        if (provides != null && !provides.isEmpty()) {
+            for (String key : provides.keySet()) {
+                pkgName = key;
+            }
+        }
+        if (pkgName.isEmpty()) {
+            msg.append("Failed to find package which provides next command:");
+            msg.append("\n");
+            msg.append(" - ");
+            msg.append(command);
+            msg.append("\n\n");
+            msg.append("You should install binary and debug packages to rootstrap for debugging.");
+            DialogUtil.openErrorDialog(DialogUtil.getActiveShell(), "Error", msg.toString());
+            return false;
+        }
+
+        if (!rootstrapCommander.checkPkgInstalled(pkgName)) {
+            PkgInfo pInfo = rootstrapCommander.getPkgInfo(pkgName, TOOL.ZYPPER);
+            if (pInfo != null) {
+                installablePackages.add(pkgName);
+                pkgList += String.format("- %s\n", pkgName);
+            } else {
+                notFoundPkgs = true;
+                notFoundPkgList += String.format("- %s\n", pkgName);
+            }
+        } else {
+            installedPkgList += String.format("- %s\n", pkgName);
+        }
+
+        String[] debugPkgs = PlatformLaunchUtil.getDebugPackageName(deviceCommander, pkgName);
+        for (String pkg : debugPkgs) {
+            if (pkg != null && !pkg.isEmpty()) {
+                if (!rootstrapCommander.checkPkgInstalled(pkg)) {
+                    PkgInfo pInfo = rootstrapCommander.getPkgInfo(pkg, TOOL.ZYPPER);
+                    if (pInfo != null) {
+                        installablePackages.add(pkg);
+                        pkgList += String.format("- %s\n", pkg);
+                    } else {
+                        notFoundPkgs = true;
+                        notFoundPkgList += String.format("- %s\n", pkg);
+                    }
+                } else {
+                    installedPkgList += String.format("- %s\n", pkg);
+                }
+            }
+        }
+
+        String develPkg = PlatformLaunchUtil.getDevelPackageName(rootstrapCommander, pkgName);
+        if (develPkg != null && !develPkg.isEmpty()) {
+            if (!rootstrapCommander.checkPkgInstalled(develPkg)) {
+                PkgInfo pInfo = rootstrapCommander.getPkgInfo(develPkg, TOOL.ZYPPER);
+                if (pInfo != null) {
+                    installablePackages.add(develPkg);
+                    pkgList += String.format("- %s\n", develPkg);
+                }
+            }
+        }
+
+        monitor.worked(1);
+
+        if (!installablePackages.isEmpty()) {
+            if (notFoundPkgs) {
+                msg.append("There are not debug packages in repositories:\n");
+                msg.append(notFoundPkgList);
+                msg.append("\n");
+            }
+            msg.append("Found debug packages for \"");
+            msg.append(pkgName);
+            msg.append("\" package:");
+            msg.append("\n");
+            msg.append(pkgList);
+            msg.append("\n");
+            msg.append("Do you want to install it to rootstrap?");
+            msg.append("\n");
+            msg.append("(These packages should be installed for debugging)");
+            int result = DialogUtil.openQuestionDialog(msg.toString());
+            if (result == SWT.YES) {
+                monitor.subTask("Install packages...");
+                String[] installPkgs = installablePackages.toArray(new String[0]);
+                status = rootstrapCommander.installRemotePkg(installPkgs, new SubProgressMonitor(
+                        monitor, 1));
+                if (!status.isOk()) {
+                    return false;
+                }
+                for (String pkg : installablePackages) {
+                    if (!rootstrapCommander.checkPkgInstalled(pkg)) {
+                        return false;
+                    }
+                }
+            } else {
+                return false;
+            }
+        } else {
+            if (notFoundPkgs) {
+                msg.append("There are not debug packages in repositories:");
+                msg.append("\n");
+                msg.append(notFoundPkgList);
+                msg.append("\n");
+                msg.append("You should install binary and debug packages to rootstrap for debugging.");
+                DialogUtil.openErrorDialog(DialogUtil.getActiveShell(), "Error", msg.toString());
+                return false;
+            }
+        }
+        monitor.worked(1);
+
+        monitor.done();
+        return true;
+    }
+}
index 5f508ef..e727973 100644 (file)
@@ -96,7 +96,9 @@ public class RpmModelMaker implements IPkgModelMaker {
         List<IPackage> pkgs = new ArrayList<IPackage>();
         for (String path : filePaths) {
             IPackage pkg = makeModel(path, needsFilter);
-            pkgs.add(pkg);
+            if (pkg != null) {
+                pkgs.add(pkg);
+            }
         }
         return pkgs;
     }
index 399fc4d..e391703 100644 (file)
 
 package org.tizen.nativeplatform.pkg.commander.rpm;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.rds.ui.preference.RdsPreferencePage;
-import org.tizen.common.util.SWTUtil;
 import org.tizen.common.util.log.UserInteraction;
 import org.tizen.common.util.log.UserLogger;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
-import org.tizen.nativeplatform.indexer.DefaultIncludePathImporter;
 import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
-import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog;
 import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
 import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
-import org.tizen.nativeplatform.pkg.commander.IPkgFilter;
 import org.tizen.nativeplatform.pkg.commander.IPkgLauncher;
 import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater;
 import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
-import org.tizen.nativeplatform.pkg.commander.factory.PkgFilterFactory;
 import org.tizen.nativeplatform.pkg.commander.factory.PkgStatusUpdaterFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.pkg.model.PkgStatus;
@@ -64,30 +57,27 @@ import org.tizen.nativeplatform.types.LaunchTypes;
 import org.tizen.nativeplatform.types.PkgInstallTypes;
 import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
-import org.tizen.sdblib.exception.SdbCommandRejectedException;
-import org.tizen.sdblib.exception.TimeoutException;
 import org.tizen.sdblib.util.DeviceUtil;
 
 public class RpmPackageLauncher implements IPkgLauncher {
     private IProject project;
     private PkgCommandTarget target;
-    private IPkgFilter pkgFilter;
     private IPkgStatusUpdater pkgUpdater;
-    private boolean selectPkgOp;
     private boolean reinstallOp;
-    private List<IPackage> packages;
-    private boolean result = false;
-    
+    private List<IPackage> devicePackages;
+    private List<IPackage> rootstrapPackages;
+    private String deviceLog = "";
+    private String rootstrapLog = "";
+
     private final Logger logger = LoggerFactory.getLogger(RpmPackageLauncher.class);
 
-    public RpmPackageLauncher(IProject project, PkgCommandTarget target, List<IPackage> packages,
-            boolean reinstallOp, boolean selectPkgOp) {
-        this.packages = packages;
-        this.selectPkgOp = selectPkgOp;
+    public RpmPackageLauncher(IProject project, PkgCommandTarget target,
+            List<IPackage> devicePackages, List<IPackage> rootstrapPackages, boolean reinstallOp) {
+        this.devicePackages = devicePackages;
+        this.rootstrapPackages = rootstrapPackages;
         this.reinstallOp = reinstallOp;
         this.project = project;
         this.target = target;
-        this.pkgFilter = PkgFilterFactory.getFilter(target.getPkgType());
         this.pkgUpdater = PkgStatusUpdaterFactory.getUpdater(target);
     }
 
@@ -129,10 +119,8 @@ public class RpmPackageLauncher implements IPkgLauncher {
     /*
      * Check whether to use RDS
      * 
-     * Return true, if
-     *  1. RDS preference should be checked.
-     *  2. Packages are already installed as same version.
-     * 
+     * Return true, if 1. RDS preference should be checked. 2. Packages are
+     * already installed as same version.
      */
     private boolean checkAvaiableRds(IProject project, List<PkgStatus> pkgStatus) {
         boolean checkedRdsPref = RdsPreferencePage.isRdsMode(project);
@@ -165,13 +153,6 @@ public class RpmPackageLauncher implements IPkgLauncher {
         monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
         boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
 
-        // if (!isEflApp && selectPkgOp) {
-        if (selectPkgOp) {
-            if (!openPkgStatusDialog(shell, buildSystemPkgStatus, devicePkgStatus)) {
-                newInterruptedException(PlatformLaunchMessages.CANCELED_LAUNCH);
-            }
-        }
-
         List<IPackage> selectBsPkgs = getSelectedPackages(buildSystemPkgStatus);
         List<IPackage> selectDvPkgs = getSelectedPackages(devicePkgStatus);
 
@@ -198,8 +179,7 @@ public class RpmPackageLauncher implements IPkgLauncher {
                 installPkgsToDevice(selectDvPkgs, IPkgCommander.TOOL.PKGCMD, monitor,
                         dvAvailableRds);
             } else {
-                installPkgsToDevice(selectDvPkgs, IPkgCommander.TOOL.ZYPPER, monitor,
-                        dvAvailableRds);
+                installPkgsToDevice(selectDvPkgs, IPkgCommander.TOOL.RPM, monitor, dvAvailableRds);
             }
             monitor.worked(1);
         }
@@ -220,8 +200,12 @@ public class RpmPackageLauncher implements IPkgLauncher {
     }
 
     private List<PkgStatus> filterAndUpdatePkgs(CmdTargetTypes cmdTarget) {
-        List<IPackage> pkgs = pkgFilter.filter(cmdTarget, packages);
-        List<PkgStatus> pkgStatus = pkgUpdater.updateStatus(cmdTarget, pkgs);
+        List<PkgStatus> pkgStatus = null;
+        if (cmdTarget.equals(CmdTargetTypes.DEVICE)) {
+            pkgStatus = pkgUpdater.updateStatus(cmdTarget, devicePackages);
+        } else if (cmdTarget.equals(CmdTargetTypes.ROOTSTRAP)) {
+            pkgStatus = pkgUpdater.updateStatus(cmdTarget, rootstrapPackages);
+        }
         applyReinstallOp(pkgStatus, reinstallOp);
         return pkgStatus;
     }
@@ -246,24 +230,6 @@ public class RpmPackageLauncher implements IPkgLauncher {
         throw new InterruptedException(message);
     }
 
-    private boolean openPkgStatusDialog(final Shell shell,
-            final List<PkgStatus> buildSystemPkgStatus, final List<PkgStatus> devicePkgStatus) {
-
-        SWTUtil.syncExec(new Runnable() {
-            public void run() {
-                ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell,
-                        buildSystemPkgStatus, devicePkgStatus);
-                if (Window.OK == statusDlg.open()) {
-                    result = true;
-                } else {
-                    result = false;
-                }
-            }
-        });
-
-        return result;
-    }
-
     private List<IPackage> getSelectedPackages(List<PkgStatus> pkgStatus) {
         List<IPackage> selectedPkgs = new ArrayList<IPackage>();
         for (PkgStatus status : pkgStatus) {
@@ -284,19 +250,19 @@ public class RpmPackageLauncher implements IPkgLauncher {
             PkgMgrInitializer initializer = new PkgMgrInitializer(target, CmdTargetTypes.ROOTSTRAP);
             initializer.initRootstrapRepoInfo();
         }
+        IPkgCommander commander = target.getCommander(CmdTargetTypes.ROOTSTRAP);
+        boolean installResult = false;
         if (useRds) {
-            boolean result = internalProcessRDS(target.getCommander(CmdTargetTypes.ROOTSTRAP),
-                    packages, false, monitor);
+            installResult = internalProcessRDS(commander, packages, false, monitor);
             // if RDS is failed, install packages normally
-            if (!result) {
-                result = installPkgs(target.getCommander(CmdTargetTypes.ROOTSTRAP), type, packages,
-                        monitor);
+            if (!installResult) {
+                installResult = installPkgs(commander, type, packages, monitor);
             }
-            return result;
         } else {
-            return installPkgs(target.getCommander(CmdTargetTypes.ROOTSTRAP), type, packages,
-                    monitor);
+            installResult = installPkgs(commander, type, packages, monitor);
         }
+        rootstrapLog = commander.getLogs();
+        return installResult;
     }
 
     private boolean installPkgsToDevice(List<IPackage> packages, IPkgCommander.TOOL type,
@@ -309,18 +275,19 @@ public class RpmPackageLauncher implements IPkgLauncher {
             PkgMgrInitializer initializer = new PkgMgrInitializer(target, CmdTargetTypes.DEVICE);
             initializer.initDeviceRepoInfo();
         }
+        IPkgCommander commander = target.getCommander(CmdTargetTypes.DEVICE);
+        boolean installResult = false;
         if (useRds) {
-            boolean result = internalProcessRDS(target.getCommander(CmdTargetTypes.DEVICE),
-                    packages, true, monitor);
+            installResult = internalProcessRDS(commander, packages, true, monitor);
             // if RDS is failed, install packages normally
-            if (!result) {
-                result = installPkgs(target.getCommander(CmdTargetTypes.DEVICE), type, packages,
-                        monitor);
+            if (!installResult) {
+                installResult = installPkgs(commander, type, packages, monitor);
             }
-            return result;
         } else {
-            return installPkgs(target.getCommander(CmdTargetTypes.DEVICE), type, packages, monitor);
+            installResult = installPkgs(commander, type, packages, monitor);
         }
+        deviceLog = commander.getLogs();
+        return installResult;
     }
 
     private boolean installPkgs(IPkgCommander commander, IPkgCommander.TOOL type,
@@ -371,8 +338,18 @@ public class RpmPackageLauncher implements IPkgLauncher {
         RpmRapidDeployer rpmRds = new RpmRapidDeployer(project, commander, packages);
         return rpmRds.process();
     }
+
     private String newline() {
         return "\n";
     }
+
+    @Override
+    public String getRootstrapLog() {
+        return rootstrapLog;
+    }
+
+    @Override
+    public String getDeviceLog() {
+        return deviceLog;
+    }
 }
index 0fccc2d..6ffb1e8 100644 (file)
@@ -69,9 +69,7 @@ public class RpmStatusUpdater implements IPkgStatusUpdater {
             } else {
                 status.setInstalledVer(installedVer[0]);
                 if (installedVer[0].equals(newVer)) {
-                    if (commander.checkPkgInstalled(pkg.getName())) {
-                        status.setInstallInfo(PkgInstallTypes.INSTALLED);
-                    }
+                    status.setInstallInfo(PkgInstallTypes.INSTALLED);
                 } else {
                     status.setInstallInfo(PkgInstallTypes.DIFFERENT_VERSION);
                 }
index e474859..ebf4698 100644 (file)
@@ -41,6 +41,7 @@ public class RpmTool {
     private final static String FORCE_OP = "--force";
     private final static String NODEPS_OP = "--nodeps";
     private final static String IGNOREARCH_OP = "--ignorearch";
+    private final static String WHATPROVIDE_OP = "--whatprovides";
     private final static String QUERY_OP = "-q";
     private final static String QUERY_PKGLIST_OP = "-qa";
     private final static String QUERY_PKGINFO_OP = "-qi";
@@ -65,6 +66,7 @@ public class RpmTool {
     public static final String TITLE_SUMMARY = "Summary";
     public static final String TITLE_DESC = "Description";
     public static final String TITLE_REQUIRES = "Requires";
+    public static final String TITEL_SRC_RPM = "Source RPM";
 
     public static String installCommand(String[] list) {
         // Command.Install.Local.Pkg.RPM = rpm -ihv %s --ignoreos --force
@@ -136,6 +138,10 @@ public class RpmTool {
         return makeCommand(QUERY_PKGLIST_OP, QUERY_INFO_TAG_OP, tag);
     }
 
+    public static String whatProvideCommand(String capability) {
+        return makeCommand(QUERY_PKGINFO_OP, WHATPROVIDE_OP, capability);
+    }
+
     public static String fileArchCommand(String file) {
         return fileInfoByTagCommand(TAG_ARCH, file);
     }
index f66b51e..0ba6563 100644 (file)
@@ -71,6 +71,7 @@ public class ZypperTool {
     public static final String TITLE_SUMMARY = "Summary";
     public static final String TITLE_DESC = "Description";
     public static final String TITLE_REQUIRES = "Requires";
+    public static final String TITLE_INSTALLED = "Installed";
 
     public static String versionCommand(String pkg) {
         return makeCommand(NON_INTERACITVE_OP, QUERY_INFO_OP, pkg, "|", "grep", TITLE_VERSION);
index 3d512b1..dda8b21 100644 (file)
@@ -96,4 +96,8 @@ public class PackageManagerOutputReceiver extends MultiLineReceiver {
     public boolean isCancelled() {
         return isCancelled;
     }
+
+    public void setCancel(boolean value) {
+        isCancelled = value;
+    }
 }
index 067a260..bebd7ca 100644 (file)
@@ -76,6 +76,8 @@ public class PlatformLaunchUtil {
     public static final String LAUNCHPAD_PATH = "/usr/bin/launchpad_preloading_preinitializing_daemon";
     public static final String GDB_PACKAGE = "gdb";
     public static final String AUL_PACKAGE = "aul";
+    public static final String TEMP_STRING_EXEC = "##changableexec##";
+    public static final String TEMP_STRING_ID = "##changableid##";
 
     private static final Logger logger = LoggerFactory.getLogger(PlatformLaunchUtil.class);
 
@@ -168,26 +170,33 @@ public class PlatformLaunchUtil {
         }
     }
 
-    public static boolean checkGdbServerInDevice(IDevice device, TizenLaunchCommand command)
-            throws CoreException {
-
-        String resultCommand = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " --version"
-                + TizenPlatformConstants.CMD_RESULT_CHECK;
-        try {
-            command.run(resultCommand, "0");
-        } catch (TizenNativeException e) {
-            return false;
-        } catch (Exception e) {
-            return false;
+    public static String[] getDebugPackageName(IPkgCommander commander, String binaryPkg) {
+        String sourcePackage = commander.getSrcPkgName(binaryPkg);
+        String[] result = new String[3];
+        if (sourcePackage.isEmpty()) {
+            result[0] = binaryPkg + "-debuginfo";
+            result[1] = binaryPkg + "-debugsource";
+        } else {
+            result[0] = sourcePackage + "-debuginfo";
+            result[1] = sourcePackage + "-debugsource";
         }
+        return result;
+    }
 
-        return true;
+    public static String getDevelPackageName(IPkgCommander commander, String binaryPkg) {
+        String sourcePackage = commander.getSrcPkgName(binaryPkg);
+        String result = "";
+        if (sourcePackage.isEmpty()) {
+            result = binaryPkg + "-devel";
+        } else {
+            result = sourcePackage + "-devel";
+        }
+        return result;
     }
 
     public static void readyGdbServer(PkgCommandTarget cmdTarget, IDevice device,
-            TizenLaunchCommand command, IPath srcPath)
-            throws CoreException, TimeoutException, SdbCommandRejectedException, IOException,
-            Exception {
+            TizenLaunchCommand command, IPath srcPath) throws CoreException, TimeoutException,
+            SdbCommandRejectedException, IOException, Exception {
         File gdbserver = new File(srcPath.toOSString());
 
         if (!gdbserver.exists()) {
@@ -218,6 +227,22 @@ public class PlatformLaunchUtil {
         }
     }
 
+    public static boolean checkGdbServerInDevice(IDevice device, TizenLaunchCommand command)
+            throws CoreException {
+
+        String resultCommand = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " --version"
+                + TizenPlatformConstants.CMD_RESULT_CHECK;
+        try {
+            command.run(resultCommand, "0");
+        } catch (TizenNativeException e) {
+            return false;
+        } catch (Exception e) {
+            return false;
+        }
+
+        return true;
+    }
+
     public static boolean checkGdbServerInBuildSystem(String rootstrapPath) {
         IPath path = new Path(rootstrapPath).append("usr").append("bin").append("gdbserver");
         File gdbserver = new File(path.toOSString());
@@ -243,6 +268,15 @@ public class PlatformLaunchUtil {
         }
     }
 
+    public static String[] getAppId(IProject project) {
+        IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
+        if (store.loadXml()) {
+            return getAppId(store);
+        } else {
+            return null;
+        }
+    }
+
     public static String getAppId(IProject project, String programPath) {
         IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
         if (store.loadXml()) {
@@ -252,6 +286,10 @@ public class PlatformLaunchUtil {
         }
     }
 
+    public static String[] getAppId(IPlatformXMLStore store) {
+        return store.getAppId();
+    }
+
     public static String getAppId(IPlatformXMLStore store, String programPath) {
         return store.getAppId(programPath);
     }
@@ -274,12 +312,11 @@ public class PlatformLaunchUtil {
     }
 
     public static FileEntry selectRemoteFile(Shell shell, String title) {
-        return selectRemoteFile(shell, title, null);
+        return selectRemoteFile(shell, title, "/opt/apps");
     }
 
     public static FileEntry selectRemoteFile(Shell shell, String title, String defaultPath) {
         FileEntry selectedFile = null;
-        String filePath = null;
         if (shell != null) {
             IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
             if (device == null) {
@@ -300,4 +337,33 @@ public class PlatformLaunchUtil {
         }
         return selectedFile;
     }
+
+    public static String changeCommand(String cmd, String prevId, String prevExec, String newId,
+            String newExec) {
+        boolean changedExec = false;
+        boolean changedId = false;
+        if (!prevExec.equals(newExec)) {
+            if (cmd.contains(prevExec)) {
+                cmd = cmd.replaceAll(prevExec, TEMP_STRING_EXEC);
+                changedExec = true;
+            }
+        }
+        if (!prevId.equals(newId)) {
+            if (cmd.contains(prevId)) {
+                cmd = cmd.replaceAll(prevId, TEMP_STRING_ID);
+                changedId = true;
+            }
+        }
+        if (changedExec) {
+            cmd = cmd.replaceAll(TEMP_STRING_EXEC, newExec);
+        }
+        if (changedId) {
+            cmd = cmd.replaceAll(TEMP_STRING_ID, newId);
+        }
+        if (changedId || changedExec) {
+            return cmd;
+        } else {
+            return null;
+        }
+    }
 }