+++ /dev/null
-/*\r
-* Common\r
-*\r
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-*\r
-* Contact: \r
-* Hoon Kang <h245.kang@samsung.com>\r
-* YoonKi Park <yoonki.park@samsung.com>\r
-* \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*\r
-* Contributors:\r
-* - S-Core Co., Ltd\r
-*\r
-*/\r
-package com.samsung.tizen.common.connection.debugtools;\r
-\r
-import java.util.MissingResourceException;\r
-import java.util.ResourceBundle;\r
-\r
-public class Messages {\r
- private static final String BUNDLE_NAME = "com.samsung.tizen.common.connection.debugtools.messages"; //$NON-NLS-1$\r
-\r
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle\r
- .getBundle(BUNDLE_NAME);\r
-\r
- private Messages() {\r
- }\r
- \r
- public static String getString(String key) {\r
- // TODO Auto-generated method stub\r
- try {\r
- return RESOURCE_BUNDLE.getString(key);\r
- } catch (MissingResourceException e) {\r
- return '!' + key + '!';\r
- }\r
- }\r
- \r
- public static String getString(String key, Object binding) {\r
- // TODO Auto-generated method stub\r
- try {\r
- return RESOURCE_BUNDLE.getString(key);\r
- } catch (MissingResourceException e) {\r
- return '!' + key + '!';\r
- }\r
- }\r
- private static String messageBind(String message, Object[] args, String argZero, String argOne) {\r
- int length = message.length();\r
- //estimate correct size of string buffer to avoid growth\r
- int bufLen = length + (args.length * 5);\r
- if (argZero != null)\r
- bufLen += argZero.length() - 3;\r
- if (argOne != null)\r
- bufLen += argOne.length() - 3;\r
- StringBuffer buffer = new StringBuffer(bufLen < 0 ? 0 : bufLen);\r
- for (int i = 0; i < length; i++) {\r
- char c = message.charAt(i);\r
- switch (c) {\r
- case '{' :\r
- int index = message.indexOf('}', i);\r
- // if we don't have a matching closing brace then...\r
- if (index == -1) {\r
- buffer.append(c);\r
- break;\r
- }\r
- i++;\r
- if (i >= length) {\r
- buffer.append(c);\r
- break;\r
- }\r
- // look for a substitution\r
- int number = -1;\r
- try {\r
- number = Integer.parseInt(message.substring(i, index));\r
- } catch (NumberFormatException e) {\r
- throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);\r
- }\r
- if (number == 0 && argZero != null)\r
- buffer.append(argZero);\r
- else if (number == 1 && argOne != null)\r
- buffer.append(argOne);\r
- else {\r
- if (number >= args.length || number < 0) {\r
- buffer.append("<missing argument>"); //$NON-NLS-1$\r
- i = index;\r
- break;\r
- }\r
- buffer.append(args[number]);\r
- }\r
- i = index;\r
- break;\r
- case '\'' :\r
- // if a single quote is the last char on the line then skip it\r
- int nextIndex = i + 1;\r
- if (nextIndex >= length) {\r
- buffer.append(c);\r
- break;\r
- }\r
- char next = message.charAt(nextIndex);\r
- // if the next char is another single quote then write out one\r
- if (next == '\'') {\r
- i++;\r
- buffer.append(c);\r
- break;\r
- }\r
- // otherwise we want to read until we get to the next single quote\r
- index = message.indexOf('\'', nextIndex);\r
- // if there are no more in the string, then skip it\r
- if (index == -1) {\r
- buffer.append(c);\r
- break;\r
- }\r
- // otherwise write out the chars inside the quotes\r
- buffer.append(message.substring(nextIndex, index));\r
- i = index;\r
- break;\r
- default :\r
- buffer.append(c);\r
- }\r
- }\r
- return buffer.toString();\r
- }\r
-}\r
import java.util.List;
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import com.samsung.tizen.common.connection.ConnectionPlugin;
-import com.samsung.tizen.common.properties.InstallPathConfig;
import com.samsung.tizen.sdblib.IDevice;
import com.samsung.tizen.sdblib.SdbCommandRejectedException;
import com.samsung.tizen.sdblib.SdbShellProcess;
class InstallProgress implements IRunnableWithProgress {
- final private String TOOLS_TARGET_PATH = "/home/root/sdk_tools";
- final private String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath();
final private String CMD_RESULT_CHECK = "; echo $?";
private IDevice device = null;
IProgressMonitor monitor = null;
- private boolean checkDirectory(String dir) {
+ private boolean checkDirectory(String dir) throws CoreException {
boolean checkResult = false;
SdbShellProcess lsProc;
try {
checkResult = true;
}
} catch (IOException e) {
- return false;
+ installCoreException(ToolsInstallMessages.CANNOT_CHECK_DIRECTORY, e);
}
return checkResult;
}
- private boolean makeDirectory(String dir) {
+ private void makeDirectory(String dir) throws CoreException {
boolean makeResult = false;
SdbShellProcess lsProc;
try {
}
br.close();
} catch (IOException e) {
- return false;
+ installCoreException(ToolsInstallMessages.CANNOT_CREATE_DIRECTORY, e);
}
- return makeResult;
+ if (makeResult == false)
+ installCoreException(ToolsInstallMessages.CANNOT_CREATE_DIRECTORY, null);
}
- private boolean isInstalled(DebugTool dt) {
+ private boolean isInstalled(DebugTool dt) throws CoreException {
boolean ret = false;
try {
SdbShellProcess echoProc = device
.executeShellCommand("cat "
- + TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK);
+ + DebugTool.TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK);
BufferedReader br = new BufferedReader(new InputStreamReader(
echoProc.getInputStream()));
ret = false;
br.close();
} catch (IOException e) {
- return true;
+ installCoreException(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
}
return ret;
}
private void removeOldPackage(String packagename) {
try {
- SdbShellProcess echoProc = device.executeShellCommand("rm -rf " + TOOLS_TARGET_PATH + "/" + packagename);
+ SdbShellProcess echoProc = device.executeShellCommand("rm -rf " + DebugTool.TOOLS_TARGET_PATH + "/" + packagename);
BufferedReader br = new BufferedReader(new InputStreamReader(echoProc.getInputStream()));
while (null != br.readLine()){
private void unzipPackage(String packageFile) {
try {
SdbShellProcess tarProc = device.executeShellCommand("cd "
- + TOOLS_TARGET_PATH + " && tar -xzf " + packageFile);
+ + DebugTool.TOOLS_TARGET_PATH + " && tar -xzf " + packageFile);
BufferedReader br = new BufferedReader(new InputStreamReader(
tarProc.getInputStream()));
while (null != br.readLine()) {
try {
SdbShellProcess echoProc = device
.executeShellCommand("echo 'version:"+version+ "' >"
- + TOOLS_TARGET_PATH + "/" + controlFile );
+ + DebugTool.TOOLS_TARGET_PATH + "/" + controlFile );
BufferedReader br = new BufferedReader(new InputStreamReader(
echoProc.getInputStream()));
while (null != br.readLine()) {
private void removeTar(String packageFile) {
try {
SdbShellProcess echoProc = device.executeShellCommand("cd "
- + TOOLS_TARGET_PATH + " && rm " + packageFile);
+ + DebugTool.TOOLS_TARGET_PATH + " && rm " + packageFile);
BufferedReader br = new BufferedReader(new InputStreamReader(
echoProc.getInputStream()));
}
}
- final private void installPackage(DebugTool tool) {
- String local = TOOLS_HOST_PATH+"/"+tool.getSourcepath() + "/" + tool.getBinaryname();
- String remote = TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
+ final private void installPackage(DebugTool tool) throws CoreException {
+ String local = DebugTool.TOOLS_HOST_PATH+"/"+tool.getSourcepath() + "/" + tool.getBinaryname();
+ String remote = DebugTool.TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
// delete old version
try {
SdbShellProcess echoProc = device.executeShellCommand("cd "
- + TOOLS_TARGET_PATH + " && rm " + tool.getControlFile());
+ + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getControlFile());
} catch (IOException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ installCoreException(ToolsInstallMessages.CANNOT_REMOVE_CONTROLFILE, e);
}
}
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final List<DebugTool> debugTools = ConnectionPlugin.getDebugTools(device);
if (debugTools == null || debugTools.size() ==0)
boolean isInstalled = false;
for (int i=0 ; i<debugTools.size(); i++) {
DebugTool dt = (DebugTool)debugTools.get(i);
- isInstalled = isInstalled(dt);
+ try {
+ isInstalled = isInstalled(dt);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
if (isInstalled == false)
break;
}
final IProgressMonitor fmonitor = monitor;
this.monitor = monitor;
- monitor.beginTask(Messages.getString("debugtools.initilize"), 100);
+ monitor.beginTask(ToolsInstallMessages.DIALOG_INITILIZE, 100);
//monitor.subTask("Prepare install");
// check directory exist
- if (!checkDirectory(TOOLS_TARGET_PATH))
- makeDirectory(TOOLS_TARGET_PATH);
+ try {
+ if (!checkDirectory(DebugTool.TOOLS_TARGET_PATH))
+ makeDirectory(DebugTool.TOOLS_TARGET_PATH);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
monitor.worked(10);
@Override
public void run() {
- installPackage(dt);
+ try {
+ installPackage(dt);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
}, "package check and install");
thread.start();
public void setDevice(IDevice device) {
this.device = device;
}
-
+
+ private void installCoreException(String message, Throwable exception) throws CoreException {
+ Status status = new Status(Status.ERROR, ConnectionPlugin.PLUGIN_ID, message, exception);
+ throw new CoreException(status);
+ }
}
public class ToolsInstall {
--- /dev/null
+/*\r
+* Common\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* Hoon Kang <h245.kang@samsung.com>\r
+* YoonKi Park <yoonki.park@samsung.com>\r
+* \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+* Contributors:\r
+* - S-Core Co., Ltd\r
+*\r
+*/\r
+package com.samsung.tizen.common.connection.debugtools;\r
+\r
+import org.eclipse.osgi.util.NLS;\r
+\r
+public class ToolsInstallMessages extends NLS {\r
+\r
+ static {\r
+ NLS.initializeMessages(ToolsInstallMessages.class.getName(), ToolsInstallMessages.class);\r
+ }\r
+ \r
+ public static String DIALOG_INITILIZE;\r
+ public static String CANNOT_CREATE_DIRECTORY;\r
+ public static String CANNOT_CHECK_DIRECTORY;\r
+ public static String CANNOT_CHECK_INSTALLED;\r
+ public static String CANNOT_COPY_FILE;\r
+ public static String CANNOT_REMOVE_CONTROLFILE;\r
+ \r
+}\r