Refactored pacakge and added web types to TizenProjectType
authorkh5325.kim <kh5325.kim@samsung.com>
Mon, 13 May 2013 13:33:55 +0000 (22:33 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Mon, 13 May 2013 14:16:59 +0000 (23:16 +0900)
org.tizen.common/META-INF/MANIFEST.MF
org.tizen.common/src/org/tizen/common/ITizenLaunchConfiguration.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenLaunchConfiguration.java with 97% similarity]
org.tizen.common/src/org/tizen/common/ITizenNativeLaunchConfiguration.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenNativeLaunchConfiguration.java with 96% similarity]
org.tizen.common/src/org/tizen/common/ITizenNativeProject.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenNativeProject.java with 79% similarity]
org.tizen.common/src/org/tizen/common/ITizenProject.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenProject.java with 72% similarity]
org.tizen.common/src/org/tizen/common/ITizenWebLaunchConfiguration.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenWebLaunchConfiguration.java with 96% similarity]
org.tizen.common/src/org/tizen/common/ITizenWebProject.java [moved from org.tizen.common/src/org/tizen/common/adapter/ITizenWebProject.java with 84% similarity]
org.tizen.common/src/org/tizen/common/TizenProjectType.java
org.tizen.common/src/org/tizen/common/util/ProjectUtil.java

index 96a73ee..7c5ff76 100755 (executable)
@@ -177,7 +177,6 @@ Export-Package:
  org.powermock.tests.utils.impl,
  org.slf4j,
  org.tizen.common,
- org.tizen.common.adapter,
  org.tizen.common.classloader,
  org.tizen.common.config,
  org.tizen.common.config.loader,
  * - S-Core Co., Ltd
  *
  */
-package org.tizen.common.adapter;
+package org.tizen.common;
 
 import java.util.List;
 
 /**
- * Interface about Tizen native project
+ * Interface about Tizen native project.
  * @author hyunsik
  *
  */
-public interface ITizenNativeProject extends ITizenProject{
+public interface ITizenNativeProject extends ITizenProject {
     /**
-     * Return build configuration list
-     * @return a List&lt;String&gt;
+     * Returns build configuration list.
+     * @return a build configuration list
      */
     public List<String> getBuildConfiguration();
+
     /**
-     * Return default build configuration name.
+     * Returns default build configuration name.
      * @return String
      */
     public String getDefaultBuildConfiguration();
-
 }
  * - S-Core Co., Ltd
  *
  */
-package org.tizen.common.adapter;
+package org.tizen.common;
 
-import org.tizen.common.TizenProjectType;
 
 /**
- * Interface to get information about Tizen project
+ * Interface to get information about Tizen project.
  * @author hyunsik
  *
  */
 public interface ITizenProject {
     /**
-     * Returns true if project is for Tizen native.
-     * 
-     * @return boolean
-     */
-    
-    boolean isTizenNativeProject();
-    /**
-     * Returns true if project is for Tizen web.
-     * 
-     * @return boolean
-     */
-    
-    boolean isTizenWebProject();
-    /**
      * Returns the App ID from a config.xml.
      * 
-     * @return an App ID string. If could not get a value, return null.
+     * @return an App ID string. If could not get a value, returns {@code null}.
      */
-    
     public String getAppId();
     
     /**
      * Returns the Package ID from a manifest.xml.
      * 
-     * @return a Package ID string. If could not get a value, return null.
+     * @return a Package ID string. If could not get a value, returns {@code null}.
      */
     public String getPackageId();
     
     /**
-     * Returns the Tizen project type
+     * Returns the Tizen project type.
      * 
-     * @return TizenProjectType
+     * @return {@link TizenProjectType}
      */
     public TizenProjectType getTizenProjectType();
 }
  * - S-Core Co., Ltd
  *
  */
-package org.tizen.common.adapter;
+package org.tizen.common;
 
 /**
- * Interface to get information about Tizen web project
+ * Interface about Tizen web project.
  * @author hyunsik
  *
  */
-public abstract class ITizenWebProject implements ITizenProject{
-
+public interface ITizenWebProject extends ITizenProject {
 }
index b9c1b5a..6589fac 100644 (file)
@@ -27,7 +27,7 @@ package org.tizen.common;
 
 
 /**
- * Represents that TIZEN supports the given project types.
+ * Represents TIZEN project types.
  */
 public enum TizenProjectType {
     TIZEN_C_UI_APPLICATION(true, false, false),
@@ -38,7 +38,11 @@ public enum TizenProjectType {
     TIZEN_CPP_SERVICE_APPLICATION(false, false, true),
     TIZEN_CPP_SHAREDLIBRARY(false, false, false),
     TIZEN_CPP_STATICLIBRARY(false, false, false),
-    TIZEN_PLATFORM_PROJECT(false, false, false);
+    TIZEN_PLATFORM_PROJECT(false, false, false),
+    
+    TIZEN_WEB_APPLICATION(false, true, false),
+    TIZEN_WEB_UIFW_APPLICATION(false, true, false),
+    TIZEN_WEB_UIBUILDER_APPLICATION(false, true, false);
     
     private boolean isNeededIconValidation;
     private boolean isRootPrj;
@@ -56,7 +60,7 @@ public enum TizenProjectType {
     
     /**
      * Returns whether this project can be root project of multi app project.
-     * @return {@code true} if this project can be root project. {@code false} if not.
+     * @return {@code true} if this project can be root project, otherwise {@code false}
      */
     public boolean isRootProject() {
         return isRootPrj;
@@ -64,9 +68,45 @@ public enum TizenProjectType {
     
     /**
      * Returns whether this project can be referenced project of multi app project.
-     * @return {@code true} if this project can be referenced project. {@code false} if not.
+     * @return {@code true} if this project can be referenced project, otherwise {@code false}
      */
     public boolean isReferencedProject() {
         return isRefPrj;
     }
+
+    /**
+     * Returns {@code true} if the project type is native.
+     * @return {@code true} if this project type is native, otherwise {@code false}
+     */
+    public boolean isNativeProject() {
+        switch (this) {
+            case TIZEN_C_UI_APPLICATION :
+            case TIZEN_C_SERVICE_APPLICATION :
+            case TIZEN_C_SHAREDLIBRARY :
+            case TIZEN_C_STATICLIBRARY :
+            case TIZEN_CPP_UI_APPLICATION :
+            case TIZEN_CPP_SERVICE_APPLICATION :
+            case TIZEN_CPP_SHAREDLIBRARY :
+            case TIZEN_CPP_STATICLIBRARY :
+            case TIZEN_PLATFORM_PROJECT :
+                return true;
+            default :
+                return false;
+        }
+    }
+
+    /**
+     * Returns {@code true} if the project type is web.
+     * @return {@code true} if this project type is web, otherwise {@code false}
+     */
+    public boolean isWebProject() {
+        switch (this) {
+            case TIZEN_WEB_APPLICATION :
+            case TIZEN_WEB_UIFW_APPLICATION :
+            case TIZEN_WEB_UIBUILDER_APPLICATION :
+                return true;
+            default :
+                return false;
+        }
+    }
 }
index 64bf5bd..786aa08 100644 (file)
@@ -37,9 +37,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Platform;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.tizen.common.adapter.ITizenNativeProject;
-import org.tizen.common.adapter.ITizenWebProject;
-import org.tizen.common.adapter.ITizenProject;
+import org.tizen.common.ITizenNativeProject;
+import org.tizen.common.ITizenProject;
+import org.tizen.common.ITizenWebProject;
 
 /**
  * ProjectUtil.
@@ -208,7 +208,7 @@ public class ProjectUtil {
     /**
      * Checks whether target project is located in default location or not.
      * @param descriptionLocation .cproject location of target project.
-     * @return true if it is located in default location. False if not.
+     * @return {@code true} if it is located in default location, otherwise {@code false}
      */
     public static boolean isDefaultProjectLocation(IPath descriptionLocation) {
         if(descriptionLocation.segmentCount() < 2) {
@@ -216,31 +216,45 @@ public class ProjectUtil {
         }
         return descriptionLocation.removeLastSegments(2).toFile().equals(Platform.getLocation().toFile());
     }
-    
+
+    /**
+     * Returns {@link ITizenProject} object for the project.
+     * @param project 
+     * @return {@link ITizenProject}
+     */
+    public static ITizenProject getTizenProject(IProject project, Class adapter) {
+        if (project == null)
+            throw new IllegalArgumentException("project can not be null");
+        Object obj = project.getAdapter(adapter);
+        if (obj == null || !(obj instanceof ITizenProject))
+            throw new IllegalArgumentException("project can not be adapted (obj - " + obj + ", adapter - " + adapter + ")");
+        return (ITizenProject) obj;
+    }
+
     /**
-     * Check whether project is for tizen native or not.
+     * Checks whether project is for Tizen native or not.
      * @param project 
-     * @return true if it is tizen native project.
+     * @return {@code true} if it is Tizen native project
      */
     public static boolean isTizenNativeProject(IProject project) {
-        ITizenProject adapter = (ITizenProject) project.getAdapter(ITizenNativeProject.class);
-        return adapter.isTizenNativeProject();
+        ITizenProject adapter = getTizenProject(project, ITizenNativeProject.class);
+        return (adapter.getTizenProjectType() == null) ? false : adapter.getTizenProjectType().isNativeProject();
     }
     
     /**
-     * Check whether project is for tizen web or not.
+     * Checks whether project is for Tizen web or not.
      * @param project 
-     * @return true if it is tizen web project.
+     * @return {@code true} if it is Tizen web project
      */
     public static boolean isTizenWebProject(IProject project) {
-        ITizenProject adapter = (ITizenProject) project.getAdapter(ITizenWebProject.class);
-        return adapter.isTizenWebProject();
+        ITizenProject adapter = getTizenProject(project, ITizenWebProject.class);
+        return (adapter.getTizenProjectType() == null) ? false : adapter.getTizenProjectType().isWebProject();
     }
     
     /**
-     * Check whether project is for tizen or not.
+     * Checks whether project is for Tizen or not.
      * @param project 
-     * @return true if it is tizen project.
+     * @return {@code true} if it is Tizen project
      */
     public static boolean isTizenProject(IProject project) {
         return (isTizenNativeProject(project) || isTizenWebProject(project));