LAUNCH: Processing launching the application having two .xml files
authordonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 20 Jan 2014 01:12:57 +0000 (10:12 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 20 Jan 2014 01:12:57 +0000 (10:12 +0900)
Some EFL application have one or more .xml files. In that case, the IDE
asks what file you want to execute.

Change-Id: Ie7ea33d19ab961877eec70dbd44f35db376c95d3
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
org.tizen.nativeplatform/src/org/tizen/nativeplatform/IPlatformXMLStore.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/manifest/PlatformManifestXMLStore.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java

index bdefe1f..a790f35 100644 (file)
@@ -7,64 +7,68 @@ import org.tizen.common.TizenProjectType;
 
 public interface IPlatformXMLStore {
     /**
-     * Sets the project of this xml store.  
-     * @param project  - project in which xml is stored.
+     * Sets the project of this xml store.
+     * 
+     * @param project
+     *            project in which xml is stored.
      */
-       public void setProject(IProject project);
-       
-    /**
+    public void setProject(IProject project);
+
+/**
      * This roles same as {@link IXMLStore#setProject(IProject), 
      * except that this is for CLI because CLI cannot use IProject.
      * 
      * @param projectPath path of project in which xml will be stored
      */
-       public void setProject(String projectPath);
-       
+    public void setProject(String projectPath);
+
     /**
      * Parses xml files and loads.
      */
-       public boolean loadXml();
-       
+    public boolean loadXml();
+
     /**
      * Returns application's version.
+     * 
      * @return application's version.
      */
     public String getVersion();
-    
+
     /**
      * Returns application's id.
+     * 
+     * @param programPath
+     *            program path
      * @return application's id.
      */
-    public String getAppId();
-    
-    /**
-     * Returns application's label.
-     * @return application's label.
-     */
-    public String getAppLabel();    
-    
+    public String getAppId(String programPath);
+
     /**
      * Returns icon file list of this xml store.
+     * 
      * @return list of icon files.
      */
     public List<String> getIconFileList();
-    
+
     /**
      * Returns application type.
+     * 
      * @return application type.
      */
     public TizenProjectType getApplicationType();
-    
+
     /**
      * Returns application's executable files.
+     * 
      * @return application's executable files.
      */
     public List<String> getExecutableFiles();
-    
+
     /**
      * Returns application's authors.
+     * 
      * @return application's authors.
      */
     public List<String> getAuthors();
-    
+
 }
index 626c96c..30981f9 100644 (file)
@@ -240,7 +240,8 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         try {
             boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
             if (isEflApp) {
-                String appId = PlatformLaunchUtil.getAppId(project);
+                programPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+                String appId = PlatformLaunchUtil.getAppId(project, programPath);
                 killIfRunningApplication(appId);
             }
         } finally {
@@ -259,7 +260,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         if (files != null) {
             if (files.length > 1) {
                 SWTUtil.syncExec(new Runnable() {
-                    public void run() {
+                    public void run() { 
                         SelectItemDialog dlg = new SelectItemDialog(shell, files);
                         dlg.create();
                         if (Window.OK == dlg.open()) {
@@ -280,7 +281,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
         setOptionAttributes(wc, programPath, appProjectName, packages, reinstallOp, selectPkgOp);
         if (isSetProgramPath(config)) {
-            String appId = PlatformLaunchUtil.getAppId(project);
+            String appId = PlatformLaunchUtil.getAppId(project, programPath);
             killIfRunningApplication(appId);
             installPackages(config, mode, monitor);
         } else {
@@ -315,7 +316,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
                     dlg.create();
                     if (Window.OK == dlg.open()) {
                         String appProjectName = dlg.getAppProjectName();
-                        String programPath = dlg.getProgramPath();
+                        programPath = dlg.getProgramPath();
                         List<IPackage> packages = dlg.getExtraPackages();
                         boolean reinstallOp = dlg.getReinstallOp();
                         boolean selectPkgOp = dlg.getSelectPkgOp();
@@ -788,7 +789,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         try {
             monitor.beginTask("", 1);
             monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
-            String appId = PlatformLaunchUtil.getAppId(project);
+            String appId = PlatformLaunchUtil.getAppId(project, programPath);
             if (appId == null) {
                 String envCmd = getEnvironments(config);
                 String execArg = getArguments(config);
index 810bd3f..4f77c1b 100644 (file)
@@ -4,6 +4,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -34,9 +35,8 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
     private static final String ATTR_EXEC = "exec";
 
     private String projectPath;
-    private File manifestFile;
-
-    private PlatformManifestModel model = new PlatformManifestModel();
+    private List<File> manifestFiles = new ArrayList<File>();
+    private List<PlatformManifestModel> models = new ArrayList<PlatformManifestModel>();
     private static final org.slf4j.Logger logger = LoggerFactory
             .getLogger(PlatformManifestXMLStore.class);
 
@@ -53,36 +53,42 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
             clear();
             return false;
         }
-
-        if (manifestFile == null || !manifestFile.exists()) {
+        if (manifestFiles.isEmpty()) {
             logger.error(NLS.bind(Messages.PlatformXmlStore_MANIFEST_NOT_EXIST, this.projectPath));
             return false;
         }
+        clear();
+        for (File f : manifestFiles) {
+            String filePath = f.getAbsolutePath();
 
-        String filePath = manifestFile.getAbsolutePath();
-
-        try {
-            loadXML(filePath);
-        } catch (IOException e) {
-            return false;
-        } catch (SAXException e2) {
-            return false;
-        } catch (ParserConfigurationException e3) {
-            return false;
+            try {
+                PlatformManifestModel model = loadXML(filePath);
+                if (model != null) {
+                    models.add(model);
+                }
+            } catch (IOException e) {
+                models.clear();
+                return false;
+            } catch (SAXException e2) {
+                models.clear();
+                return false;
+            } catch (ParserConfigurationException e3) {
+                models.clear();
+                return false;
+            }
         }
-
         return true;
     }
 
-    private boolean loadXML(final String path) throws FileNotFoundException, IOException,
-            ParserConfigurationException, SAXException {
-        clear();
-        FileInputStream stream = null;
+    private PlatformManifestModel loadXML(final String path) throws FileNotFoundException,
+            IOException, ParserConfigurationException, SAXException {
 
+        FileInputStream stream = null;
+        PlatformManifestModel model = null;
         try {
             File file = new File(path);
             if (!file.exists()) {
-                return false;
+                return null;
             }
             stream = new FileInputStream(file);
 
@@ -90,17 +96,17 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
             DocumentBuilder db = dbf.newDocumentBuilder();
             Document dom = db.parse(stream);
 
-            parse(dom);
+            model = parse(dom);
         } finally {
             IOUtil.tryClose(stream);
         }
-
-        return true;
+        return model;
     }
 
-    private boolean parse(Document dom) {
+    private PlatformManifestModel parse(Document dom) {
         Element root = dom.getDocumentElement();
         String rootName = root.getNodeName();
+        PlatformManifestModel model = new PlatformManifestModel();
 
         if (rootName.equals(ELEMENT_MANIFEST)) {
             for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) {
@@ -112,8 +118,7 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
                 }
             }
         }
-
-        return true;
+        return model;
     }
 
     private void parseApp(Node node, PlatformManifestModel model) {
@@ -131,30 +136,30 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
 
     @Override
     public String getVersion() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public List<String> getIconFileList() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public TizenProjectType getApplicationType() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     @Override
     public List<String> getExecutableFiles() {
-        return model.getExecutableFiles();
+        List<String> exec = new ArrayList<String>();
+        for (PlatformManifestModel m : models) {
+            exec.addAll(m.getExecutableFiles());
+        }
+        return exec;
     }
 
     @Override
     public List<String> getAuthors() {
-        // TODO Auto-generated method stub
         return null;
     }
 
@@ -167,14 +172,17 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
         String[] files = dir.list(new XmlFileFilter());
         // return false if ".xml" file does not exist
         if (files.length != 0) {
-            String xmlFileName = files[0];
-            IPath filePath = new Path(projectPath).append(xmlFileName);
-            manifestFile = filePath.toFile();
+            for (String file : files) {
+                IPath filePath = new Path(projectPath).append(file);
+                manifestFiles.add(filePath.toFile());
+            }
         }
     }
 
     private void clear() {
-        model.clear();
+        for (PlatformManifestModel m : models) {
+            m.clear();
+        }
     }
 
     private static String getChildValue(Node node) {
@@ -184,13 +192,14 @@ public class PlatformManifestXMLStore implements IPlatformXMLStore {
         return null;
     }
 
-    @Override
-    public String getAppId() {
-        return model.getAppId();
-    }
-
-    @Override
-    public String getAppLabel() {
-        return model.getLabel();
+    public String getAppId(String programPath) {
+        for (PlatformManifestModel m : models) {
+            for (String exec : m.getExecutableFiles()) {
+                if (exec.equals(programPath)) {
+                    return m.getAppId();
+                }
+            }
+        }
+        return "";
     }
 }
index b1d969e..383048d 100644 (file)
@@ -384,9 +384,10 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
                         ZypperTool.installLocalCommand(value.toArray(new String[0])));
                 status = execute(command, monitor);
             } else if (type == TOOL.PKGCMD) {
-                String command = makeCommand(getResetRpmDb(),
-                        PkgcmdTool.installCommand(value.toArray(new String[0])));
-                status = execute(command, monitor);
+                for (String pkg : value) {
+                    String command = makeCommand(getResetRpmDb(), PkgcmdTool.installCommand(pkg));
+                    status = execute(command, monitor);
+                }
             }
         }
 
index ee865b3..067a260 100644 (file)
@@ -243,17 +243,17 @@ public class PlatformLaunchUtil {
         }
     }
 
-    public static String getAppId(IProject project) {
+    public static String getAppId(IProject project, String programPath) {
         IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
         if (store.loadXml()) {
-            return getAppId(store);
+            return getAppId(store, programPath);
         } else {
             return null;
         }
     }
 
-    public static String getAppId(IPlatformXMLStore store) {
-        return store.getAppId();
+    public static String getAppId(IPlatformXMLStore store, String programPath) {
+        return store.getAppId(programPath);
     }
 
     public static boolean questionPackaging(IProject project) {