From ade93bd6d64360c2adba6a8d974012152d26fd77 Mon Sep 17 00:00:00 2001 From: Taeyoung Son Date: Wed, 4 Dec 2013 18:03:28 +0900 Subject: [PATCH] LAUNCH: Added launch message and launch util. Added launch message: PROJECT_NOT_FOUND Added launch util: LaunchUtil#getDevice(ILaunchConfiguration) Change-Id: Ie70439e22dfe6c43703a1c6aa5cae087d784e9a6 Signed-off-by: Taeyoung Son --- org.tizen.common/META-INF/MANIFEST.MF | 3 +- .../org/tizen/common/launch/LaunchMessages.java | 1 + .../tizen/common/launch/LaunchMessages.properties | 3 +- .../src/org/tizen/common/util/LaunchUtil.java | 60 ++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 org.tizen.common/src/org/tizen/common/util/LaunchUtil.java diff --git a/org.tizen.common/META-INF/MANIFEST.MF b/org.tizen.common/META-INF/MANIFEST.MF index b8817af..8828e61 100755 --- a/org.tizen.common/META-INF/MANIFEST.MF +++ b/org.tizen.common/META-INF/MANIFEST.MF @@ -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, diff --git a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java index a5021cd..dc14080 100644 --- a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java +++ b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java @@ -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; diff --git a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties index 357bc72..e307be1 100644 --- a/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties +++ b/org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties @@ -11,6 +11,7 @@ PROJECT_NOT_OPENED = Project must be opened. PROJECT_NOT_SELECTED = No project is selected. PROJECT_NOT_SPECIFIED = Project is not specified. PROJECT_NOT_USABLE = Project is closed or does not exist. +PROJECT_NOT_FOUND = Could not find the project. UPDATE_MODE_LABEL = Enable update mode UPDATE_MODE_TOOLTIP = If you want to set update mode you should turn off RDS option first of all. @@ -35,4 +36,4 @@ LAUNCH_START = Launching the Tizen application... LAUNCH_END = Tizen application is successfully launched. # Exception -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 index 0000000..23e598f --- /dev/null +++ b/org.tizen.common/src/org/tizen/common/util/LaunchUtil.java @@ -0,0 +1,60 @@ +/* +* Common +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Taeyoung Son +* Kangho Kim +* +* 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 + * + */ +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; + } +} -- 2.7.4