LAUNCH: Added launch message and launch util. 72/13372/3
authorTaeyoung Son <taeyoung2.son@samsung.com>
Wed, 4 Dec 2013 09:03:28 +0000 (18:03 +0900)
committerTaeyoung Son <taeyoung2.son@samsung.com>
Wed, 4 Dec 2013 10:12:00 +0000 (19:12 +0900)
Added launch message: PROJECT_NOT_FOUND
Added launch util: LaunchUtil#getDevice(ILaunchConfiguration)

Change-Id: Ie70439e22dfe6c43703a1c6aa5cae087d784e9a6
Signed-off-by: Taeyoung Son <taeyoung2.son@samsung.com>
org.tizen.common/META-INF/MANIFEST.MF
org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java
org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties
org.tizen.common/src/org/tizen/common/util/LaunchUtil.java [new file with mode: 0644]

index b8817af..8828e61 100755 (executable)
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.ide,
  org.eclipse.core.resources,
  org.eclipse.core.filesystem,
- org.junit4;bundle-version="4.8.1";resolution:=optional
+ org.junit4;bundle-version="4.8.1";resolution:=optional,
+ org.eclipse.debug.core
 Export-Package: 
  freemarker.cache,
  freemarker.core,
index a5021cd..dc14080 100644 (file)
@@ -43,6 +43,7 @@ public class LaunchMessages extends NLS {
     public static String PROJECT_NOT_SELECTED;
     public static String PROJECT_NOT_SPECIFIED;
     public static String PROJECT_NOT_USABLE;
+    public static String PROJECT_NOT_FOUND;
 
     public static String UPDATE_MODE_LABEL;
     public static String UPDATE_MODE_TOOLTIP;
index 357bc72..e307be1 100644 (file)
@@ -11,6 +11,7 @@ PROJECT_NOT_OPENED = Project must be opened.
 PROJECT_NOT_SELECTED = No project is selected.\r
 PROJECT_NOT_SPECIFIED = Project is not specified.\r
 PROJECT_NOT_USABLE = Project is closed or does not exist.\r
+PROJECT_NOT_FOUND = Could not find the project.\r
 \r
 UPDATE_MODE_LABEL = Enable update mode\r
 UPDATE_MODE_TOOLTIP = If you want to set update mode you should turn off RDS option first of all.\r
@@ -35,4 +36,4 @@ LAUNCH_START = Launching the Tizen application...
 LAUNCH_END = Tizen application is successfully launched.\r
 \r
 # Exception\r
-SDB_TIMEOUT_EXCEPTION = There is no response while {0} seconds. Please retry again.
\ No newline at end of file
+SDB_TIMEOUT_EXCEPTION = There is no response while {0} seconds. Please retry again.
diff --git a/org.tizen.common/src/org/tizen/common/util/LaunchUtil.java b/org.tizen.common/src/org/tizen/common/util/LaunchUtil.java
new file mode 100644 (file)
index 0000000..23e598f
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+*  Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Taeyoung Son <taeyoung2.son@samsung.com> 
+* Kangho Kim <kh5325.kim@samsung.com>
+* 
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+package org.tizen.common.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SmartDevelopmentBridge;
+
+/**
+ * Utils for launching a Tizen application.
+ * @author Taeyoung Son <taeyoung2.son@samsung.com>
+ *
+ */
+public class LaunchUtil {
+
+    /**
+     * Gets {@link IDevice}.
+     * @param configuration
+     * @param serialNoKey The configuration's attribute key about device serial number.
+     * @return {@link IDevice}. If it cannot find device, return null;
+     * @throws CoreException
+     */
+    public static IDevice getDevice(ILaunchConfiguration configuration, String serialNoKey) throws CoreException {
+        String deviceSerialNo = configuration.getAttribute(serialNoKey, "");
+        IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+        if (ArrayUtil.isEmpty(devices)) {
+            return null;
+        }
+        for (IDevice device : devices) {
+            if (device.getSerialNumber().equals(deviceSerialNo)) {
+                return device;
+            }
+        }
+        return null;
+    }
+}