From 974c78f7ac8880da4781137e4e72d1f7dc2c63e6 Mon Sep 17 00:00:00 2001 From: "taeyoung2.son" Date: Fri, 8 Jul 2011 14:29:50 +0900 Subject: [PATCH] WAC, Fresh IDE - Common Module Integration - VirtualDeviceLauncher.java -- change - emulator launch function - AbstractMachine.java -- remove - unused import package. -- add - variable get function. - ShellTerminal.java -- Remove CDT dependency. - HostUtil.java -- add - emulator launch function (batch run) -- add - exception (e.printStackTrace()) --- .../src/com/samsung/ide/common/util/HostUtil.java | 39 +++++++- com.samsung.ide.connection/META-INF/MANIFEST.MF | 19 ++-- com.samsung.ide.connection/plugin.xml | 110 +++++++++------------ .../connection/device/VirtualDeviceLauncher.java | 18 ++-- .../ide/connection/machine/AbstractMachine.java | 18 +++- .../ide/connection/session/ShellTerminal.java | 24 ++--- 6 files changed, 129 insertions(+), 99 deletions(-) diff --git a/com.samsung.ide.common/src/com/samsung/ide/common/util/HostUtil.java b/com.samsung.ide.common/src/com/samsung/ide/common/util/HostUtil.java index 205e833..f332d65 100644 --- a/com.samsung.ide.common/src/com/samsung/ide/common/util/HostUtil.java +++ b/com.samsung.ide.common/src/com/samsung/ide/common/util/HostUtil.java @@ -103,7 +103,7 @@ public abstract class HostUtil{ String[] fullCommand = getCommand(command); - int i; + int i = 0; try { proc= runtime.exec(fullCommand); i = proc.waitFor(); @@ -111,6 +111,7 @@ public abstract class HostUtil{ e.printStackTrace(); return false; } finally{ + System.out.println("HostUtil execute - exit value : " + i); if(proc!=null) proc.destroy(); } @@ -132,12 +133,46 @@ public abstract class HostUtil{ gb1.start(); gb2.start(); }catch(Exception e){ + e.printStackTrace(); + return false; }finally{ } return true; } - + /** + * Don't need for emultor install registration. + * using java.lang.Runtime.exec(String[] cmdarray, String[] envp, File dir) + * @param command - array containing the command to call and its arguments. + * @param envp - array of strings, each element of which has environment variable settings in format name=value. + * @param dir - Emultor path. + * @return success true, failed false. + */ + public static boolean batchExecute(String command, String[] envp, File dir) + { + String[] fullCommand = getCommand(command); + + Runtime run = Runtime.getRuntime(); + Process p = null; + + StreamGobbler gb1 = null; + StreamGobbler gb2 = null; + try{ + p = run.exec(fullCommand, envp, dir); + gb1 = new StreamGobbler(p.getInputStream()); + gb2 = new StreamGobbler(p.getErrorStream()); + gb1.start(); + gb2.start(); + }catch(Exception e){ + e.printStackTrace(); + return false; + }finally{ + System.out.println(gb1.getResult()); + System.out.println(gb2.getResult()); + } + return true; + } + public static String returnExecute(String command){ BufferedReader input = null; StringBuilder contents = new StringBuilder(); diff --git a/com.samsung.ide.connection/META-INF/MANIFEST.MF b/com.samsung.ide.connection/META-INF/MANIFEST.MF index 2baf6a1..2d1bba9 100644 --- a/com.samsung.ide.connection/META-INF/MANIFEST.MF +++ b/com.samsung.ide.connection/META-INF/MANIFEST.MF @@ -1,13 +1,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Connection -Bundle-SymbolicName: com.samsung.ide.connection;singleton:=true +Bundle-SymbolicName: com.samsung.freshide.connection;singleton:=true Bundle-Version: 1.0.0.qualifier -Bundle-Activator: com.samsung.ide.connection.FreshConnectionActivator +Bundle-Activator: com.samsung.freshide.connection.FreshConnectionActivator Bundle-Vendor: SAMSUNG Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - com.samsung.ide.common;bundle-version="1.3.20", + com.samsung.freshide.common;bundle-version="1.3.20", org.eclipse.rse.ui;bundle-version="3.1.102", org.eclipse.rse.core;bundle-version="3.1.102", org.eclipse.rse.services;bundle-version="3.2.2", @@ -18,11 +18,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.net Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy -Export-Package: com.samsung.ide.connection, - com.samsung.ide.connection.device, - com.samsung.ide.connection.machine, - com.samsung.ide.connection.session -Import-Package: com.samsung.ide.common.properties, - com.samsung.ide.common.util, - org.eclipse.cdt.core, +Export-Package: com.samsung.freshide.connection, + com.samsung.freshide.connection.device, + com.samsung.freshide.connection.machine, + com.samsung.freshide.connection.session +Import-Package: com.samsung.freshide.common.properties, + com.samsung.freshide.common.util, org.eclipse.ui.console diff --git a/com.samsung.ide.connection/plugin.xml b/com.samsung.ide.connection/plugin.xml index 5dd1b9d..ecbb015 100644 --- a/com.samsung.ide.connection/plugin.xml +++ b/com.samsung.ide.connection/plugin.xml @@ -5,68 +5,44 @@ - - - - - - - + - - + + + + + - - - - - - - - - - - - - - - + + locationURI="toolbar:com.samsung.freshide.connection.ui.LogView?after=additions"> @@ -76,15 +52,15 @@ @@ -92,16 +68,16 @@ + class="com.samsung.freshide.connection.handler.ImportLogHandler" + commandId="com.samsung.freshide.connection.ui.command.ImportLog"> + class="com.samsung.freshide.connection.handler.ExportLogHandler" + commandId="com.samsung.freshide.connection.ui.command.ExportLog"> + class="com.samsung.freshide.connection.handler.ClearLogHandler" + commandId="com.samsung.freshide.connection.ui.command.ClearLog"> @@ -114,11 +90,12 @@ + class="com.samsung.freshide.connection.ui.DeviceView" + icon="icons/Device View.gif" + id="com.samsung.freshide.connection.ui.DeviceView" + name="Connections" + restorable="true"> @@ -128,8 +105,8 @@ name="Logs" icon="icons/Log View.gif" category="com.samsung.freshide.viewCategory" - class="com.samsung.ide.connection.ui.LogView" - id="com.samsung.ide.connection.ui.LogView"> + class="com.samsung.freshide.connection.ui.LogView" + id="com.samsung.freshide.connection.ui.LogView"> @@ -141,10 +118,10 @@ ratio="1" relationship="bottom" relative="org.eclipse.ui.navigator.ProjectExplorer" - id="com.samsung.ide.connection.ui.DeviceView"> + id="com.samsung.freshide.connection.ui.DeviceView"> + id="com.samsung.freshide.connection.ui.DeviceView"> @@ -154,13 +131,13 @@ + id="com.samsung.freshide.connection.ui.LogView"> @@ -168,9 +145,18 @@ + + + + diff --git a/com.samsung.ide.connection/src/com/samsung/ide/connection/device/VirtualDeviceLauncher.java b/com.samsung.ide.connection/src/com/samsung/ide/connection/device/VirtualDeviceLauncher.java index 4bd6dc0..45745ab 100644 --- a/com.samsung.ide.connection/src/com/samsung/ide/connection/device/VirtualDeviceLauncher.java +++ b/com.samsung.ide.connection/src/com/samsung/ide/connection/device/VirtualDeviceLauncher.java @@ -1,4 +1,4 @@ -package com.samsung.ide.connection.device; +package com.samsung.freshide.connection.device; import java.io.File; @@ -9,12 +9,12 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import com.samsung.ide.common.properties.InstallPathConfig; -import com.samsung.ide.common.util.HostUtil; -import com.samsung.ide.connection.FreshConnectionActivator; -import com.samsung.ide.connection.machine.DeviceMachine; -import com.samsung.ide.connection.session.ISession; -import com.samsung.ide.connection.session.SessionManager; +import com.samsung.freshide.common.properties.InstallPathConfig; +import com.samsung.freshide.common.util.HostUtil; +import com.samsung.freshide.connection.FreshConnectionActivator; +import com.samsung.freshide.connection.machine.DeviceMachine; +import com.samsung.freshide.connection.session.ISession; +import com.samsung.freshide.connection.session.SessionManager; public class VirtualDeviceLauncher extends DeviceLauncher{ @@ -110,7 +110,7 @@ public class VirtualDeviceLauncher extends DeviceLauncher{ e.printStackTrace(); } } catch (Exception e) { - return new Status(Status.ERROR, "com.samsung.ide.connection", e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + return new Status(Status.ERROR, "com.samsung.freshide.connection", e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } finally { monitor.done(); } @@ -252,7 +252,7 @@ public class VirtualDeviceLauncher extends DeviceLauncher{ } else { - HostUtil.batchExecute( command ); + HostUtil.batchExecute( command, null, new File(EMULATOR_PATH) ); } } diff --git a/com.samsung.ide.connection/src/com/samsung/ide/connection/machine/AbstractMachine.java b/com.samsung.ide.connection/src/com/samsung/ide/connection/machine/AbstractMachine.java index 9dbed3c..843ca3d 100644 --- a/com.samsung.ide.connection/src/com/samsung/ide/connection/machine/AbstractMachine.java +++ b/com.samsung.ide.connection/src/com/samsung/ide/connection/machine/AbstractMachine.java @@ -1,4 +1,4 @@ -package com.samsung.ide.connection.machine; +package com.samsung.freshide.connection.machine; import java.io.IOException; import java.net.InetAddress; @@ -29,8 +29,6 @@ import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystem; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.swt.widgets.Display; -import com.samsung.ide.common.util.DialogUtil; - public abstract class AbstractMachine implements IMachine { // RSE protected ISystemRegistry rseSystemRegistry; @@ -470,7 +468,19 @@ public abstract class AbstractMachine implements IMachine { } public String getHostName() { - return hostName; + return this.hostName; + } + + public String getUserName() { + return this.userName; + } + + public String getPassWord() { + return this.password; + } + + public int getSshPort() { + return this.sshPort; } public IHost getHost() { diff --git a/com.samsung.ide.connection/src/com/samsung/ide/connection/session/ShellTerminal.java b/com.samsung.ide.connection/src/com/samsung/ide/connection/session/ShellTerminal.java index cf8536e..02c079c 100644 --- a/com.samsung.ide.connection/src/com/samsung/ide/connection/session/ShellTerminal.java +++ b/com.samsung.ide.connection/src/com/samsung/ide/connection/session/ShellTerminal.java @@ -1,4 +1,4 @@ -package com.samsung.ide.connection.session; +package com.samsung.freshide.connection.session; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -13,15 +13,15 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.channels.FileChannel; -import org.eclipse.cdt.core.CommandLauncher; +//import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -import com.samsung.ide.common.util.HostUtil; -import com.samsung.ide.connection.console.ConsoleWriter; -import com.samsung.ide.connection.machine.IMachine; +import com.samsung.freshide.common.util.HostUtil; +import com.samsung.freshide.connection.console.ConsoleWriter; +import com.samsung.freshide.connection.machine.IMachine; /** @@ -58,19 +58,19 @@ public class ShellTerminal extends AbstractTerminal implements ISession{ messagePrintln("Connecting to local target"); messagePrintln("-------------------------------------"); messagePrintln(""); - + String shellCommand = "/bin/bash"; IPath path = new Path(shellCommand); - - CommandLauncher launcher = new CommandLauncher(); - shellProcess = launcher.execute(path, new String[] {}, new String[] {}, new Path(".")); - //shellProcess = Runtime.getRuntime().exec(path.toOSString(), new String[] {}, new File(".")); + + //CommandLauncher launcher = new CommandLauncher(); + //shellProcess = launcher.execute(path, new String[] {}, new String[] {}, new Path(".")); + shellProcess = Runtime.getRuntime().exec(path.toOSString(), new String[] {}, new File(".")); input = shellProcess.getInputStream(); output = shellProcess.getOutputStream(); - + br = new BufferedReader(new InputStreamReader(input)); bw = new BufferedWriter(new OutputStreamWriter(output)); - + setIsConnected(true); }catch(Exception e){ -- 2.7.4