[Title] Added launch configuration wizard and modified package manager
authordonghyuk.yang <donghyuk.yang@samsung.com>
Sun, 11 Nov 2012 13:58:40 +0000 (22:58 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Sun, 11 Nov 2012 13:58:40 +0000 (22:58 +0900)
for applying refactoring sources

22 files changed:
org.tizen.nativeplatform/icons/rootstrap/remove.gif [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectPackaging.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowLogDialog.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPackage.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RemoveInstalledPackageDialog.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapUIMessages.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapView.java

diff --git a/org.tizen.nativeplatform/icons/rootstrap/remove.gif b/org.tizen.nativeplatform/icons/rootstrap/remove.gif
new file mode 100644 (file)
index 0000000..73f5554
Binary files /dev/null and b/org.tizen.nativeplatform/icons/rootstrap/remove.gif differ
index d452383..83b014d 100644 (file)
@@ -97,19 +97,20 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild
 
        @Override
        protected String getDebugOption(String[] arrOption) {
-               String options = "";            
-               String rootstrapPath = "";
+               String options = "";
+               
                String targetId = getTargetID();                
                
                if (targetId.contains("obs")) {
                        String passwd = SudoPasswdManager.getSudoPassword();
                        options = String.format("-passwd=%s -gdb-options=\'", passwd);
+                       String path = "";
                        try {
-                               rootstrapPath = new Path(getSbi().getRootstrapPath(getTargetID())).makeAbsolute().toOSString();
+                               path = new Path(getSbi().getRootstrapPath(getTargetID())).makeAbsolute().toOSString();
                        } catch (SBIException e) {
                                e.printStackTrace();
                        }
-                       
+                       String rootstrapPath = getSbi().getPlatformRootstrapPath(path);
                        for (int i = 0 ; i < arrOption.length ; i++) {
                                if (arrOption[i] == null) {
                                        break;
@@ -122,6 +123,7 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild
                                        options = options.concat(arrOption[i] + " ");                           
                                }
                        }                       
+                       options = String.format("-rootpath=%s ", rootstrapPath).concat(options); 
                        options = options.concat("\' ");                        
                        return options;
                        
@@ -132,6 +134,7 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild
                        }
                        options = options.concat("\' ");
             String sysroot="";
+            String rootstrapPath = "";
             try {
                rootstrapPath = getSbi().getRootstrapPath(getTargetID());
                sysroot = String.format("-sysroot=%s", rootstrapPath );
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectPackaging.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectPackaging.java
new file mode 100644 (file)
index 0000000..dbfbc82
--- /dev/null
@@ -0,0 +1,60 @@
+package org.tizen.nativeplatform.build;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.tizen.nativecommon.build.CommonBuildMessages;
+import org.tizen.nativecommon.build.CommonProjectDependentPackager;
+import org.tizen.nativecommon.build.ProjectTypeManager;
+import org.tizen.nativecommon.build.exception.SBIException;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+
+public class PlatformProjectPackaging {
+       public static boolean RPMPackaging(final IProject targetProj, IConfiguration config, IProgressMonitor monitor) {
+               String PKGTYPE = "RPM";
+        monitor.beginTask("Packaging", 1);
+
+        CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(targetProj);
+        PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, targetProj, packager.getSbi());
+        Thread checkCancelThread = new Thread(cancelJob);
+        checkCancelThread.start();
+
+        try {
+            monitor.subTask("Packaging " + targetProj.getName());
+            packager.buildPackage(PKGTYPE);
+        } catch (SBIException e) {
+            e.printStackTrace();
+            cancelJob.setFinishFlag(true);
+            monitor.done();
+            return false;
+        } catch (CoreException e) {
+            cancelJob.setFinishFlag(true);
+            monitor.done();
+            return false;
+        }
+
+        cancelJob.setFinishFlag(true);
+        monitor.done();
+        
+       PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+       ArrayList<LocalPackage> pkgfiles = launchUtils.getProjectPackages(targetProj, config.getName());
+
+       try {
+               targetProj.refreshLocal(IResource.DEPTH_INFINITE, null );
+        } catch (CoreException e) {
+            e.printStackTrace();
+        }
+       
+       return !pkgfiles.isEmpty();     
+        
+
+       }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java
new file mode 100644 (file)
index 0000000..7ad172a
--- /dev/null
@@ -0,0 +1,12 @@
+package org.tizen.nativeplatform.launch;
+
+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_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$
+       
+
+}
index e6867bb..b9e7a66 100644 (file)
@@ -30,7 +30,9 @@ package org.tizen.nativeplatform.launch;
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
@@ -46,10 +48,14 @@ import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
 import org.eclipse.cdt.launch.LaunchUtils;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
 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.cdt.ui.newui.CDTPropertyManager;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -65,6 +71,9 @@ import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
@@ -75,7 +84,10 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.TwoPaneElementSelector;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.LocalPortChecker;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.nativecommon.build.CommonBuildMessages;
 import org.tizen.nativecommon.build.CommonConfigurationManager;
 import org.tizen.nativecommon.build.CommonProjectDependentBuilder;
 import org.tizen.nativecommon.build.ProjectTypeManager;
@@ -87,6 +99,11 @@ import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativecommon.launch.TizenUIThreadForConfirmMessage;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.build.PlatformProjectPackaging;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
+import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog;
+import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
 import org.tizen.sdblib.IDevice;
 
 public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
@@ -96,12 +113,17 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
     protected int localDebugPort = -1;
     protected ICDISession debugSession;
     protected static final int defaultTimeOut = 60000;
+    private Shell shell;
+    private boolean result;
+       private ArrayList<LocalPackage> BuildSystemPkgs = null;
+       private ArrayList<LocalPackage> DevicePkgs = null;
 
     protected String getPluginID() {
         return Activator.PLUGIN_ID;
     }
 
     public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+       shell = LaunchUIPlugin.getShell();
         if (monitor == null)
             monitor = new NullProgressMonitor();
         try {
@@ -112,9 +134,13 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
 
             verifyDeviceReachability(getProject(config), new SubProgressMonitor(monitor, 8));
             verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 1));
+            
+            if (!fromShortcut(config)) {
+                       verifyExistPackages(config, new SubProgressMonitor(monitor, 1));
+               }            
 
-            if (mode.equals(ILaunchManager.DEBUG_MODE)) {
-                verifyTizenDebianProjectSettings(config);
+            if (mode.equals(ILaunchManager.DEBUG_MODE)) {              
+                verifyTizenDebianProjectSettings(config);                
                 setDebugConfigAttributes(config);
                 setDefaultSourceLocator(launch, config);
                 IBinaryObject exeFile = getBinaryObject(config);
@@ -134,6 +160,22 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
             monitor.done();
         }
     }
+    
+    private boolean fromShortcut(ILaunchConfiguration config) {
+       boolean result = false;
+               try {
+                       ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+                       result = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, false);
+                       if (result) {
+                               wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, !result);
+                               wc.doSave();
+                       }
+               } catch (CoreException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }               
+               return result;         
+    }
 
     protected void processPostDebug(ILaunchConfiguration config)
             throws CoreException {
@@ -156,6 +198,130 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
             }
         }
     }
+    
+    private boolean packagingProject(IProject targetProj, IConfiguration config, IProgressMonitor monitor) {
+       boolean packagingResult = false;
+       
+               packagingResult = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor);
+               
+       if (packagingResult) {
+               DialogUtil.openMessageDialog(shell, CommonBuildMessages.BUILD_RESULT, 
+                               CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);                  
+       } else {
+               DialogUtil.openErrorDialog(shell, CommonBuildMessages.BUILD_RESULT, 
+                               CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
+       }
+        
+        return packagingResult;
+    }
+    
+    private void verifyExistPackages(ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
+       IProject platformProject = getProject(config);
+       IProject appProject = null;
+       final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+       
+               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, "");      
+       ArrayList<String> extraPkgs = 
+                       (ArrayList<String>) config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, new ArrayList<String>());
+       
+       ArrayList<LocalPackage> appPkgs = null;
+       ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();       
+       
+       String buildConfigName = getBuildConfigName(config);
+       IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
+               String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
+               
+       final ArrayList<LocalPackage> platformPkgs = launchUtils.getProjectPackages(platformProject, buildConfigName);          
+               if (platformPkgs.isEmpty()) {
+                       String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" +
+                               "Do you want packaging now ?\n" +
+                               "[%s]", platformProject.getName(), buildConfigName);
+               if (64 == DialogUtil.openQuestionDialog(msg)) {
+                       if (packagingProject(platformProject, buildConfig, new SubProgressMonitor(monitor, 1))) {
+                               platformPkgs.addAll(launchUtils.getProjectPackages(platformProject, buildConfigName));
+                       } else {
+                               if (64 != DialogUtil.openQuestionDialog("Do you want to continue ?")) {
+                                       newCoreException("Canceled", null);
+                               }                                       
+                       }
+               }
+               }
+               
+               packages.addAll(platformPkgs);
+               
+               if (!appProjectName.isEmpty()) {
+                       appProject = launchUtils.getProjectInstance(appProjectName);
+                       appPkgs = launchUtils.getProjectPackages(appProject, buildConfigName);
+                       
+                       if (appPkgs.isEmpty()) {
+                               String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" +
+                                       "Do you want packaging now ?\n" +
+                                       "[%s]", appProject.getName(), buildConfigName);
+                       if (64 == DialogUtil.openQuestionDialog(msg)) {
+                               if (packagingProject(appProject, buildConfig, new SubProgressMonitor(monitor, 1))) {
+                                       appPkgs.addAll(launchUtils.getProjectPackages(appProject, buildConfigName));
+                               } else {
+                                       if (64 != DialogUtil.openQuestionDialog("Do you want to continue ?")) {
+                                               newCoreException("Canceled", null);
+                                       }                                       
+                               }
+                       }
+                       }
+                       
+                       packages.addAll(appPkgs);
+       }
+
+               if (!extraPkgs.isEmpty()) {
+                       packages.addAll(launchUtils.getLocalPackages(extraPkgs));
+               }       
+
+        String path = "";
+        try {
+               path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
+        } catch (SBIException e) {
+            newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
+        }
+        
+        final String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
+        
+               final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+               final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+               
+               launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
+               launchUtils.filterDevicePackages(packages, DevicePkgs, currentDevice, reinstallOp);
+
+               try {                   
+                       monitor.beginTask("Install packages", 4);                       
+                       monitor.subTask("Checking package status");
+
+                       if (selectPkgOp) {
+                               if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+                                       newCoreException("Canceled", null);
+                               }
+                       }
+                       
+                       ArrayList<LocalPackage> selecteBsPkgs = launchUtils.getSelectedPackages(BuildSystemPkgs);
+                       ArrayList<LocalPackage> selecteDvPkgs = launchUtils.getSelectedPackages(DevicePkgs);
+                       
+                       monitor.worked(1);
+                       monitor.subTask("Install packages to rootstrap");
+                       if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {
+                               launchUtils.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1));
+                       }
+                       //monitor.worked(2);
+                       monitor.subTask("Install packages to device");
+                       if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
+                               launchUtils.installPkgsToDevice(selecteDvPkgs, currentDevice, new SubProgressMonitor(monitor, 1));
+                       }
+                       //monitor.worked(3);
+                       monitor.done(); 
+               } catch (InterruptedException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }               
+    }
 
     protected void verifyTizenDebianProjectSettings(ILaunchConfiguration config) throws CoreException {
         String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
@@ -171,6 +337,10 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
     }
     
     protected void verifyBuildConfiguration(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException {
+       
+       monitor.beginTask("Verifying build configuration", 2);
+        monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
+        
         // FIXME : Match by deviceType, not buildTargetArchitecture.
         IProject project = getProject(config);
         String buildConfigName = getBuildConfigName(config);
@@ -186,6 +356,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
             if(!PlatformConfigurationManager.isDeviceArch(buildTargetArchitecture))
                 resolveProblematicConfiguration(config, "armel");
         }
+        monitor.done();
     }
 
     protected void resolveProblematicConfiguration(ILaunchConfiguration config, final String arch) throws CoreException {
@@ -288,7 +459,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
 
     protected void verifyDeviceReachability(IProject project, IProgressMonitor monitor) throws CoreException {
         try {
-            monitor.beginTask(TizenLaunchMessages.PREPARE_TO_LAUNCH, 1);
+            monitor.beginTask(TizenLaunchMessages.PREPARE_TO_LAUNCH, 2);
             monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
 
             currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
@@ -304,7 +475,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
     protected void launchApplicationForRun(ILaunchConfiguration config, ILaunch launch,
             IProgressMonitor monitor) throws CoreException {
         try {
-            monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 10);
+            monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 2);
             monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
             String envCmd = setEnvironments(config);
             String execArg = setArguments(config);
@@ -312,14 +483,15 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
         } catch (Exception e) {
             newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
         } finally {
+               monitor.worked(1);
             monitor.done();
         }
     }
 
     protected void launchApplicationForDebug(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
         try {
-            monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 10);
-            monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
+            monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 1);
+            //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
             launchApplicationWithGDBServer(launch, config, new SubProgressMonitor(monitor, 1));
             launchApplicationWithGDBClient(launch, config, exeFile, new SubProgressMonitor(monitor, 1));
         } finally {
@@ -330,7 +502,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
     protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
         try {
             monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER, 1);
-            monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER);
+            //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER);
             String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
             String gdbserverCmd = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " :" + gdbserverPort;
             String execArg = setArguments(config);
@@ -347,7 +519,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
     protected void launchApplicationWithGDBClient(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
         try {
             monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT, 1);
-            monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT);
+            //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT);
 
             TizenDebugger debugger = new TizenDebugger();
             debugSession = ((ICDIDebugger2)debugger).createSession(launch, exeFile.getPath().toFile(), new SubProgressMonitor(monitor, 1));
@@ -493,16 +665,32 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
         CommonProjectDependentBuilder builder = ProjectTypeManager.getProjectBuilderInstance(getProject(config));        
         String targetID = builder.getTargetID();
 
-        String rootstrapPath = "";
+        String path = "";
         try {
-            rootstrapPath = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
+            path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
         } catch (SBIException e) {
             newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
         }
 
+        String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
         if (!rootstrapPath.equals(""))
             rootstrapPath = rootstrapPath.concat(exePath);
 
         return new Path(rootstrapPath);
     }
+    
+       private boolean openPkgStatusDialog(final ArrayList<LocalPackage> BuildSystemPkgs, final ArrayList<LocalPackage> DevicePkgs) {          
+               SWTUtil.syncExec(new Runnable() {
+            public void run() {
+               ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs);
+                               if (Window.OK  == statusDlg.open()) {
+                                       result = true;
+                               } else {
+                                       result = false;
+                               }
+            }
+        });
+               
+               return result;
+       }
 }
\ No newline at end of file
index 9fab253..ff13eb3 100644 (file)
 */
 package org.tizen.nativeplatform.launch.ui;
 
+import java.util.ArrayList;
+import java.util.List;
+
+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.IBinary;
 import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
+import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
 import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
 import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.cdt.ui.CElementLabelProvider;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+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.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Event;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.MessageBox;
 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.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 
 import org.tizen.common.connection.ConnectionPlugin;
 import org.tizen.common.connection.ui.TizenRemoteFileDialog;
 import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
+import org.tizen.common.util.ImageUtil;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
+import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
 
 import org.tizen.sdblib.FileListingService.FileEntry;
 import org.tizen.sdblib.IDevice;
 
 public class TizenDebianMainTab extends CMainTab {
+//public class TizenDebianMainTab extends AbstractLaunchConfigurationTab {
        private Label fProgLabel;
        private Text fProgText;
+       private Text fAppProjText;
+       private Button fAppProjButton;
+       private Button fReinstallOp;
+       private Button fSelectPkgOp;
+       private TableViewer tableViewer;
        private boolean fSpecifyCoreFile;
+       private ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
+       //private ArrayList<String> packages = new ArrayList<String>();
        private static final String LABEL_TEXT = "Tizen Application Path :";
        private static final String DEFAULT_APP_PATH = "/opt/apps/";
        private static final String REMOTE_BROWSE = "Remote Browse...";
        private static final String SELECT_AN_APPLICATION = "Select an Application";
        private String filePath = "";
+       private String selectedFileList = "";
        
        public TizenDebianMainTab() {
                this(false);
@@ -92,11 +144,16 @@ public class TizenDebianMainTab extends CMainTab {
                createVerticalSpacer(comp, 1);
                createExeFileField(comp, 1);
                createProjectGroup(comp, 1);
+               createAppProjectGroup(comp, 1);
+               createExtraTableGroup(comp);
+               createOptionGroupComposite(comp);
+               
                if (fSpecifyCoreFile)
                        createCoreFileGroup(comp, 1);
                createVerticalSpacer(comp, 1);
        }
-       
+
+
        @Override
        protected String handleBrowseButtonSelected() {
                FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
@@ -107,6 +164,296 @@ public class TizenDebianMainTab extends CMainTab {
                return fileDialog.open();
        }
        
+       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);
+               
+               fReinstallOp = new Button(composite, SWT.CHECK);
+               fReinstallOp.setText("Reinstall if the package is already present");
+               fSelectPkgOp = new Button(composite, SWT.CHECK);
+               fSelectPkgOp.setText("Select packages to be installed");
+               
+               fReinstallOp.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                updateLaunchConfigurationDialog();
+            }
+        });
+               
+               fSelectPkgOp.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent evt) {
+                updateLaunchConfigurationDialog();
+            }
+        });
+       }
+       
+       private void createTableTitleComposite(Composite parent) {
+               Label tableLabel = new Label(parent, SWT.NONE);
+               tableLabel.setText("Additional Packages:");
+       }
+       
+       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);                 
+                       tableColumn.addSelectionListener(new TooltableSelectionAdapter());
+               }               
+                               
+               tableViewer.setLabelProvider(new TableViewerProvider());                
+               tableViewer.setContentProvider(new ArrayContentProvider());
+               tableViewer.setInput(RootstrapManager.getRootstraps());         
+               tableViewer.getTable().addSelectionListener(new SelectionListener() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {                          
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {                           
+                       }
+                       
+               });
+               
+               table.addListener(SWT.Dispose, tableListener);
+               table.addListener(SWT.KeyDown, tableListener);
+               table.addListener(SWT.MouseMove, tableListener);
+               table.addListener(SWT.MouseHover, tableListener);
+       }
+       
+       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.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+               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("Select RPM files");                 
+                       String[] filterExt = { "*.rpm" };
+                       fd.setFilterExtensions(filterExt);
+                       selectedFileList = fd.open();                   
+                       System.out.println(selectedFileList);
+                       PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+                       if (selectedFileList != null) {
+                               String[] files = fd.getFileNames();
+                               String path = fd.getFilterPath();
+                               for (String f : files) {                                        
+                                       String filePath = new Path(path).append(f).toOSString();
+                                       LocalPackage p = launchUtils.getLocalPackage(filePath);
+                                       if (!existsPkg(p)) {
+                                               packages.add(p);
+                                       }
+                               }
+
+                               tableViewer.refresh();
+                               updateLaunchConfigurationDialog();
+                       }
+                       }
+
+                       @Override
+                       public void mouseUp(MouseEvent e) {                             
+                       }
+                       
+               });             
+               
+               Button removeBt = new Button(composite, SWT.PUSH);
+               Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+               removeBt.setImage(removeIcon);
+       }
+       
+       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(LocalPackage pkg) {
+               for (LocalPackage p : packages) {
+                       if (pkg.getPath().equals(p.getPath())) {
+                               return true;                            
+                       }
+               }
+               return false;
+       }
+       
+       private void createAppProjectGroup(Composite parent, int colSpan) {
+               Composite projComp = new Composite(parent, SWT.NONE);
+               GridLayout projLayout = new GridLayout();
+               projLayout.numColumns = 2;
+               projLayout.marginHeight = 0;
+               projLayout.marginWidth = 0;
+               projComp.setLayout(projLayout);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = colSpan;
+               projComp.setLayoutData(gd);
+
+               fProjLabel = new Label(projComp, SWT.NONE);
+               fProjLabel.setText("Test Application Project:"); 
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               fProjLabel.setLayoutData(gd);
+
+               fAppProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+               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();
+                       }
+               });
+
+               fAppProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null); 
+               fAppProjButton.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleAppProjectButtonSelected();
+                               updateLaunchConfigurationDialog();
+                       }
+               });
+       }
+       
+       protected void handleAppProjectButtonSelected() {
+               String currentProjectName = fProjText.getText();
+               ICProject project = chooseCAppProject(currentProjectName);
+               if (project == null) {
+                       return;
+               }
+
+               String projectName = project.getElementName();
+               fAppProjText.setText(projectName);
+               /*
+               if (currentProjectName.length() == 0) {
+                       // New project selected for the first time, set the program name default too.
+                       IBinary[] bins = getBinaryFiles(project);
+                       if (bins != null && bins.length == 1) {                         
+                               fProgText.setText(bins[0].getResource().getProjectRelativePath().toOSString());
+                       }
+               }
+               */
+       }
+       
+       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$                        
+               }
+               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]);
+                       }
+               }
+               return list.toArray(new ICProject[list.size()]);
+       }
+       
        private void createExeFileField(Composite parent, int colSpan) {
                Composite mainComp = new Composite(parent, SWT.NONE);
                GridLayout mainLayout = new GridLayout();
@@ -181,6 +528,8 @@ public class TizenDebianMainTab extends CMainTab {
                configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
                configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
                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)
@@ -191,54 +540,43 @@ public class TizenDebianMainTab extends CMainTab {
        public void initializeFrom(ILaunchConfiguration configuration) {
                updateProgramFromConfig(configuration);
                updateProjectFromConfig(configuration);
+               updateAppProjectFromConfig(configuration);
+               updateExtraTableFromConfig(configuration);
+               updateReinstallOpFromConfig(configuration);
+               updateSelectPkgOpFromConfig(configuration);
                if (fSpecifyCoreFile)
                        updateCoreFromConfig(configuration);
        }
 
        @Override
        public boolean isValid(ILaunchConfiguration config) {
-               setErrorMessage(null);
-               setMessage(null);
-
+               return true;
+       }       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.launch.ui.CMainTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+        */
+       @Override
+       public void performApply(ILaunchConfigurationWorkingCopy config) {
+               String programPath = fProgText.getText().trim();
                String name = fProjText.getText().trim();
-               if (name.length() == 0) {
-                       setErrorMessage(TizenLaunchMessages.TizenMainTab_Project_not_specified);
-                       return false;
-               }
-               if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
-                       setErrorMessage(TizenLaunchMessages.Launch_common_Project_does_not_exist);
-                       return false;
-               }
-               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
-               if (!project.isOpen()) {
-                       setErrorMessage(TizenLaunchMessages.TizenMainTab_Project_must_be_opened);
-                       return false;
-               }
-
-               if (fProgText != null)
-                       name = fProgText.getText().trim();
+               String appProj = fAppProjText.getText().trim();
+               boolean reinstallOp = fReinstallOp.getSelection();
+               boolean selectPkgOp = fSelectPkgOp.getSelection();
+               ArrayList<String> pkgs = new ArrayList<String>();
                
-               if (name.length() == 0) {
-                       setErrorMessage(TizenLaunchMessages.TizenMainTab_Program_not_specified);
-                       return false;
-               }
-               if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
-                       setErrorMessage(TizenLaunchMessages.TizenMainTab_Program_does_not_exist);
-                       return false;
-               }
-
-               //FIXME:: For enabling apply button. but the button is enabled when change more than 2 characters. 
-               try {
-                       ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
-                       wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, name);
-                       wc.doSave();
-               } catch (CoreException ce) {
-                       LaunchUIPlugin.log(ce);
-               }
+               for (LocalPackage p : packages) {
+                       pkgs.add(p.getPath());
+               }       
                
-               return true;
+               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);
        }
-       
+
        @Override
        protected void updateProjectFromConfig(ILaunchConfiguration config) {
                String projectName = EMPTY_STRING;
@@ -254,8 +592,9 @@ public class TizenDebianMainTab extends CMainTab {
        protected void updateProgramFromConfig(ILaunchConfiguration config) {
                if (fProgText != null)
                {
-                       String programName = EMPTY_STRING;
+                       String programName = EMPTY_STRING;                      
                        try {
+                               
                                programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
                        } catch (CoreException ce) {
                                LaunchUIPlugin.log(ce);
@@ -263,4 +602,176 @@ public class TizenDebianMainTab extends CMainTab {
                        fProgText.setText(programName);
                }
        }
+       
+       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);
+       }
+       
+       protected void updateExtraTableFromConfig(ILaunchConfiguration config) {                
+               ArrayList<String> pkgs = null;
+               try {
+                       pkgs = (ArrayList<String>) config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, new ArrayList<String>());
+               } catch (CoreException ce) {
+                       LaunchUIPlugin.log(ce);
+               }
+               PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+               //packages.addAll(launchUtils.getLocalPackages(pkgs));
+               packages = launchUtils.getLocalPackages(pkgs);
+               tableViewer.setInput(packages);
+       }
+       
+       protected void updateReinstallOpFromConfig(ILaunchConfiguration config) {               
+               boolean option = true;
+               try {
+                       option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
+               } catch (CoreException ce) {
+                       LaunchUIPlugin.log(ce);
+               }
+               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);
+       }
+       
+       private class TooltableSelectionAdapter extends SelectionAdapter
+       {
+               public void widgetSelected(SelectionEvent e) {          
+
+                       final int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
+                       tableViewer.getTable().setSortColumn((TableColumn)e.widget);
+                       if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {                                            
+                               tableViewer.getTable().setSortDirection(SWT.UP);
+                       } else {
+                               tableViewer.getTable().setSortDirection(SWT.DOWN);
+                       }                                       
+                       
+                       tableViewer.setSorter(new ViewerSorter() {
+                               public int compare(Viewer viewer, Object e1, Object e2) {                                       
+                                       LocalPackage pkg_1 = (LocalPackage)e1;
+                                       LocalPackage pkg_2 = (LocalPackage)e2;
+                                       
+                                       String fileName_1 = new Path(pkg_1.getPath()).lastSegment();
+                                       String fileName_2 = new Path(pkg_2.getPath()).lastSegment();
+                                       
+                                       switch (column) {
+                                               case 1:                                                                 
+                                                       if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+                                                               return fileName_1.compareTo(fileName_2);
+                                                       } else {
+                                                               return fileName_2.compareTo(fileName_1);
+                                                       }
+                                               default:
+                                                   break;
+                                       }
+                                       return fileName_1.compareTo(fileName_2);
+                               }
+                       });             
+                       
+               }
+       }
+       
+       /* selected package table provider */
+       private class TableViewerProvider extends LabelProvider implements ITableLabelProvider 
+       {
+               @Override
+               public Image getColumnImage(Object element, int columnIndex) {  
+                       return null;
+               }
+
+               @Override
+               public String getColumnText(Object element, int columnIndex) {
+                       if ( element instanceof LocalPackage) {
+                               LocalPackage pkg = (LocalPackage)element;
+                               String file = pkg.getPath();            
+                               String name = new Path(file).lastSegment();
+                               String path = new Path(file).removeLastSegments(1).toOSString();
+                               
+                               switch(columnIndex) {
+                               case 0 :
+                                       return name;                                                                                    
+                               }
+                       }
+                       return null;
+               }
+       }
+       
+       Listener tableListener = new Listener() {
+               Shell tip = null;
+               Label label = null;
+
+               public void handleEvent(Event event) {
+                       switch (event.type) {
+                               case SWT.Dispose:
+                               case SWT.KeyDown:
+                               case SWT.MouseMove: {
+                                       if (tip == null) {
+                                               break;
+                                       }
+                                       tip.dispose();
+                                       tip = null;
+                                       label = null;
+                                       break;
+                               }
+                               case SWT.MouseHover: {
+                                       TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
+                                       if (item != null) {
+                                               if (tip != null && !tip.isDisposed()) {
+                                                       tip.dispose();
+                                               }
+                                               tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
+                                               tip.setLayout(new FillLayout());
+                                               label = new Label(tip, SWT.NONE);
+                                               LocalPackage pkg = (LocalPackage)item.getData();              
+                     
+                                               label.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+                                               label.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+                     
+                                               label.setData("_TABLEITEM", item);
+                                               label.setText(pkg.getPath());
+                                               label.addListener(SWT.MouseExit, labelListener);
+                                               label.addListener(SWT.MouseDown, labelListener);
+                                               Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+                                               Rectangle rect = item.getBounds(0);
+                                               Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
+                                               tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
+                                               tip.setVisible(true);
+                                       }
+                               }
+                       }
+               }
+       };
+      
+      // Implement a "fake" tooltip
+       final Listener labelListener = new Listener() {
+               public void handleEvent(Event event) {
+                       Label label = (Label) event.widget;
+                       Shell shell = label.getShell();
+                       switch (event.type) {
+                               case SWT.MouseDown:
+                                       Event e = new Event();
+                                       e.item = (TableItem) label.getData("_TABLEITEM");
+                                       // Assuming table is single select, set the selection as if
+                                       // the mouse down event went through to the table
+                                       tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
+                                       tableViewer.getTable().notifyListeners(SWT.Selection, e);
+                                       // fall through
+                               case SWT.MouseExit:
+                                       shell.dispose();
+                                       break;
+                       }
+               }
+       };
 }
\ No newline at end of file
index ee1847f..b7720bd 100644 (file)
 */
 package org.tizen.nativeplatform.launch.ui.shortcut;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -42,37 +47,71 @@ import org.eclipse.cdt.debug.internal.ui.launch.CApplicationLaunchShortcut;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.ICDebuggerPage;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
+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.debug.core.sourcelookup.containers.DirectorySourceContainer;
+import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
+import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
 import org.eclipse.debug.ui.DebugUITools;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
 import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
-
-
-
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
 
 public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut {
        private static final String APPLICATION_PATH_INPUT_DIALOG_TITLE = "Input Tizen Application Path";
        private static final String APPLICATION_PATH_INPUT_DIALOG_TEXT = "Input Tizen Application Path : ";
        
+       private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
+       
+       private String programPath = null;
+       private String appProjectName = null;
+       private ArrayList<LocalPackage> packages = null;
+       private boolean reinstallOp = true;
+       private boolean selectPkgOp = true;
+       
+       protected ISourceLookupDirector fLocator;
+       
        public void launch(IProject project, String mode) {
                searchAndLaunch(new Object[] {project}, mode);
        }
@@ -90,6 +129,12 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut
        }
        
        private void searchAndLaunch(final Object[] elements, String mode) {
+               IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+               if (device == null) {
+                       DialogUtil.openErrorDialog(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+                       return;
+               }
+               
                if (elements != null && elements.length > 0) {
                        int nElements = elements.length;
                        for (int i = 0; i < nElements; i++) {
@@ -180,16 +225,36 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut
        }               
 
        protected ILaunchConfiguration createConfiguration(IProject project, ICDebugConfiguration debugConfig, String mode) {
+               
                ILaunchConfiguration config = null;
                try {
-                       String projectName = project.getProjectRelativePath().toString();
                        ILaunchConfigurationType configType = getCLaunchConfigType();
                        ILaunchConfigurationWorkingCopy wc =
                                configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(project.getName()));
-                       String programName = getProgramName();
-                       if (programName != null)
-                               wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName);
                        
+                       if (!setLaunchConfiguration(project)) {
+                               return null;
+                       }
+                       
+                       if (programPath != null) {
+                               wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+                       }
+                       
+                       if (appProjectName != null && !APP_PROJ_DEFAULT_SELECTION.equals(appProjectName)) {
+                               wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, appProjectName);
+                       }
+                       
+                       if (packages != null) {
+                               ArrayList<String> strs = new ArrayList<String>();
+                               for (LocalPackage p : packages) {
+                                       strs.add(p.getPath());
+                               }
+                               wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, strs);                              
+                       }               
+                       
+                       wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
+                       wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
+                       wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
                        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
                        wc.setMappedResources(new IResource[] {project});
                        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
@@ -210,6 +275,7 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut
                        // Load up the debugger page to set the defaults. There should probably be a separate
                        // extension point for this.
                        ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
+                       setSourceContainer(project, wc);
                        page.setDefaults(wc);
                        
                        config = wc.doSave();
@@ -219,7 +285,21 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut
                return config;
        }
        
-       private String getProgramName() throws CoreException {
+       private void newCoreException(String message, Throwable exception) throws CoreException {
+               Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
+               throw new CoreException(status);
+       }
+       
+       @Override
+       protected ILaunchConfigurationType getCLaunchConfigType() {
+               return getLaunchManager().getLaunchConfigurationType("org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType");
+       }
+       
+       
+       private boolean setLaunchConfiguration(IProject project) {
+               IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ;
+        IConfiguration defaultConfig = info.getDefaultConfiguration();
+        
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (window == null) {
                        IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
@@ -227,25 +307,162 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut
                }
                final Shell shell = window.getShell();
                
-               TizenPathInputDialog dlg = new TizenPathInputDialog(shell,
-                                                  APPLICATION_PATH_INPUT_DIALOG_TITLE,
-                                                  APPLICATION_PATH_INPUT_DIALOG_TEXT,
-                                                  null);
-               if (Window.OK == dlg.open())
-                       return dlg.getValue();
-               else
-                       newCoreException(TizenDebianLaunchMessages.OPERATION_CANCELED, null);
-               
-               return null;
+               PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig);
+               PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
+               dlg.create();
+               if (Window.OK == dlg.open()) {
+                       appProjectName = dlg.getAppProjectName();
+                       programPath = dlg.getProgramPath();
+                       packages = dlg.getExtraPackages();
+                       reinstallOp = dlg.getReinstallOp();
+                       selectPkgOp = dlg.getSelectPkgOp();
+                       return true;
+               } else {
+                       return false;
+               }
        }
        
-       private void newCoreException(String message, Throwable exception) throws CoreException {
-               Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
-               throw new CoreException(status);
+       private void setSourceContainer(IProject project, ILaunchConfigurationWorkingCopy configuration) {
+               
+               IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ;
+        IConfiguration config = info.getDefaultConfiguration();
+        String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+        String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+        PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
+        
+               String basePath = rootstrap.getPath().toOSString();
+               String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(basePath);
+               DirectorySourceContainer container = new DirectorySourceContainer(new Path(rootstrapPath), true);
+               MappingSourceContainer mappingContainer = new MappingSourceContainer("Source mapping");
+               MapEntrySourceContainer entry = new MapEntrySourceContainer();
+               String[] infos = getProjectInfo(project);
+               if (infos == null) {
+                       // TODO: error handling
+               }
+               String backend = String.format("/usr/src/debug/%s-%s", infos[0], infos[1]);
+               String local = project.getLocation().toOSString();
+               
+               entry.setBackendPath(new Path(backend));
+               entry.setLocalPath(new Path(local));
+               mappingContainer.addMapEntry(entry);            
+               
+               if (fLocator != null) {
+                       fLocator.dispose();
+                       fLocator = null;                
+               }
+               
+               String memento = null;  
+               String type = null;
+               try{
+                       memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
+                       type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
+                       if (type == null) {
+                               type = configuration.getType().getSourceLocatorId();
+                       }
+               } catch(CoreException e){
+                       return;
+               }       
+               
+               if(type == null) { 
+                       return;
+               }       
+
+               try {
+                       ISourceLocator locator = getLaunchManager().newSourceLocator(type);
+                       if(!(locator instanceof AbstractSourceLookupDirector)) {
+                               // migrate to the new source lookup infrastructure
+                               memento = null; // don't use old memento
+                               type = configuration.getType().getSourceLocatorId();
+                               if(type == null) { 
+                                       return;
+                               }
+                               locator = getLaunchManager().newSourceLocator(type);
+                               if (!(locator instanceof AbstractSourceLookupDirector)) { 
+                                       return;
+                               }               
+                       }
+                       fLocator = (AbstractSourceLookupDirector)locator;                       
+                       if (memento == null) {
+                               fLocator.initializeDefaults(configuration);
+                       } else {                                
+                               fLocator.initializeFromMemento(memento, configuration);                          
+                       }                       
+               } catch (CoreException e) {
+                       return;
+               }               
+               
+               configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
+               configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
+
+               int length = fLocator.getSourceContainers().length;
+               ISourceContainer[] containers = new ISourceContainer[length + 2];
+               containers[0] = mappingContainer;
+               containers[1] = container;
+               containers[2] = fLocator.getSourceContainers()[0];      
+               
+               fLocator.setSourceContainers(containers);               
+
+               try {
+                       configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, fLocator.getMemento());
+                       configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, fLocator.getId());
+               } catch (CoreException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }               
        }
        
-       @Override
-       protected ILaunchConfigurationType getCLaunchConfigType() {
-               return getLaunchManager().getLaunchConfigurationType("org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType");
+       private String[] getProjectInfo(IProject project) {
+               String[] infos = new String[2];
+               String name = null;
+               String version = null;
+               IFolder folder = project.getFolder("packaging");
+               File dir = new File(folder.getLocation().toOSString());
+               File specfile = null;
+               if (dir.exists()) {                     
+                       for (File f : dir.listFiles()) {
+                               if (f.isFile() && f.getName().endsWith(".spec")) {
+                                       specfile = f;
+                                       break;
+                               }
+                       }
+               }
+               
+               try {
+                       BufferedReader in = new BufferedReader(new FileReader(specfile.getPath()));
+                       String s;
+                       
+                       while ((s = in.readLine()) != null ) { 
+                               s = s.trim();
+                               if (s.trim().startsWith("Name:")) {
+                                       String[] arrStr = s.split(":");
+                                       if (arrStr.length == 2) {
+                                               name = arrStr[1].trim();
+                                               continue;
+                                       }
+                               } else if (s.trim().startsWith("Version:")) {
+                                       String[] arrStr = s.split(":");
+                                       if (arrStr.length == 2) {
+                                               version = arrStr[1].trim();
+                                               continue;
+                                       }
+                               }
+                               
+                               if (name != null && version != null) {
+                                       break;
+                               }
+                       }
+               } catch (FileNotFoundException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               
+               if (name != null && version != null) {
+                       infos[0] = name;
+                       infos[1] = version;
+                       return infos;                   
+               } else {
+                       return null;
+               }               
        }
 }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java
new file mode 100644 (file)
index 0000000..8779990
--- /dev/null
@@ -0,0 +1,554 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+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.IStatus;
+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.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+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.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+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.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+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.eclipse.swt.widgets.Text;
+
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.common.util.ImageUtil;
+import org.tizen.nativecommon.build.CommonBuildMessages;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.build.PlatformProjectPackaging;
+import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+
+import org.tizen.sdblib.IDevice;
+
+public class PlatformLaunchSettingAppPage extends WizardPage {
+       
+       private Text text;
+       private TableViewer tableViewer;
+       private FileDialog fd;
+       private Combo projectCombo;
+       private Button reinstallOp;
+       private Button selectPkgOp;
+       private String selectedFileList = "";
+       private Shell shell;
+       
+       private IConfiguration config;
+       private IProject platformProject;
+       private PlatformRootstrap rootstrap;
+       private String rootPath = "";
+       private IDevice device; 
+       private IStatus status;
+       private boolean packagingResult;
+       private ArrayList<LocalPackage> platformPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> appPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> extraPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
+       private ArrayList<String> projectNames = new ArrayList<String>();
+       private HashMap<String, IProject> projectMap = new HashMap<String, IProject>();
+       
+       private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
+
+       protected PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project, IConfiguration config) {
+               super(pageName);
+               
+               setTitle("Setting test application");
+               setDescription("Please select a test application or add RPM files for testing");
+               setPageComplete(true);
+       
+        this.platformProject = project;
+        this.config = config;
+        this.shell = shell;
+        this.device = ConnectionPlugin.getDefault().getCurrentDevice();
+        String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+        String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+        this.rootstrap = RootstrapManager.getRootstrap(rootId);
+        this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
+        
+        setPlatformPackages();
+        setProjectMap();
+       }
+       
+       public void setPlatformPackages() {
+               platformPackages.clear();
+               PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+               platformPackages = launchUtils.getProjectPackages(platformProject, config.getName());
+               
+        if (platformPackages.isEmpty()) {
+               String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" +
+                               "Do you want packaging now ?\n" +
+                               "[%s]", platformProject.getName(), config.getName());
+               if (64 == DialogUtil.openQuestionDialog(msg)) {
+                       if (packagingProject(platformProject)) {
+                               setPlatformPackages();
+                       }
+               }
+        } else {
+               packages.addAll(platformPackages);
+        }      
+       }
+
+       private void setAppPackages(IProject appProj) {
+               appPackages.clear();
+               PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+               appPackages = launchUtils.getProjectPackages(appProj, config.getName());
+               if (appPackages.isEmpty()) {
+               String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" +
+                               "Do you want packaging now ?\n" +
+                               "[%s]", appProj.getName(), config.getName());
+               if (64 == DialogUtil.openQuestionDialog(msg)) {
+                       if (packagingProject(appProj)) {
+                               setAppPackages(appProj);
+                       }
+               }
+        }
+       }
+       
+       private void setProjectMap() {
+               IWorkspace works = ResourcesPlugin.getWorkspace();
+       IProject[] projs = works.getRoot().getProjects();
+       projectNames.add(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("Reinstall if the package is already present");
+               reinstallOp.setSelection(true);
+               selectPkgOp = new Button(composite, SWT.CHECK);
+               selectPkgOp.setText("Select packages to be installed");
+               selectPkgOp.setSelection(true);
+       }
+       
+       private void createTableTitleComposite(Composite parent) {
+               Label tableLabel = new Label(parent, SWT.NONE);
+               tableLabel.setText("Additional Packages:");
+       }
+    
+    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("Test Application 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 (APP_PROJ_DEFAULT_SELECTION.equals(selected)) {
+                       packages.clear();
+                       packages.addAll(platformPackages);
+                       packages.addAll(extraPackages);
+               } else {
+                       IProject proj = projectMap.get(selected);
+                       setAppPackages(proj);
+                               packages.clear();
+                               packages.addAll(platformPackages);
+                               packages.addAll(appPackages);
+                               packages.addAll(extraPackages);                 
+               }
+            }
+
+            @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);                 
+                       //tableColumn.addSelectionListener(new TooltableSelectionAdapter());
+               }               
+                               
+               tableViewer.setLabelProvider(new TableViewerProvider());                
+               tableViewer.setContentProvider(new ArrayContentProvider());
+               packages.addAll(extraPackages);
+               tableViewer.setInput(extraPackages);            
+               tableViewer.getTable().addSelectionListener(new SelectionListener() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {                          
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {                           
+                       }
+                       
+               });
+               
+               table.addListener(SWT.Dispose, tableListener);
+               table.addListener(SWT.KeyDown, tableListener);
+               table.addListener(SWT.MouseMove, tableListener);
+               table.addListener(SWT.MouseHover, tableListener);
+    }
+
+
+       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("Select RPM files");                 
+                       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) {
+                                       LocalPackage p = new LocalPackage();                                    
+                                       p.setPath(new Path(path).append(f).toOSString());
+                                       String name = RPMPackageCommander.getPkgNameForFile(p.getPath());
+                                               p.setName(name);
+                                       extraPackages.add(p);                                           
+                                       //rpmFiles.add(f);
+                               }
+                               //tableViewer.refresh();
+                               packages.clear();
+                               packages.addAll(platformPackages);
+                               packages.addAll(appPackages);     
+                               packages.addAll(extraPackages);
+                               tableViewer.refresh();
+                       }
+                       }
+
+                       @Override
+                       public void mouseUp(MouseEvent e) {                             
+                       }
+                       
+               });             
+               
+               
+               Button removeBt = new Button(composite, SWT.PUSH);
+               Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+               removeBt.setImage(removeIcon);  
+    }
+    
+
+
+       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 = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor);
+                               }
+                           });             
+               } else {        
+                               getContainer().run(true, true,
+                                       new IRunnableWithProgress() {
+                                               public void run(IProgressMonitor monitor)
+                                                               throws InvocationTargetException,
+                                                               InterruptedException {
+                                                       packagingResult = PlatformProjectPackaging.RPMPackaging(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) {
+               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;
+    }
+
+       /* selected package table provider */
+       private class TableViewerProvider extends LabelProvider implements ITableLabelProvider 
+       {
+               @Override
+               public Image getColumnImage(Object element, int columnIndex) {                  
+                       return null;
+               }
+
+               @Override
+               public String getColumnText(Object element, int columnIndex) {
+                       if ( element instanceof LocalPackage) {
+                               LocalPackage p = (LocalPackage)element;                         
+                               String name = new Path(p.getPath()).lastSegment();                              
+                               
+                               switch(columnIndex) {
+                               case 0:
+                                       return name;                                                                            
+                               }
+                       }
+                       return null;
+               }
+       }       
+       
+       public ArrayList<LocalPackage> getPackages() {
+               return packages;
+       }       
+       
+       public ArrayList<LocalPackage> getExtraPackages() {
+               return extraPackages;
+       }
+       
+       public String getRootstrapPath() {
+               return rootPath;
+       }
+       
+       public String getAppProjectName() {
+               return projectCombo.getText().trim();
+       }
+       
+       public boolean getReinstallOp() {
+               return reinstallOp.getSelection();
+       }
+       
+       public boolean getSelectPkgOp() {
+               return selectPkgOp.getSelection();
+       }
+       
+       Listener tableListener = new Listener() {
+               Shell tip = null;
+               Label label = null;
+
+               public void handleEvent(Event event) {
+                       switch (event.type) {
+                               case SWT.Dispose:
+                               case SWT.KeyDown:
+                               case SWT.MouseMove: {
+                                       if (tip == null) {
+                                               break;
+                                       }
+                                       tip.dispose();
+                                       tip = null;
+                                       label = null;
+                                       break;
+                               }
+                               case SWT.MouseHover: {
+                                       TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
+                                       if (item != null) {
+                                               if (tip != null && !tip.isDisposed()) {
+                                                       tip.dispose();
+                                               }
+                                               tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
+                                               tip.setLayout(new FillLayout());
+                                               label = new Label(tip, SWT.NONE);
+                                               LocalPackage pkg = (LocalPackage)item.getData();              
+                     
+                                               label.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+                                               label.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+                     
+                                               label.setData("_TABLEITEM", item);
+                                               label.setText(pkg.getPath());
+                                               label.addListener(SWT.MouseExit, labelListener);
+                                               label.addListener(SWT.MouseDown, labelListener);
+                                               Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+                                               Rectangle rect = item.getBounds(0);
+                                               Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
+                                               tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
+                                               tip.setVisible(true);
+                                       }
+                               }
+                       }
+               }
+       };
+      
+      // Implement a "fake" tooltip
+       final Listener labelListener = new Listener() {
+               public void handleEvent(Event event) {
+                       Label label = (Label) event.widget;
+                       Shell shell = label.getShell();
+                       switch (event.type) {
+                               case SWT.MouseDown:
+                                       Event e = new Event();
+                                       e.item = (TableItem) label.getData("_TABLEITEM");
+                                       // Assuming table is single select, set the selection as if
+                                       // the mouse down event went through to the table
+                                       tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
+                                       tableViewer.getTable().notifyListeners(SWT.Selection, e);
+                                       // fall through
+                               case SWT.MouseExit:
+                                       shell.dispose();
+                                       break;
+                       }
+               }
+       };
+       
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java
new file mode 100644 (file)
index 0000000..de6ca41
--- /dev/null
@@ -0,0 +1,100 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog;
+import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.FileListingService.FileEntry;
+
+public class PlatformLaunchSettingBinPage extends WizardPage {
+       
+       private Text text;
+       private String filePath = "";
+       private static final String SELECT_AN_APPLICATION = "Select an Application";
+       private static final String DEFAULT_APP_PATH = "/opt/apps/";
+       private static final String REMOTE_BROWSE = "Remote Browse...";
+       
+       protected PlatformLaunchSettingBinPage(String pageName) {
+               super(pageName);
+               setTitle("Setting binary path");
+               setDescription("Please set a path for test binary");
+               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);
+        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        text.setLayoutData(data);
+        
+               Button browseButton = new Button(composite, SWT.PUSH);
+               browseButton.setText(REMOTE_BROWSE);
+               browseButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               String path = handleBrowseButtonSelected();
+                               if (path != null) {
+                                       text.setText(path);
+                               }
+                       }
+               });
+               
+               setControl(composite);
+       }
+       
+       protected String handleBrowseButtonSelected() {
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window == null) {
+                       IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+
+               final Shell shell = window.getShell();
+               if (shell != null) {
+                       IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+                       if (device == null) {
+                               MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION);
+                               msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+                               msgBox.open();
+                               return null;
+                       }
+
+                       shell.getDisplay().syncExec( new Runnable() {
+                               public void run() {
+                                       IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+                                       TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, SELECT_AN_APPLICATION, device, false, DEFAULT_APP_PATH);
+                                       if(dlg.open() == TizenRemoteFileDialogResult.OK) {
+                                               FileEntry selectedFile = dlg.getSelectedFileEntry();
+                                               filePath = selectedFile.getFullPath();
+                                       } else
+                                               filePath = null;
+                               }
+                       });
+               }
+               return filePath;
+       }
+       
+       
+       public String getPath() {
+               return text.getText().trim();
+       }
+
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java
new file mode 100644 (file)
index 0000000..54e169f
--- /dev/null
@@ -0,0 +1,381 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+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.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.util.FileUtil;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SdbCommandRejectedException;
+import org.tizen.sdblib.SyncService;
+import org.tizen.sdblib.TimeoutException;
+import org.tizen.sdblib.SyncService.SyncResult;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class PlatformLaunchUtils {
+       
+       public PlatformLaunchUtils() {
+               
+       }
+       
+       public boolean installPkgsToRootstrap(ArrayList<LocalPackage> packages, String rootPath, 
+                       IProgressMonitor monitor) throws InterruptedException {
+               
+               monitor.beginTask("Installing packages to rootstrap", 3);
+               
+               String rpmPathList = "";
+               String localPkgList = "";
+               
+       for (LocalPackage p : packages) {                       
+               String filePath = p.getPath();
+                       String filename = new File(filePath).getName();
+                       String pathOnRootstrap = "/tmp/" + filename;
+                       String copyToPath = rootPath + pathOnRootstrap;
+                       try {
+                               FileUtil.copyTo(filePath, copyToPath);
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+                       rpmPathList = rpmPathList.concat(pathOnRootstrap + " ");
+                       localPkgList = localPkgList.concat(p.getName() + " ");                          
+       }       
+
+       boolean error = false;
+       String log = "";
+       
+       //monitor.subTask("Installing packages..");
+       
+
+       String proxy = PreferencesManager.getProxyURL();
+       RPMPackageCommander.setHttpProxy(proxy);
+       Document doc = RPMPackageCommander.InstallPkgWithZypperXmlOut(rootPath, rpmPathList, true, true);
+       
+               doc.getDocumentElement().normalize();           
+               NodeList messageNodes = doc.getElementsByTagName("message");
+               
+               
+               for (int i = 0; i < messageNodes.getLength() ; i++) {
+                       Node ii = messageNodes.item(i);                 
+                       NamedNodeMap map = ii.getAttributes();          
+                       Node node = map.getNamedItem("type");
+                       if (node != null) {
+                               String type = node.getNodeValue();
+                               if (type.equals("error")) {
+                                       error = true;
+                                       log = log + "[ERROR] " + ii.getFirstChild().getNodeValue() + "\n";
+                               } else {
+                                       log = log + "[INFO] " + ii.getFirstChild().getNodeValue() + "\n";
+                               }
+                       }                       
+               }               
+       
+               if (error) {
+                       newException(log);                      
+               }               
+               monitor.worked(1);
+               
+               monitor.subTask("Checking installed successfully..");
+               String failedInstallPkgs = "";
+               for (LocalPackage p : packages) {
+                       String name = p.getName();
+                       if(!RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(name, rootPath)) {
+                               failedInstallPkgs = failedInstallPkgs + "   - " + name + newline();
+                       }
+               }    
+               
+               if (failedInstallPkgs != "") {
+                       String desc = String.format("Follow package does not installed successfully.\n\n" +
+                                       "%s\n" +
+                                       "See below log.", failedInstallPkgs);
+                       newException(log);
+               }
+               monitor.worked(2);
+               monitor.done();
+
+       return true;            
+       }
+       
+       public boolean installPkgsToDevice(ArrayList<LocalPackage> packages, IDevice device, IProgressMonitor monitor) 
+                       throws InterruptedException {
+               
+               monitor.beginTask("Installing packages to rootstrap", 3);
+               
+               ArrayList<LocalPackage> packagesForDevice = new ArrayList<LocalPackage>();
+       ConsoleManager cm = new ConsoleManager("package manager", true);
+               //cm.clear();
+               MessageConsoleStream mcs = cm.getMessageConsoleStream();
+               PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
+               rec.setMessageConsoleStream(mcs);
+               
+       String localPkgList = "";       
+       
+       for (LocalPackage p : packages) {
+               String file = new File(p.getPath()).getName();
+               
+               if (file.contains("-debugsource") || file.contains("-debuginfo") ||
+                               file.contains("-devel")) {
+                       continue;
+               }
+               
+               packagesForDevice.add(p);
+               
+                       String newPath = "/tmp/" + file;
+                       SyncService syncService;
+                       try {                                   
+                               syncService = device.getSyncService();
+                               SyncResult syncResult = syncService.pushFile(p.getPath(), newPath, SyncService.getNullProgressMonitor());
+                               if (syncResult.getCode() != SyncService.RESULT_OK) {                                    
+                                       continue;
+                               }
+                               
+                               if (localPkgList == "") {
+                                       localPkgList = newPath;
+                               } else {
+                                       localPkgList = localPkgList + " " + newPath;
+                               }                               
+                               
+                       } catch (TimeoutException e) {                          
+                               e.printStackTrace();
+                       } catch (SdbCommandRejectedException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+                       
+       }
+       
+       //monitor.subTask("Installing packages..");     
+       RPMPackageCommander.InstallPkgToDevice(localPkgList, device, rec);      
+       monitor.worked(1);
+       
+       // check to install successfully
+       monitor.subTask("Checking installed successfully..");
+       String failedInstallPkgs = "";
+               for (LocalPackage p : packagesForDevice) {
+                       String name = p.getName();
+                       if(!RPMPackageCommander.pkgInstalledSuccessfullyForDevice(name, device, rec)) {
+                               failedInstallPkgs = failedInstallPkgs + "   - " + name + newline();
+                       }
+               }    
+               
+               if (failedInstallPkgs != "") {
+                       String msg = String.format("Follow package does not installed successfully.\n\n" +
+                                       "%s\n" +
+                                       "You can install package through package manager manually.", failedInstallPkgs);
+                       newException(msg);;
+                       return false;
+               }
+               monitor.worked(2);
+               monitor.done();
+       
+       return true;
+       }
+       
+       private String newline() {              
+               return "\n";
+       }
+
+    protected void newException(String message) throws InterruptedException {
+        //Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
+        //throw new CoreException(status);
+       throw new InterruptedException(message);
+    }
+    
+    public IProject getProjectInstance(String projectName) {
+       IWorkspace works = ResourcesPlugin.getWorkspace();
+       IProject[] projs = works.getRoot().getProjects();
+       IProject result = null;
+       HashMap<String, IProject> projectMap = new HashMap<String, IProject>();         
+       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) &&
+                        projectName.equals(p.getName())) {
+                result = p;
+                break;
+             }
+       }
+       
+       return result;
+    }
+    
+    public ArrayList<LocalPackage> getProjectPackages(IProject project, String configName) {
+       ArrayList<LocalPackage> pkgs = new ArrayList<LocalPackage>();
+       IFolder folder = project.getFolder(configName);
+               File dir = new File(folder.getLocation().toOSString());
+               if (dir.exists()) {                     
+                       for (File f : dir.listFiles()) {
+                               if (f.isFile() && f.getName().endsWith(".rpm")) {       
+                                       IPath pkgPath = new Path(dir.getPath()).append(f.getName());
+                                       LocalPackage pkg = getLocalPackage(pkgPath.toOSString());                                                                       
+                                       pkgs.add(pkg);
+                               }
+                       }
+               }
+               
+               return pkgs;
+    }
+    
+    public LocalPackage getLocalPackage(String pkgfilePath) {          
+       LocalPackage pkg = new LocalPackage();          
+               pkg.setPath(pkgfilePath);                                                       
+               String name = RPMPackageCommander.getPkgNameForFile(pkg.getPath());
+               pkg.setName(name);                                                      
+               return pkg;
+    }
+    
+    public ArrayList<LocalPackage> getLocalPackages(ArrayList<String> pkgPaths) {
+       ArrayList<LocalPackage> pkgs = new ArrayList<LocalPackage>();
+       for (String path : pkgPaths) {
+               LocalPackage pkg = getLocalPackage(path);
+               pkgs.add(pkg);
+       }
+                                                               
+               return pkgs;
+    }
+    
+       public void filterBuildsystemPkgs(ArrayList<LocalPackage> totalPackages,
+                       ArrayList<LocalPackage> buildsystePkgs, String rootstrapPath, boolean reinstallOp) {
+               for (LocalPackage pkg : totalPackages) {                
+                       buildsystePkgs.add(pkg.clone());
+               }               
+               
+               updateBuildsystemPkgs(buildsystePkgs, rootstrapPath, reinstallOp);              
+       }
+       
+       public void filterDevicePackages(ArrayList<LocalPackage> totalPackages,
+                       ArrayList<LocalPackage> devicePkgs, IDevice device, boolean reinstallOp) {
+
+               for (LocalPackage pkg : totalPackages) {                        
+                       String name = pkg.getName();
+                       if (name.contains("-debugsource") || name.contains("-debuginfo") ||
+                                       name.contains("-devel")) {
+                               continue;
+               } else {
+                       devicePkgs.add(pkg.clone());
+               }
+               }
+
+               updateDevicePkgs(devicePkgs, device, reinstallOp);
+       }
+       
+       private void updateBuildsystemPkgs(ArrayList<LocalPackage> pkgs, String rootstrapPath,
+                        boolean reinstallOp) {
+               for (LocalPackage pkg : pkgs) {
+                       String newVer = RPMPackageCommander.getPkgVerForFile(pkg.getPath());
+                       String arch = RPMPackageCommander.getArchForFile(pkg.getPath());
+                       String installedVerForRootstrap = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), rootstrapPath);
+                       
+                       pkg.setNewVersion(newVer);
+                       pkg.setArch(arch);
+                       pkg.setInstalledVersion(installedVerForRootstrap);
+                       
+                       pkg.setCheckColumn(true);
+                       
+                       if ("".equals(newVer)) {
+                               pkg.setCheckColumn(false);
+                       } else if (!"".equals(installedVerForRootstrap)) {
+                               if (!installedVerForRootstrap.equals(newVer)) {
+                                       pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
+                               } else {
+                                       if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), rootstrapPath)) {
+                                               pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
+                                               if (!reinstallOp) {
+                                                       pkg.setCheckColumn(false);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       private void updateDevicePkgs(ArrayList<LocalPackage> pkgs, IDevice device,
+                        boolean reinstallOp) {
+               PackageManagerOuputReceiver rec = getNewOuputReceiver();
+               
+               for (LocalPackage pkg : pkgs) {
+                       String newVer = RPMPackageCommander.getPkgVerForFile(pkg.getPath());
+                       String arch = RPMPackageCommander.getArchForFile(pkg.getPath());
+                       String installedVer = RPMPackageCommander.getPkgInstalledVerForDevice(pkg.getName(), device, rec);
+                       
+                       pkg.setNewVersion(newVer);
+                       pkg.setArch(arch);
+                       pkg.setInstalledVersion(installedVer);
+                       
+                       pkg.setCheckColumn(true);
+                       
+                       if ("".equals(newVer)) {
+                               pkg.setCheckColumn(false);
+                       } else if (!"".equals(installedVer)) {
+                               if (!installedVer.equals(newVer)) {
+                                       pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
+                               } else {
+                                       if (RPMPackageCommander.pkgInstalledSuccessfullyForDevice(pkg.getName(), device, rec)) {
+                                               pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
+                                               if (!reinstallOp) {
+                                                       pkg.setCheckColumn(false);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       public ArrayList<LocalPackage> getSelectedPackages(ArrayList<LocalPackage> pkgs) {
+               ArrayList<LocalPackage> selectedPkgs = new ArrayList<LocalPackage>();
+               for (LocalPackage pkg : pkgs) {
+                       if (pkg.getCheckColumn()) {
+                               selectedPkgs.add(pkg);
+                       }
+               }
+               
+               return selectedPkgs;
+       }
+       
+       
+       private PackageManagerOuputReceiver getNewOuputReceiver() {
+               ConsoleManager cm = new ConsoleManager("debug launch", true);
+               cm.clear();
+               MessageConsoleStream mcsError = cm.getMessageConsoleStream();
+               MessageConsoleStream mcs = cm.getMessageConsoleStream();
+               PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
+               rec.setMessageConsoleStream(mcs);
+
+               return rec;
+       }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java
new file mode 100644 (file)
index 0000000..8017b86
--- /dev/null
@@ -0,0 +1,214 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+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.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.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.connection.ConnectionPlugin;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.sdblib.IDevice;
+
+public class PlatformLaunchWizard extends Wizard implements IPageChangingListener, IPageChangedListener {
+       
+       private IProject project;
+       private IConfiguration config;
+       private IDevice device; 
+       private Shell shell;
+       private String programPath = "";
+       private String appProjectName = "";
+       boolean reinstallOp;
+       boolean selectPkgOp;
+       private ArrayList<LocalPackage> packages =  new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> extraPackages =  new ArrayList<LocalPackage>();
+       private String appProject = ""; 
+       private boolean result;
+       
+       private final String SETTING_APP_PAGE = "setting_app";
+       private final String SETTING_BIN_PAGE = "setting_bin";
+       
+       public PlatformLaunchWizard() {                         
+       }
+       
+       public PlatformLaunchWizard(Shell shell, IProject project, IConfiguration config) {
+               this.project = project;
+               this.config = config;
+               this.shell = shell;
+               this.device = ConnectionPlugin.getDefault().getCurrentDevice();
+               setWindowTitle("Launch Configuration");
+               setNeedsProgressMonitor(true);          
+       }
+
+       @Override
+       public boolean needsProgressMonitor() {
+               // TODO Auto-generated method stub
+               //return super.needsProgressMonitor();
+               return true;
+       }
+
+       @Override
+       public boolean performFinish() {
+               PlatformLaunchSettingBinPage binPage = (PlatformLaunchSettingBinPage)getPage(SETTING_BIN_PAGE);
+               programPath = binPage.getPath();
+               
+               PlatformLaunchSettingAppPage appPage = (PlatformLaunchSettingAppPage)getPage(SETTING_APP_PAGE);
+               appProjectName = appPage.getAppProjectName();
+               extraPackages = appPage.getExtraPackages();             
+               
+               return true;
+       }
+       
+       public String getProgramPath() {
+               return programPath;
+       }
+       
+       public ArrayList<LocalPackage> getPackages() {
+               return packages;
+       }
+       
+       public ArrayList<LocalPackage> 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));
+               addPage(new PlatformLaunchSettingBinPage(SETTING_BIN_PAGE));
+               
+               WizardDialog dialog = (WizardDialog)getContainer();
+               dialog.addPageChangedListener(this);
+               dialog.addPageChangingListener(this);
+       }
+
+       @Override
+       public void pageChanged(PageChangedEvent event) {
+               
+               Object a = event.getSelectedPage();             
+       }
+
+       @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;
+                       final String rootstrapPath = page.getRootstrapPath();                   
+                       packages = page.getPackages();
+                       IWizardContainer container = getContainer();
+                       final PlatformLaunchUtils launchUtil = new PlatformLaunchUtils();
+                       final IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+                       reinstallOp = page.getReinstallOp();
+                       selectPkgOp = page.getSelectPkgOp();            
+                       
+                       //container.run(fork, cancelable, runnable)                     
+                       
+                       try {
+                               container.run(true, true,
+                                       new IRunnableWithProgress() {
+                                               public void run(IProgressMonitor monitor)
+                                                               throws InvocationTargetException,
+                                                               InterruptedException {
+                                                       monitor.beginTask("Install packages", 3);
+                                                       monitor.subTask("Checking package status");
+                                                       
+                                                       final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+                                                       final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+                                                       
+                                                       launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
+                                                       launchUtil.filterDevicePackages(packages, DevicePkgs, device, reinstallOp);
+                                                       
+                                                       if (selectPkgOp) {
+                                                               if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+                                                                       cancelChanging(event);
+                                                                       return;
+                                                               }
+                                                       }
+                                                       
+                                                       ArrayList<LocalPackage> selecteBsPkgs = launchUtil.getSelectedPackages(BuildSystemPkgs);
+                                                       ArrayList<LocalPackage> selecteDvPkgs = launchUtil.getSelectedPackages(DevicePkgs);
+                                                       
+                                                       monitor.worked(1);                      
+                                                       monitor.subTask("Installing packages to rootstrap");
+                                                       
+                                                       if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {                                                        
+                                                               launchUtil.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1));
+                                                       }
+                                                       //monitor.worked(2);
+                                                       monitor.subTask("Installing packages to device");
+                                                       if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
+                                                               launchUtil.installPkgsToDevice(selecteDvPkgs, device, new SubProgressMonitor(monitor, 1));
+                                                       }
+                                                       //monitor.worked(3);
+                                                       monitor.done();                                         
+                                               }                                       
+                               });
+                       } catch (InvocationTargetException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       } catch (InterruptedException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                               String desc = "Failed to install packages. See below logs";                             
+                               openLogDialog(desc, e.getMessage());                                            
+                               cancelChanging(event);
+                       }
+               }               
+       }
+       
+       private void cancelChanging(PageChangingEvent event) {          
+               event.doit = false;
+       }
+
+       private void openLogDialog(final String desc, final String log) {
+               SWTUtil.syncExec(new Runnable() {
+            public void run() {
+               ShowLogDialog dialog = new ShowLogDialog(shell, desc, log);
+                dialog.open();
+            }
+        });
+       }
+               
+       private boolean openPkgStatusDialog(final ArrayList<LocalPackage> BuildSystemPkgs, final ArrayList<LocalPackage> DevicePkgs) {          
+               SWTUtil.syncExec(new Runnable() {
+            public void run() {
+               ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs);
+                               if (Window.OK  == statusDlg.open()) {
+                                       result = true;
+                               } else {
+                                       result = false;
+                               }
+            }
+        });
+               
+               return result;
+       }
+
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java
new file mode 100644 (file)
index 0000000..a515ccc
--- /dev/null
@@ -0,0 +1,58 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+
+public class PlatformLaunchWizardDialog extends WizardDialog {
+       
+       private PlatformLaunchWizard wizard = null;
+       
+       public PlatformLaunchWizardDialog(Shell shell, PlatformLaunchWizard wizard) {   
+               super(shell, wizard);   
+               
+               this.wizard = wizard;   
+       }
+       
+       public String getProgramPath() {
+               if (wizard != null) {
+                       return wizard.getProgramPath();
+               } else {
+                       return null;
+               }
+       }
+       
+       public ArrayList<LocalPackage> getExtraPackages() {
+               if (wizard != null) {
+                       return wizard.getExtraPackages();
+               } else {
+                       return null;
+               }
+       }
+       
+       public String getAppProjectName() {
+               if (wizard != null) {
+                       return wizard.getAppProjectName();
+               } else {
+                       return null;
+               }
+       }
+       
+       public boolean getReinstallOp() {
+               if (wizard != null) {
+                       return wizard.getReinstallOp();
+               } else {
+                       return true;
+               }
+       }
+       
+       public boolean getSelectPkgOp() {
+               if (wizard != null) {
+                       return wizard.getSelectPkgOp();
+               } else {
+                       return true;
+               }
+       }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowLogDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowLogDialog.java
new file mode 100644 (file)
index 0000000..17de81f
--- /dev/null
@@ -0,0 +1,83 @@
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class ShowLogDialog extends Dialog {
+       
+       private int x = 0;
+       private int y = 0;
+       private final int width = 700;
+       private final int height = 500;
+       private Shell shell;
+       private String desc = "";
+       private String log = "";
+
+       protected ShowLogDialog(Shell parentShell, String desc, String log) {
+               super(parentShell);
+               this.shell = parentShell;
+               Rectangle bounds = parentShell.getBounds();
+        x = bounds.x + (bounds.width - width)/2;
+        y = bounds.y + (bounds.height - height)/2;
+        
+        this.desc = desc;
+        this.log = log;
+       }
+       
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);         
+               
+               newShell.setText("Show Log");           
+               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));       
+
+        createDescComposite(composite);      
+        createTextAreaComposite(composite);                
+               return null;
+       }
+       
+       private void createDescComposite(Composite parent) {
+               
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               composite.setLayout(new GridLayout(1, false));
+               
+               Label message = new Label(composite, SWT.NONE);
+               message.setText(desc);
+       }
+       
+       private void createTextAreaComposite(Composite parent) {
+               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);
+       }
+
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java
new file mode 100644 (file)
index 0000000..d58fd2d
--- /dev/null
@@ -0,0 +1,319 @@
+package org.tizen.nativeplatform.launch.wizards;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+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.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+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.eclipse.ui.console.MessageConsoleStream;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.sdblib.IDevice;
+
+public class ShowPackageStatusDialog extends Dialog {
+       
+       private int x = 0;
+       private int y = 0;
+       private final int width = 800;
+       private final int height = 700;
+       private Shell shell;    
+       private String rootstrapPath = "";
+       private IDevice device;
+       
+       
+       private TableViewer bsViewer;
+       private TableViewer dvViewer;
+       private ArrayList<LocalPackage> bsPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> dvPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> selectedBsPackages = new ArrayList<LocalPackage>();
+       private ArrayList<LocalPackage> selectedDvPackages = new ArrayList<LocalPackage>();     
+       
+       private ArrayList<LocalPackage> packages;
+
+       public ShowPackageStatusDialog(Shell parentShell, 
+                       ArrayList<LocalPackage> bsPkgs, ArrayList<LocalPackage> dvPkgs) {
+               super(parentShell);
+               this.shell = parentShell;
+               Rectangle bounds = parentShell.getBounds();
+        x = bounds.x + (bounds.width - width)/2;
+        y = bounds.y + (bounds.height - height)/2;
+
+        this.bsPackages = bsPkgs;
+        this.dvPackages = dvPkgs;
+       }
+       
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);         
+               
+               newShell.setText("Select packages to be installed");            
+               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));  
+
+        createDescComposite(composite);      
+        createBuildSystemLabelComposite(composite);
+        createBuildSystemComposite(composite);
+        createDeviceLabelComposite(composite);
+        createDeviceComposite(composite);
+        tableRefresh();
+               return null;
+       }
+       
+       private void createDescComposite(Composite parent) {
+               
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               composite.setLayout(new GridLayout(1, false));
+               
+               Label message = new Label(composite, SWT.NONE);
+               message.setText("Checked packages will be installed to buildsystem and device");
+       }
+       
+       @Override
+       protected void okPressed() {
+               selectedBsPackages.clear();
+               selectedDvPackages.clear();
+               
+               int recentTableIndex = bsViewer.getTable().getItemCount();
+               for (int i = 0; i < recentTableIndex; i++) {
+                       TableItem item = null;
+                       item = bsViewer.getTable().getItem(i);
+                       LocalPackage pkg = (LocalPackage)item.getData();
+                       if (pkg.getCheckColumn()) {
+                               selectedBsPackages.add(pkg);
+                       }
+               }
+               
+               recentTableIndex = dvViewer.getTable().getItemCount();
+               for (int i = 0; i < recentTableIndex; i++) {
+                       TableItem item = null;
+                       item = dvViewer.getTable().getItem(i);
+                       LocalPackage pkg = (LocalPackage)item.getData();
+                       if (pkg.getCheckColumn()) {
+                               selectedDvPackages.add(pkg);
+                       }
+               }               
+               
+               super.okPressed();
+       }
+
+       @Override
+       protected void cancelPressed() {
+               super.cancelPressed();
+       }
+       
+       public ArrayList<LocalPackage> getSelectedBsPkgs() {
+               return selectedBsPackages;
+       }
+       
+       public ArrayList<LocalPackage> getSelectedDvPkgs() {
+               return selectedDvPackages;
+       }
+
+       private void createBuildSystemLabelComposite(Composite parent) {
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               composite.setLayout(new GridLayout(1, false));
+               
+               Label tableDesc = new Label(composite, SWT.NONE);
+               tableDesc.setText("To Buildsystem : ");
+       }
+       
+       private void createBuildSystemComposite(Composite parent) {
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               composite.setLayout(new FillLayout());
+               
+               bsViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
+        createColumns( composite, bsViewer);
+        Table packageTable = bsViewer.getTable();
+        packageTable.addListener( SWT.Selection, new Listener(){
+
+                       @Override
+                       public void handleEvent(Event event) {
+                               if( event.detail == SWT.CHECK )
+                               {
+                                       Package pkg = (Package)event.item.getData();
+                                       pkg.setCheckColumn( !pkg.getCheckColumn() );
+                               }
+                       }
+               });
+
+        packageTable.setHeaderVisible(true);
+        packageTable.setLinesVisible(true);
+
+        bsViewer.setContentProvider(new ArrayContentProvider());
+        bsViewer.setInput(bsPackages);
+       }
+
+       private void createDeviceLabelComposite(Composite parent) {
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               composite.setLayout(new GridLayout(1, false));
+               
+               Label tableDesc = new Label(composite, SWT.NONE);
+               tableDesc.setText("To Device : ");
+       }
+       
+       private void createDeviceComposite(Composite parent) {
+               Composite composite = new Composite( parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               composite.setLayout(new FillLayout());
+               
+               dvViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
+        createColumns( composite, dvViewer);
+        Table packageTable = dvViewer.getTable();
+        packageTable.addListener( SWT.Selection, new Listener(){
+
+                       @Override
+                       public void handleEvent(Event event) {
+                               if( event.detail == SWT.CHECK )
+                               {
+                                       Package pkg = (Package)event.item.getData();
+                                       pkg.setCheckColumn( !pkg.getCheckColumn() );
+                                       boolean b = pkg.getCheckColumn();
+                               }
+                       }
+               });
+
+        packageTable.setHeaderVisible(true);
+        packageTable.setLinesVisible(true);
+
+        dvViewer.setContentProvider(new ArrayContentProvider());
+        dvViewer.setInput(dvPackages);
+       }
+       
+       protected void createButtonsForButtonBar(Composite parent) 
+       {
+               createButton(parent, IDialogConstants.OK_ID, "Continue", true);
+               createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+       }       
+       
+       private void createColumns( Composite parent, TableViewer viewer )
+       {
+               String[] titles = {"Package Name", "Arch", "New Version", "Installed Version", "Status"};
+               int[] bounds = {250, 60, 150, 150, 150};
+
+               TableViewerColumn colPackage = createTableViewerColumn( viewer, titles[0], bounds[0], SWT.NONE);
+
+               colPackage.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               Package pkg = (Package)element;
+                               return pkg.getName();
+                       }
+               });
+
+               TableViewerColumn colArch = createTableViewerColumn( viewer, titles[1], bounds[1], SWT.NONE);
+
+               colArch.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               Package pkg = (Package)element;
+                               String arch = pkg.getArch();
+                               return arch;
+                       }
+               });
+
+               TableViewerColumn colNewVer = createTableViewerColumn( viewer, titles[2], bounds[2], SWT.NONE);
+
+               colNewVer.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               Package pkg = (Package)element;
+                               String newVer = pkg.getNewVersion();
+                               return newVer;
+                       }
+               });
+
+               TableViewerColumn colInsVer = createTableViewerColumn( viewer, titles[3], bounds[3], SWT.NONE);
+               colInsVer.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               Package pkg = (Package)element;
+                               String installedVer = pkg.getInstalledVersion();
+                               return installedVer;
+                       }
+               });
+
+               TableViewerColumn colStatus = createTableViewerColumn( viewer, titles[4], bounds[4], SWT.NONE);
+
+               colStatus.setLabelProvider(new ColumnLabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               Package pkg = (Package)element;
+                               String status = pkg.getInstallInfo().toString();
+                               return status;
+                       }
+               });
+       }
+       
+       private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) {
+
+               final TableViewerColumn viewerColumn = new TableViewerColumn( viewer,   Style);
+               final TableColumn column = viewerColumn.getColumn();            
+               //column.addSelectionListener(new PackageTableSelectionAdapter(bsViewer));
+               column.setText(title);
+               column.setWidth(bound);
+               column.setResizable(true);
+               column.setMoveable(true);
+               return viewerColumn;
+       }
+       
+       private PackageManagerOuputReceiver getNewOuputReceiver() {
+               ConsoleManager cm = new ConsoleManager("debug launch", true);
+               cm.clear();
+               MessageConsoleStream mcsError = cm.getMessageConsoleStream();
+               MessageConsoleStream mcs = cm.getMessageConsoleStream();
+               PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
+               rec.setMessageConsoleStream(mcs);
+
+               return rec;
+       }
+       
+       private void tableRefresh() {
+               int recentTableIndex = bsViewer.getTable().getItemCount();
+               for (int i = 0; i < recentTableIndex; i++) {
+                       TableItem item = null;
+                       item = bsViewer.getTable().getItem(i);
+                       Package pkg = (Package)item.getData();
+                       item.setChecked(pkg.getCheckColumn());
+               }
+               
+               recentTableIndex = dvViewer.getTable().getItemCount();
+               for (int i = 0; i < recentTableIndex; i++) {
+                       TableItem item = null;
+                       item = dvViewer.getTable().getItem(i);
+                       Package pkg = (Package)item.getData();
+                       item.setChecked(pkg.getCheckColumn());
+               }
+       }
+
+}
index a53dfbf..34ecd2a 100644 (file)
 */
 package org.tizen.nativeplatform.pkgmgr;
 
+import java.io.IOException;
+import java.io.StringReader;
 import java.util.ResourceBundle;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.tizen.common.util.HostUtil;
 import org.tizen.nativecommon.build.exception.SBIException;
 import org.tizen.nativeplatform.password.SudoPasswdManager;
 import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
 import org.tizen.sdblib.IDevice;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 public class RPMPackageCommander {
 
        private final static int MAX_TIMEOUT = 10000;
        private static String http_proxy = "";  
+       private static final String REMOVE_PKGS = "rpm-x86-arm";
+       private static final String NODEPS_OPTION = "--nodeps";
        
        private static final String BUNDLE_NAME = RPMPackageCommander.class.getPackage().getName() + ".RPMPackageCommands";
        private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
@@ -51,6 +63,8 @@ public class RPMPackageCommander {
        }       
 
        public static void DistUpgradeRootstrap(String path) {
+               
+               actionBeforeUseZypper(path);
 
                String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getDistUpgradeCmd());
                String command = getCommand(path, cmd);
@@ -76,7 +90,53 @@ public class RPMPackageCommander {
                }                               
        }
        
-       public static void UninstallPkgFromRootstrap(String fileList, String option, String path) throws SBIException {         
+       public static Document InstallPkgWithZypperXmlOut(String path, String pkgs, boolean refresh, boolean force) {
+               String log = "";
+               if (refresh) {
+                       refreshRepositoryForRootstrap(path);
+               }
+               String basicOp = "--xmlout --non-interactive";
+               String additionOp = "";
+               if (force) {
+                       additionOp = "--force";
+               }
+               String cmd = String.format("%s;%s", getProxyCmd(), getInstallPkgWithZypper(basicOp, additionOp, pkgs));
+               String command = getCommand(path, cmd);
+               
+               try {
+                       log = HostUtil.returnExecute(command, null, true);              
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               
+               if (log.contains("<?xml")) {
+                       int index = log.indexOf("<?xml");
+                       log = log.substring(index);
+               }
+               
+               Document doc = null;
+               StringReader sr = new StringReader(log);
+               InputSource is = new InputSource(sr);
+               DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+               DocumentBuilder db;
+               try {
+                       db = dbf.newDocumentBuilder();
+                       doc = db.parse(is);
+               } catch (ParserConfigurationException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (SAXException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+               return doc;
+       }
+       
+       public static void UninstallPkgFromRootstrap(String fileList, String option, String path) {             
 
                String cmd = String.format("%s;%s", getResetDbCmd(), getUninstallPkgCmd(fileList, option));             
                String command = getCommand(path, cmd);
@@ -354,7 +414,7 @@ public class RPMPackageCommander {
                String command = getCommand(path, cmd);
                
        try {
-                       result = HostUtil.returnExecute(command, "test");
+                       result = HostUtil.returnExecute(command);
                
                } catch (Exception e) {
                        // TODO Auto-generated catch block
@@ -390,7 +450,7 @@ public class RPMPackageCommander {
                String command = getCommand(path, cmd);
                
        try {
-                       result = HostUtil.returnExecute(command, "test");
+                       result = HostUtil.returnExecute(command);
                
                } catch (Exception e) {
                        // TODO Auto-generated catch block
@@ -419,7 +479,9 @@ public class RPMPackageCommander {
                return result;          
        }
        
-       public static String installRemotePkgForRootstrap(String pkgList, String path) {
+       public static String installRemotePkgForRootstrap(String pkgList, String path) {                
+
+               actionBeforeUseZypper(path);
                
                String result = "";     
                String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList));      
@@ -464,6 +526,12 @@ public class RPMPackageCommander {
                }                       
        }
        
+       private static void actionBeforeUseZypper(String path) {
+               if (pkgInstalledSuccessfullyForRootstrap(REMOVE_PKGS, path)) {
+                       UninstallPkgFromRootstrap(REMOVE_PKGS, NODEPS_OPTION, path);
+               }
+       }
+       
        private static String getProxyCmd() {
                return String.format(resources.getString("Command.Export.Proxy"), http_proxy);
        }
@@ -525,6 +593,11 @@ public class RPMPackageCommander {
                return String.format(resources.getString("Command.Info.Pkg.File"), tag, name);
        }
        
+       private static String getInstallPkgWithZypper(String basicOp, String additionOp, String pkgs) {
+               return String.format(resources.getString("Command.Install.Pkg.WithZypper"), 
+                               basicOp, additionOp, pkgs);
+       }
+       
        private static String getCommand(String path, String cmd) {
                String passwd = SudoPasswdManager.getSudoPassword();
                return String.format("sh -c \'echo %s | sudo -S chroot %s sh -c \"%s\"\'", passwd, path, cmd);          
index 0530a36..90b51be 100644 (file)
@@ -14,6 +14,7 @@ Command.Show.Info.Pkg = rpm -qi %s
 Command.Info.Pkg.File = rpm -qp --qf "%%{%s}\n" %s
 Command.Change.Updatemode = /bin/change-booting-mode.sh --update
 Command.DistUpgrade = zypper --non-interactive dup
+Command.Install.Pkg.WithZypper = zypper %s in %s %s
 
 PkgMgr.Error.Noselected.Project = No project selected. Select a Tizen platform project.
 PkgMgr.Error.Not.Platformproject = The selected project is not a Tizen platform project.
index 5550054..5666549 100644 (file)
@@ -15,4 +15,17 @@ public class LocalPackage extends Package {
        public void setPath(String path) {
                this.path = path;
        }
+       
+       public LocalPackage clone() {
+               LocalPackage newPkg = new LocalPackage();
+               newPkg.setArch(this.getArch());
+               newPkg.setCheckColumn(this.getCheckColumn());
+               newPkg.setInstalledVersion(this.getInstalledVersion());
+               newPkg.setInstallInfo(this.getInstallInfo());
+               newPkg.setName(this.getName());
+               newPkg.setNewVersion(this.getNewVersion());
+               newPkg.setPath(this.getPath());
+               newPkg.setPkgType(this.getPkgType());
+               return newPkg;
+       }
 }
index 7e370aa..c45e4b8 100644 (file)
@@ -8,7 +8,9 @@ import java.util.ResourceBundle;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
 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;
@@ -80,13 +82,14 @@ public class BuildSystemTab {
                this.shell = shell;
                this.folder = folder;
                this.rootstrap = rootstrap;
-               this.rootstrapPath = rootstrap.getPath().toOSString();
+               this.rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());              
                this.arch = rootstrap.getArch();
                this.project = CurrentEnabledProject.getCurrentProject();
        }
 
        public void createTab() {
                initialize();
+               
                createBuildsystemTab(folder);
        }
 
@@ -110,6 +113,50 @@ public class BuildSystemTab {
 
                        RepositoryProvider.INSTANCE.getBuildsystemRepos().add(repo);
                }
+               
+               boolean dirty = false;          
+               
+               for (String r : rootstrap.getRepositoryURLs()) {
+                       if (!existRepoUrl(r.trim())) {
+                               dirty = true;
+                               RPMPackageCommander.addRepositoryForRootstrap(getAvailableRepoName(), r, rootstrapPath);
+                       }                       
+               }
+               
+               if (dirty) {
+                       initialize();
+               }
+               
+       }
+       
+       private boolean existRepoUrl(String r) {
+               for (Repository repo : RepositoryProvider.INSTANCE.getBuildsystemRepos()) {
+                       if (r.equals(repo.getUri().trim())) {
+                               return true;
+                       }
+               }
+               
+               return false;
+       }
+       
+       private boolean existRepoName(String n) {
+               for (Repository repo : RepositoryProvider.INSTANCE.getBuildsystemRepos()) {
+                       if (n.equals(repo.getName().trim())) {
+                               return true;
+                       }
+               }
+               
+               return false;
+       }
+       
+       private String getAvailableRepoName() {
+               String namePrefix = "url";
+               for (int i=0 ; ; i++) {
+                       String name = namePrefix + String.valueOf(i);
+                       if (!existRepoName(name)) {
+                               return name;
+                       }                               
+               }
        }
 
        private void createBuildsystemTab( TabFolder parent )
@@ -295,7 +342,7 @@ public class BuildSystemTab {
                                        if (repo.getCheckDirty()) {
                                                list.remove(selectedRepo);                                              
                                                RPMPackageCommander.removeRepositoryForRootstrap(selectedRepo.getName(), rootstrapPath);                                                
-                                               RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), rootstrapPath);
+                                               RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), rootstrapPath);                                            
                                                repo.setCheckDirty(false);
                                        }
                                }
index 1a22326..a5ebe63 100644 (file)
@@ -251,16 +251,9 @@ public class RemoveInstalledPackageDialog extends Dialog {
                        
                                
                                                monitor.beginTask(resources.getString("UninstallPkg.Message.Uninstalling.Package") + 
-                                                               "   " + list, -1);
-                       
-                                               try {
-                                                               RPMPackageCommander.UninstallPkgFromRootstrap(list, options, rootstrapPath);
-                                                       } catch (SBIException e) {
-                                                               DialogUtil.openErrorDialog(getShell(), 
-                                                                               resources.getString("UninstallPkg.Uninstall.Failed.Title"), 
-                                                                               e.getMessage());
-                                                               return;
-                                                       }
+                                                               "   " + list, -1);                      
+
+                                                       RPMPackageCommander.UninstallPkgFromRootstrap(list, options, rootstrapPath);
                                                        
                                                DialogUtil.openMessageDialog(getShell(), 
                                                                resources.getString("UninstallPkg.Uninstall.Success.Title"), 
index a70599e..b2b8849 100644 (file)
@@ -465,7 +465,7 @@ public class RootstrapManager {
                }
                
                // remove model/file
-               SBIModel.removeRootstrap(rootstrap);
+               //SBIModel.removeRootstrap(rootstrap);
                new File(getPluginXML(rootstrap.getId())).delete();
        }
 
index 0e0dec1..09ed16b 100644 (file)
@@ -40,4 +40,5 @@ SelectRootDlg.Title = Warning
 SelectRootDlg.Msg.LastOne = "%s [%s]" rootstrap is the last one. You can not remove it
 SelectRootDlg.Label.Desc = Follow projects use "%s" rootstrap.\nYou should set other rootstraps if you want to remove "%s" rootstrap
 
-Action.Msg.Error.RemoveDefault = Cannot remove basic rootstrap!  
\ No newline at end of file
+Action.Msg.Error.RemoveDefault = Cannot remove basic rootstrap!  
+Action.Msg.Info.NotInit = This rootstrap is not initialize.
\ No newline at end of file
index c20f0f3..e2d252a 100644 (file)
@@ -1,5 +1,6 @@
 package org.tizen.nativeplatform.views.ui;
 
+import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.ResourceBundle;
@@ -515,6 +516,11 @@ public class RootstrapView extends ViewPart {
                Table table = tableViewer.getTable();
                TableItem[] item = table.getSelection();
                PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
+               boolean initialized = new File(selected.getPath().toOSString()).exists() ? true : false;
+               if (!initialized) {
+                       DialogUtil.openMessageDialog(resources.getString("Action.Msg.Info.NotInit"));
+                       return;
+               }
                RPMPackageDialog dlg = new RPMPackageDialog(shell, selected);
                dlg.open();
             }