Web simluator launch shortcut appears only mobile project
authornamki lee <namki.lee@samsung.com>
Mon, 30 Jun 2014 04:48:03 +0000 (13:48 +0900)
committernamki lee <namki.lee@samsung.com>
Mon, 30 Jun 2014 04:48:03 +0000 (13:48 +0900)
Change-Id: I05dbd7276cf43c118f0ecdbb9dcfca7320c00480
Signed-off-by: namki lee <namki.lee@samsung.com>
org.tizen.web.simulator/META-INF/MANIFEST.MF
org.tizen.web.simulator/plugin.xml
org.tizen.web.simulator/src/org/tizen/web/simulator/TizenPropertyTester.java [new file with mode: 0644]

index 5cddabd..ef18015 100644 (file)
@@ -25,7 +25,8 @@ Export-Package: org.tizen.web.simulator;
    org.eclipse.jface.viewers,
    org.osgi.framework"
 Bundle-Vendor: %Bundle-Vendor
-Import-Package: org.eclipse.debug.core,
+Import-Package: org.eclipse.core.expressions,
+ org.eclipse.debug.core,
  org.eclipse.debug.core.model,
  org.eclipse.debug.ui,
  org.tizen.common.gom.launch,
index 081feb8..638ba8f 100644 (file)
                         value="1">
                   </count>
                   <iterate>
+                       <test
+                               property="org.tizen.web.simulator.isTizenMobileProject"
+                                       forcePluginActivation="true">
+                               </test>
+                       
                      <and>
                         <test
                               property="org.eclipse.core.resources.projectNature"
          </adapter>
       </factory>
    </extension>
-
+   <extension
+         point="org.eclipse.core.expressions.propertyTesters">
+      <propertyTester
+            class="org.tizen.web.simulator.TizenPropertyTester"
+            id="org.tizen.web.simulator.TizenPropertyTester"
+            namespace="org.tizen.web.simulator"
+            properties="isTizenMobileProject"
+            type="org.eclipse.core.resources.IResource">
+      </propertyTester>
+   </extension>
+   
 </plugin>
diff --git a/org.tizen.web.simulator/src/org/tizen/web/simulator/TizenPropertyTester.java b/org.tizen.web.simulator/src/org/tizen/web/simulator/TizenPropertyTester.java
new file mode 100644 (file)
index 0000000..1025f4e
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  Web Simulator
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Taejun Ha <taejun.ha@samsung.com>
+ * Jiil Hyoun <jiil.hyoun@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * NamKi Lee <namki.lee@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ * - Samsung Electronics Co.., Ltd
+ *
+ */
+
+package org.tizen.web.simulator;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.core.application.TizenProjectDescription;
+
+public class TizenPropertyTester extends PropertyTester {
+       private final Logger logger = LoggerFactory.getLogger(TizenPropertyTester.class);
+       
+       @Override
+       public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+               try {
+                       if (property.equals("isTizenMobileProject")) {
+                               if (receiver instanceof IProject) {
+                                       IProject project = (IProject) receiver;
+                                       if (org.tizen.common.util.ProjectUtil.getTizenProjectDescription(project).getProfileName().equals("mobile")){
+                                               return true;
+                                       } else {
+                                               return false;
+                                       }                                       
+                               }
+                       } 
+                       return false;
+               } catch (Exception e) {
+            logger.error("Failed to test isTizenProject", e);
+            // It must return a value although an error occurs.
+            // Otherwise, UI like project popup is broken.
+            return false;
+        }
+       }
+}