Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java2
-rw-r--r--profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java85
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java58
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF1
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java24
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/Messages.java35
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java138
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/messages.properties17
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/internal/localization.properties4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/messages.properties2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferenceConstants.java5
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferencePage.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/PreferenceInitializer.java9
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/RemoteScriptOptions.java8
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java72
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java130
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java2
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java12
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java132
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties2
25 files changed, 357 insertions, 418 deletions
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
index ecc0e65900..a553bae600 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java
@@ -21,7 +21,7 @@ import org.eclipse.linuxtools.profiling.launch.RemoteEnvProxyManager;
import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
/*
- * Abstract class with usefull functions for ProcessFactory classes.
+ * Abstract class with useful functions for ProcessFactory classes.
*/
public abstract class LinuxtoolsProcessFactory {
private static final String PATH = "PATH"; //$NON-NLS-1$
diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java
index 0f8c3a8289..a1f42cb73e 100644
--- a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java
+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java
@@ -220,7 +220,7 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory {
*
* @since 1.1
*/
- public Process exec(String cmdarray[], String[] envp, IFileStore dir, IProject project)
+ public Process exec(String[] cmdarray, String[] envp, IFileStore dir, IProject project)
throws IOException {
return exec(cmdarray, envp, dir, project, null);
}
@@ -239,7 +239,7 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory {
*
* @since 3.0
*/
- public Process exec(String cmdarray[], String[] envp, IFileStore dir, IProject project, PTY pty)
+ public Process exec(String[] cmdarray, String[] envp, IFileStore dir, IProject project, PTY pty)
throws IOException {
Process p = null;
@@ -276,9 +276,9 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory {
cmdarray = cmdlist.toArray(new String[0]);
if (pty == null) {
- p = launcher.execute(path, cmdarray, envp, changeToDir , new NullProgressMonitor());
+ p = launcher.execute(path, cmdarray, envp, changeToDir, new NullProgressMonitor());
} else {
- p = launcher.execute(path, cmdarray, envp, changeToDir , new NullProgressMonitor(), pty);
+ p = launcher.execute(path, cmdarray, envp, changeToDir, new NullProgressMonitor(), pty);
}
} catch (CoreException e) {
e.printStackTrace();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
index ddbbcab069..80536bb279 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/process/SystemtapProcessFactory.java
@@ -27,26 +27,42 @@ import com.jcraft.jsch.Session;
*/
public class SystemtapProcessFactory {
+ private static final int DEFAULT_PORT = 22;
+
/**
* Runs stap with the given arguments on the given host using the given
* credentials.
*
- * @param user
- * the user name to use on the remote machine.
- * @param host
- * the host where the systemtap process will be run.
- * @param password
- * password for authenticating with the given host.
+ * @param user the user name to use on the remote machine.
+ * @param host the host where the systemtap process will be run.
+ * @param password password for authenticating with the given host.
* @return a {@link Channel} connected to the remotely running process.
- * @throws JSchException
- * thrown if there are problems connecting to the remote
- * machine.
+ * @throws JSchException thrown if there are problems connecting to the remote machine.
*/
public static Channel execRemote(String[] args,
OutputStream out, OutputStream err, String user, String host,
String password) throws JSchException {
+ return execRemote(args, out, err, user, host, password, DEFAULT_PORT, null);
+ }
+
+ /**
+ * Runs stap with the given arguments on the given host using the given
+ * credentials.
+ *
+ * @param user the user name to use on the remote machine.
+ * @param host the host where the systemtap process will be run.
+ * @param password password for authenticating with the given host.
+ * @param envp an array with extra enviroment variables to be used when running
+ * the command. Set to <code>null</code> if none are needed.
+ * @return a {@link Channel} connected to the remotely running process.
+ * @throws JSchException thrown if there are problems connecting to the remote machine.
+ * @since 3.0
+ */
+ public static Channel execRemote(String[] args, OutputStream out,
+ OutputStream err, String user, String host, String password, int port, String[] envp)
+ throws JSchException {
JSch jsch = new JSch();
- Session session = jsch.getSession(user, host, 22);
+ Session session = jsch.getSession(user, host, port);
session.setPassword(password);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no"); //$NON-NLS-1$//$NON-NLS-2$
@@ -54,16 +70,21 @@ public class SystemtapProcessFactory {
session.connect();
StringBuilder command = new StringBuilder();
+ if (envp != null) {
+ for (String var : envp) {
+ command.append(String.format("export %s; ", var)); //$NON-NLS-1$
+ }
+ }
for (int i = 0; i < args.length; i++) {
- command.append(args[i]);
+ command.append(args[i] + ' ');
}
- Channel channel = session.openChannel("exec"); //$NON-NLS-1$
- ((ChannelExec) channel).setCommand(command.toString());
-
+ ChannelExec channel = (ChannelExec) session.openChannel("exec"); //$NON-NLS-1$
+ channel.setCommand(command.toString());
channel.setInputStream(null, true);
channel.setOutputStream(out, true);
channel.setExtOutputStream(err, true);
+ channel.connect();
return channel;
}
@@ -72,23 +93,37 @@ public class SystemtapProcessFactory {
* Runs stap with the given arguments on the given host using the given
* credentials and waits for the process to finish executing.
*
- * @param user
- * the user name to use on the remote machine.
- * @param host
- * the host where the systemtap process will be run.
- * @param password
- * password for authenticating with the given host.
+ * @param user the user name to use on the remote machine.
+ * @param host the host where the systemtap process will be run.
+ * @param password password for authenticating with the given host.
* @return a {@link Channel} connected to the remotely running process.
- * @throws JSchException
- * thrown if there are problems connecting to the remote
- * machine.
+ * @throws JSchException thrown if there are problems connecting to the remote machine.
*/
public static Channel execRemoteAndWait(String[] args,
OutputStream out, OutputStream err, String user, String host,
String password) throws JSchException {
- Channel channel = execRemote(args, out, err, user, host, password);
+ return execRemote(args, out, err, user, host, password, DEFAULT_PORT, null);
+ }
+
+ /**
+ * Runs stap with the given arguments on the given host using the given
+ * credentials and waits for the process to finish executing.
+ *
+ * @param user the user name to use on the remote machine.
+ * @param host the host where the systemtap process will be run.
+ * @param password password for authenticating with the given host.
+ * @param envp an array with extra enviroment variables to be used when running
+ * the command. Set to <code>null</code> if none are needed.
+ * @return a {@link Channel} connected to the remotely running process.
+ * @throws JSchException thrown if there are problems connecting to the remote machine.
+ * @since 3.0
+ */
+ public static Channel execRemoteAndWait(String[] args, OutputStream out,
+ OutputStream err, String user, String host, String password, int port, String[] envp)
+ throws JSchException {
+ Channel channel = execRemote(args, out, err, user, host, password, port, envp);
- while (!channel.isClosed()){
+ while (!channel.isClosed()) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
index 84422f4a69..3798e584a3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.structures/src/org/eclipse/linuxtools/systemtap/structures/runnable/Command.java
@@ -60,13 +60,20 @@ public class Command implements Runnable {
private List<IGobblerListener> errorListeners = new ArrayList<>(); //Only used to allow adding listeners before creating the StreamGobbler
private int returnVal = Integer.MAX_VALUE;
- private String[] cmd;
- private String[] envVars;
+ /**
+ * @since 3.0
+ */
+ protected final String[] cmd;
+ /**
+ * @since 3.0
+ */
+ protected final String[] envVars;
+
protected Process process;
/**
* @since 2.1
*/
- protected IProject project = null;
+ protected final IProject project;
private final LoggingStreamDaemon logger;
public static final int ERROR_STREAM = 0;
@@ -91,18 +98,13 @@ public class Command implements Runnable {
* This must be called by the implementing class in order to start the
* StreamGobbler.
* @param cmd The entire command to run
- * @param envVars List of all environment variables to use
- * @param project The project this script belongs to or null
+ * @param envVars List of all environment variables to use, or <code>null</code> if none
+ * @param project The project this script belongs to, or <code>null</code> if projectless
* @since 2.1
*/
public Command(String[] cmd, String[] envVars, IProject project) {
- if (cmd != null) {
- this.cmd = Arrays.copyOf(cmd, cmd.length);
- }
-
- if (envVars != null) {
- this.envVars = Arrays.copyOf(envVars, envVars.length);
- }
+ this.cmd = cmd != null ? Arrays.copyOf(cmd, cmd.length) : null;
+ this.envVars = envVars != null ? Arrays.copyOf(envVars, envVars.length) : null;
this.project = project;
logger = new LoggingStreamDaemon();
addInputStreamListener(logger);
@@ -115,7 +117,7 @@ public class Command implements Runnable {
*/
public void start() throws CoreException {
IStatus status = init();
- if(status.isOK()) {
+ if (status.isOK()) {
Thread t = new Thread(this, cmd[0]);
t.start();
started = true;
@@ -135,7 +137,7 @@ public class Command implements Runnable {
try {
process = RuntimeProcessFactory.getFactory().exec(cmd, envVars, project);
- if (process == null){
+ if (process == null) {
return new Status(IStatus.ERROR, StructuresPlugin.PLUGIN_ID, Messages.Command_failedToRunSystemtap);
}
@@ -155,11 +157,11 @@ public class Command implements Runnable {
* properly to the process itself.
* @since 2.0
*/
- protected void transferListeners(){
- for(IGobblerListener listener :inputListeners) {
+ protected void transferListeners() {
+ for (IGobblerListener listener : inputListeners) {
inputGobbler.addDataListener(listener);
}
- for(IGobblerListener listener: errorListeners) {
+ for (IGobblerListener listener : errorListeners) {
errorGobbler.addDataListener(listener);
}
}
@@ -185,15 +187,15 @@ public class Command implements Runnable {
* on this command.
*/
public synchronized void stop() {
- if(!stopped) {
- if(null != errorGobbler) {
+ if (!stopped) {
+ if (errorGobbler != null) {
errorGobbler.stop();
}
- if(null != inputGobbler) {
+ if (inputGobbler != null) {
inputGobbler.stop();
}
try {
- if(process != null){
+ if (process != null) {
process.waitFor();
}
} catch (InterruptedException e) {
@@ -249,7 +251,7 @@ public class Command implements Runnable {
* @param listener A listener to monitor the InputStream from the Process
*/
public void addInputStreamListener(IGobblerListener listener) {
- if(null != inputGobbler) {
+ if (inputGobbler != null) {
inputGobbler.addDataListener(listener);
} else {
inputListeners.add(listener);
@@ -261,7 +263,7 @@ public class Command implements Runnable {
* @param listener A listener to monitor the ErrorStream from the Process
*/
public void addErrorStreamListener(IGobblerListener listener) {
- if(null != errorGobbler) {
+ if (errorGobbler != null) {
errorGobbler.addDataListener(listener);
} else {
errorListeners.add(listener);
@@ -273,7 +275,7 @@ public class Command implements Runnable {
* @param listener An </code>IGobblerListener</code> that is monitoring the stream.
*/
public void removeInputStreamListener(IGobblerListener listener) {
- if(null != inputGobbler) {
+ if (inputGobbler != null) {
inputGobbler.removeDataListener(listener);
} else {
inputListeners.remove(listener);
@@ -285,7 +287,7 @@ public class Command implements Runnable {
* @param listener An </code>IGobblerListener</code> that is monitoring the stream.
*/
public void removeErrorStreamListener(IGobblerListener listener) {
- if(null != errorGobbler) {
+ if (errorGobbler != null) {
errorGobbler.removeDataListener(listener);
} else {
errorListeners.remove(listener);
@@ -306,7 +308,7 @@ public class Command implements Runnable {
* referenced after this is called.
*/
public void dispose() {
- if(!disposed) {
+ if (!disposed) {
stop();
disposed = true;
@@ -316,12 +318,12 @@ public class Command implements Runnable {
inputListeners = null;
errorListeners = null;
- if(null != inputGobbler) {
+ if (inputGobbler != null) {
inputGobbler.dispose();
}
inputGobbler = null;
- if(null != errorGobbler) {
+ if (errorGobbler != null) {
errorGobbler.dispose();
}
errorGobbler = null;
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
index f85df158f6..5609ab11d3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Bundle-Activator: org.eclipse.linuxtools.systemtap.ui.consolelog.internal.Consol
Bundle-Vendor: %bundleProvider
Bundle-Localization: plugin
Export-Package: org.eclipse.linuxtools.systemtap.ui.consolelog,
- org.eclipse.linuxtools.systemtap.ui.consolelog.dialogs,
org.eclipse.linuxtools.systemtap.ui.consolelog.internal,
org.eclipse.linuxtools.systemtap.ui.consolelog.preferences,
org.eclipse.linuxtools.systemtap.ui.consolelog.structures,
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
index 697b8bd899..a8994f4550 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/ScpExec.java
@@ -15,15 +15,12 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
import org.eclipse.linuxtools.systemtap.structures.process.SystemtapProcessFactory;
import org.eclipse.linuxtools.systemtap.structures.runnable.Command;
import org.eclipse.linuxtools.systemtap.structures.runnable.StreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.RemoteScriptOptions;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSchException;
@@ -34,17 +31,12 @@ public class ScpExec extends Command {
private Channel channel;
private RemoteScriptOptions remoteOptions;
- private String command;
/**
* @since 3.0
*/
- public ScpExec(String cmds[], RemoteScriptOptions remoteOptions) {
- super(cmds, null);
- this.command = ""; //$NON-NLS-1$
- for (String cmd:cmds) {
- this.command = this.command + " " + cmd; //$NON-NLS-1$
- }
+ public ScpExec(String[] cmd, RemoteScriptOptions remoteOptions, String[] envVars) {
+ super(cmd, envVars, null);
this.remoteOptions = remoteOptions;
}
@@ -52,7 +44,9 @@ public class ScpExec extends Command {
protected IStatus init() {
try {
channel = SystemtapProcessFactory.execRemote(
- new String[] { command }, System.out, System.err, remoteOptions.userName, remoteOptions.hostName, remoteOptions.password);
+ cmd, System.out, System.err,
+ remoteOptions.userName, remoteOptions.hostName, remoteOptions.password, remoteOptions.port,
+ envVars);
errorGobbler = new StreamGobbler(channel.getExtInputStream());
inputGobbler = new StreamGobbler(channel.getInputStream());
@@ -61,12 +55,6 @@ public class ScpExec extends Command {
return Status.OK_STATUS;
} catch (final JSchException|IOException e) {
final IStatus status = new Status(IStatus.ERROR, ConsoleLogPlugin.PLUGIN_ID, Messages.ScpExec_FileTransferFailed, e);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ScpExec_Error, e.getMessage(), status);
- }
- });
return status;
}
}
@@ -96,7 +84,7 @@ public class ScpExec extends Command {
*/
@Override
public synchronized void stop() {
- if(!stopped) {
+ if (!stopped) {
if(null != errorGobbler) {
errorGobbler.stop();
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/Messages.java
deleted file mode 100644
index c1ab2fb538..0000000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/Messages.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Red Hat, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.systemtap.ui.consolelog.dialogs;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @since 2.0
- */
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.linuxtools.systemtap.ui.consolelog.dialogs.messages"; //$NON-NLS-1$
- public static String SelectServerDialog_RemoteServerDetails;
- public static String SelectServerDialog_Host;
- public static String SelectServerDialog_User;
- public static String SelectServerDialog_Password;
- public static String SelectServerDialog_AlwaysConnectToHost;
- public static String SelectServerDialog_Cancel;
- public static String SelectServerDialog_Connect;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-
-}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java
deleted file mode 100644
index cd5c5f8c8f..0000000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/SelectServerDialog.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.systemtap.ui.consolelog.dialogs;
-
-import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
-import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-public class SelectServerDialog extends Dialog {
- private boolean result;
-
- public SelectServerDialog(Shell parent) {
- super(parent);
- }
-
- public boolean open() {
- if (ConsoleLogPlugin.getDefault().getPreferenceStore().getBoolean(ConsoleLogPreferenceConstants.REMEMBER_SERVER)) {
- return true;
- }
- result = false;
-
- Shell parent = getParent();
- final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- shell.setText(Messages.SelectServerDialog_RemoteServerDetails);
- shell.pack();
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.makeColumnsEqualWidth = false;
- shell.setLayout(layout);
-
- GridData dataLeft = new GridData();
- dataLeft.grabExcessHorizontalSpace = false;
- dataLeft.horizontalAlignment = SWT.LEFT;
- Label hostLabel = new Label(shell, SWT.NONE);
- hostLabel.setText(Messages.SelectServerDialog_Host);
- hostLabel.setLayoutData(dataLeft);
-
- GridData dataFill = new GridData();
- dataFill.grabExcessHorizontalSpace = true;
- dataFill.horizontalAlignment = SWT.FILL;
- final Text hostText = new Text(shell, SWT.SINGLE | SWT.BORDER);
- hostText.setLayoutData(dataFill);
- hostText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.HOST_NAME));
-
- Label userLabel = new Label(shell, SWT.NONE);
- userLabel.setText(Messages.SelectServerDialog_User);
- userLabel.setLayoutData(dataLeft);
-
- final Text userText = new Text(shell, SWT.SINGLE | SWT.BORDER);
- userText.setLayoutData(dataFill);
- userText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.SCP_USER));
-
- Label passwordLabel = new Label(shell, SWT.NONE);
- passwordLabel.setText(Messages.SelectServerDialog_Password);
- passwordLabel.setLayoutData(dataLeft);
-
- final Text passwordText = new Text(shell, SWT.SINGLE | SWT.BORDER);
- passwordText.setEchoChar('*');
- passwordText.setLayoutData(dataFill);
- passwordText.setText(ConsoleLogPlugin.getDefault().getPreferenceStore().getString(ConsoleLogPreferenceConstants.SCP_PASSWORD));
-
-
- GridData data = new GridData();
- data.horizontalAlignment = SWT.LEFT;
- data.horizontalSpan = 2;
- final Button rememberButton = new Button(shell, SWT.CHECK);
- rememberButton.setLayoutData(data);
- rememberButton.setText(Messages.SelectServerDialog_AlwaysConnectToHost);
-
- data = new GridData();
- data.horizontalAlignment = SWT.RIGHT;
- Button cancelButton = new Button(shell, SWT.PUSH);
- cancelButton.setLayoutData(data);
- cancelButton.setSize(50, 100);
- cancelButton.setText(Messages.SelectServerDialog_Cancel);
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- result = false;
- shell.dispose();
- }
- });
-
- data = new GridData();
- data.horizontalAlignment = SWT.RIGHT;
- Button connectButton = new Button(shell, SWT.PUSH);
- connectButton.setLayoutData(data);
- connectButton.setSize(50, 100);
- connectButton.setText(Messages.SelectServerDialog_Connect);
- connectButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // FIXME: no error handling is done, should probably be
- // pushed down to the connection level
- // Set the preferences to this new info.
- ConsoleLogPlugin.getDefault().getPreferenceStore().setValue(ConsoleLogPreferenceConstants.HOST_NAME, hostText.getText());
- ConsoleLogPlugin.getDefault().getPreferenceStore().setValue(ConsoleLogPreferenceConstants.REMEMBER_SERVER, rememberButton.getSelection());
- ConsoleLogPlugin.getDefault().getPreferenceStore().setValue(ConsoleLogPreferenceConstants.SCP_PASSWORD, passwordText.getText());
- ConsoleLogPlugin.getDefault().getPreferenceStore().setValue(ConsoleLogPreferenceConstants.SCP_USER, userText.getText());
- result = true;
-
- shell.close();
- }
- });
-
- shell.pack();
- shell.open();
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- return result;
- }
-}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/messages.properties
deleted file mode 100644
index ce7dbcde24..0000000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/dialogs/messages.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2013 Red Hat, Inc.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Red Hat, Inc. - initial API and implementation
-###############################################################################
-SelectServerDialog_RemoteServerDetails=Remote Server Details
-SelectServerDialog_Host=Host:
-SelectServerDialog_User=User:
-SelectServerDialog_Password=Password:
-SelectServerDialog_AlwaysConnectToHost=Always connect to this host.
-SelectServerDialog_Cancel=Cancel
-SelectServerDialog_Connect=Connect
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/internal/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/internal/localization.properties
index efeae3898b..daff96aa3f 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/internal/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/internal/localization.properties
@@ -4,7 +4,9 @@ ErrorStreamDaemon.Password=Password:
ErrorView.Description=Description
-ScriptConsole.ErrorKillingStap=Error killing stap process
+ScriptConsole.ErrorRunningStapTitle=Error Running SystemTap Script
+ScriptConsole.ErrorRunningStapMessage=The SystemTap script could not be run. See the error details below for more information.
+ScriptConsole.ErrorKillingStap=Error Killing SystemTap Process
ScriptConsole.Problem=Problem
ScriptConsole.ErrorSavingLog=Error saving the log file.
ScriptConsole.Terminated=<terminated>
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/messages.properties
index 6165fba4f8..b1b633aaf6 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/messages.properties
@@ -11,4 +11,4 @@
ScpExec_errorConnectingToServer=Connecting to remote server failed
ScpExec_ConnTimedOut=Connection Timed Out
ScpExec_Error=Error
-ScpExec_FileTransferFailed=File Transfer failed
+ScpExec_FileTransferFailed=Remote file transfer failed
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferenceConstants.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferenceConstants.java
index 48c71656ec..0dee59e805 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferenceConstants.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferenceConstants.java
@@ -12,13 +12,8 @@
package org.eclipse.linuxtools.systemtap.ui.consolelog.preferences;
public interface ConsoleLogPreferenceConstants {
- //ide
String HOST_NAME = "host"; //$NON-NLS-1$
String PORT_NUMBER = "port"; //$NON-NLS-1$
- String DB_COMMIT = "commit"; //$NON-NLS-1$
- String SAVE_LENGTH = "saveLength"; //$NON-NLS-1$
- String REMEMBER_SERVER = "rememberServer"; //$NON-NLS-1$
String SCP_USER = "scpuser"; //$NON-NLS-1$
String SCP_PASSWORD = "scppassword"; //$NON-NLS-1$
- String REMEMBER_SCPUSER = "rememberscpuser"; //$NON-NLS-1$
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferencePage.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferencePage.java
index 2215c5fc69..3ae0377336 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferencePage.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/ConsoleLogPreferencePage.java
@@ -11,7 +11,6 @@
package org.eclipse.linuxtools.systemtap.ui.consolelog.preferences;
-import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
@@ -44,13 +43,6 @@ public class ConsoleLogPreferencePage extends FieldEditorPreferencePage implemen
getFieldEditorParent());
passwordField.getTextControl(getFieldEditorParent()).setEchoChar('*');
addField(passwordField);
-
- addField(new BooleanFieldEditor(ConsoleLogPreferenceConstants.REMEMBER_SERVER,
- Messages.ConsoleLogPreferencePage_AlwaysConnectToHost, getFieldEditorParent()));
-
- addField(new IntegerFieldEditor(ConsoleLogPreferenceConstants.SAVE_LENGTH,
- Messages.ConsoleLogPreferencePage_SecondsToSaveData, getFieldEditorParent()));
-
}
@Override
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/PreferenceInitializer.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/PreferenceInitializer.java
index d6d2a29237..3d381e1420 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/PreferenceInitializer.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/preferences/PreferenceInitializer.java
@@ -1,4 +1,5 @@
- /* Copyright (c) 2006 IBM Corporation.
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,13 +27,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
//ide
store.setDefault(ConsoleLogPreferenceConstants.HOST_NAME, "localhost"); //$NON-NLS-1$
store.setDefault(ConsoleLogPreferenceConstants.PORT_NUMBER, 22462);
- store.setDefault(ConsoleLogPreferenceConstants.DB_COMMIT, false);
- store.setDefault(ConsoleLogPreferenceConstants.SAVE_LENGTH, 5);
- store.setDefault(ConsoleLogPreferenceConstants.REMEMBER_SERVER, false);
store.setDefault(ConsoleLogPreferenceConstants.SCP_USER, "guest"); //$NON-NLS-1$
store.setDefault(ConsoleLogPreferenceConstants.SCP_PASSWORD, "welcome"); //$NON-NLS-1$
- store.setDefault(ConsoleLogPreferenceConstants.REMEMBER_SCPUSER, false);
- }
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/RemoteScriptOptions.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/RemoteScriptOptions.java
index c81f2a6544..6dd18f355c 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/RemoteScriptOptions.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/RemoteScriptOptions.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Red Hat - Andrew Ferrazzutti
+ * Red Hat - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.systemtap.ui.consolelog.structures;
@@ -16,20 +16,20 @@ import org.eclipse.linuxtools.internal.systemtap.ui.consolelog.structures.Messag
* A class containing all properties relating to a remote run of a SystemTap
* script, such as user name and password.
* @since 3.0
- * @author Andrew Ferrazzutti
*/
public class RemoteScriptOptions {
-
public final String userName;
public final String password;
public final String hostName;
+ public final int port;
- public RemoteScriptOptions(String userName, String password, String hostName) {
+ public RemoteScriptOptions(String userName, String password, String hostName, int port) {
if (userName == null || password == null || hostName == null) {
throw new IllegalArgumentException(Messages.RemoteScriptOptions_invalidArguments);
}
this.userName = userName;
this.password = password;
this.hostName = hostName;
+ this.port = port;
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
index debc559514..10b6b34e5d 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.consolelog/src/org/eclipse/linuxtools/systemtap/ui/consolelog/structures/ScriptConsole.java
@@ -102,9 +102,9 @@ public class ScriptConsole extends IOConsole {
IConsole ic[] = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
if (null != ic) {
for (IConsole consoleIterator: ic) {
- if (consoleIterator instanceof ScriptConsole){
+ if (consoleIterator instanceof ScriptConsole) {
ScriptConsole activeConsole = (ScriptConsole) consoleIterator;
- if(activeConsole.getName().endsWith(name) && activeConsole.isRunning()) {
+ if (activeConsole.getName().endsWith(name) && activeConsole.isRunning()) {
return true;
}
}
@@ -127,12 +127,12 @@ public class ScriptConsole extends IOConsole {
IConsole ic[] = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
//Prevent running the same script twice
- if(null != ic) {
+ if (ic != null) {
ScriptConsole activeConsole;
for (IConsole consoleIterator: ic) {
- if (consoleIterator instanceof ScriptConsole){
+ if (consoleIterator instanceof ScriptConsole) {
activeConsole = (ScriptConsole) consoleIterator;
- if(activeConsole.getName().endsWith(name)) {
+ if (activeConsole.getName().endsWith(name)) {
//Stop any script currently running, and terminate stream listeners.
if (activeConsole.isRunning()) {
activeConsole.stop();
@@ -159,11 +159,11 @@ public class ScriptConsole extends IOConsole {
}
}
- if(null == console) {
+ if (console == null) {
console = new ScriptConsole(name, null);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
}
- } catch(NullPointerException npe) {
+ } catch (NullPointerException npe) {
console = null;
}
return console;
@@ -178,10 +178,10 @@ public class ScriptConsole extends IOConsole {
IConsole ic[] = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
ScriptConsole console;
- for(IConsole con : ic) {
- if (con instanceof ScriptConsole){
+ for (IConsole con : ic) {
+ if (con instanceof ScriptConsole) {
console = (ScriptConsole)con;
- if(console.isRunning()){
+ if (console.isRunning()) {
return true;
}
}
@@ -197,8 +197,8 @@ public class ScriptConsole extends IOConsole {
IConsole ic[] = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
ScriptConsole console;
- for(IConsole con : ic) {
- if (con instanceof ScriptConsole){
+ for (IConsole con : ic) {
+ if (con instanceof ScriptConsole) {
console = (ScriptConsole)con;
console.stop();
}
@@ -225,7 +225,7 @@ public class ScriptConsole extends IOConsole {
private void createErrorDaemon(IErrorParser parser) {
ErrorView errorView = null;
IViewPart ivp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ErrorView.ID);
- if(ivp instanceof ErrorView) {
+ if (ivp instanceof ErrorView) {
errorView = ((ErrorView)ivp);
}
errorDaemon = new ErrorStreamDaemon(this, errorView, parser);
@@ -248,15 +248,15 @@ public class ScriptConsole extends IOConsole {
if (waitingToStart()) {
return;
}
- cmd = new ScpExec(command, remoteOptions);
+ cmd = new ScpExec(command, remoteOptions, envVars);
- this.stopCommand = new Runnable() {
+ stopCommand = new Runnable() {
private final Command stopcmd = cmd;
private final String stopString = getStopString();
@Override
public void run() {
- ScpExec stop = new ScpExec(new String[]{stopString}, remoteOptions);
+ ScpExec stop = new ScpExec(new String[]{stopString}, remoteOptions, null);
try {
synchronized (stopcmd) {
while (stopcmd.isRunning()) {
@@ -265,7 +265,7 @@ public class ScriptConsole extends IOConsole {
}
}
} catch (CoreException e) {
- // Failed to start the 'stop' process. Ignore.
+ ExceptionErrorDialog.openError(Localization.getString("ScriptConsole.ErrorKillingStap"), e.getMessage(), e); //$NON-NLS-1$
} catch (InterruptedException e) {
// Wait was interrupted. Exit.
}
@@ -291,7 +291,7 @@ public class ScriptConsole extends IOConsole {
cmd = new Command(command, envVars, project);
final IProject proj = project;
- this.stopCommand = new Runnable() {
+ stopCommand = new Runnable() {
private final Command stopcmd = cmd;
String stopString = getStopString();
@@ -305,7 +305,7 @@ public class ScriptConsole extends IOConsole {
}
}
} catch (IOException e) {
- ExceptionErrorDialog.openError(Localization.getString("ScriptConsole.ErrorKillingStap"), e); //$NON-NLS-1$
+ ExceptionErrorDialog.openError(Localization.getString("ScriptConsole.ErrorKillingStap"), e.getMessage(), e); //$NON-NLS-1$
} catch (InterruptedException e) {
//Wait was interrupted. Exit.
}
@@ -314,7 +314,7 @@ public class ScriptConsole extends IOConsole {
this.run(cmd, errorParser);
}
- private void run(final Command cmd, IErrorParser errorParser){
+ private void run(final Command cmd, IErrorParser errorParser) {
final Runnable onCmdStop = new Runnable() {
@Override
public void run() {
@@ -350,7 +350,9 @@ public class ScriptConsole extends IOConsole {
try {
cmd.start();
} catch (final CoreException e) {
- ExceptionErrorDialog.openError(e.getMessage(), e);
+ ExceptionErrorDialog.openError(
+ Localization.getString("ScriptConsole.ErrorRunningStapTitle"), //$NON-NLS-1$
+ Localization.getString("ScriptConsole.ErrorRunningStapMessage"), e);//$NON-NLS-1$
cmd.dispose();
return;
}
@@ -379,7 +381,7 @@ public class ScriptConsole extends IOConsole {
});
}
- private synchronized void notifyConsoleObservers(){
+ private synchronized void notifyConsoleObservers() {
boolean started = hasStarted();
boolean running = isRunning();
for (ScriptConsoleObserver observer : inactiveConsoleObservers) {
@@ -394,7 +396,7 @@ public class ScriptConsole extends IOConsole {
/**
* @since 2.0
*/
- public synchronized void addScriptConsoleObserver(ScriptConsoleObserver observer){
+ public synchronized void addScriptConsoleObserver(ScriptConsoleObserver observer) {
activeConsoleObservers.add(observer);
observer.runningStateChanged(hasStarted(), !isRunning());
}
@@ -402,7 +404,7 @@ public class ScriptConsole extends IOConsole {
/**
* @since 3.0
*/
- public synchronized void removeScriptConsoleObserver(ScriptConsoleObserver observer){
+ public synchronized void removeScriptConsoleObserver(ScriptConsoleObserver observer) {
if (activeConsoleObservers.contains(observer)) {
inactiveConsoleObservers.add(observer);
}
@@ -478,14 +480,14 @@ public class ScriptConsole extends IOConsole {
public synchronized void stop() {
if (isRunning() && (stopCommandThread == null || !stopCommandThread.isAlive())) {
// Stop the underlying stap process
- stopCommandThread = new Thread(this.stopCommand);
+ stopCommandThread = new Thread(stopCommand);
stopCommandThread.start();
}
}
- private String getModuleName(){
- if(this.moduleName == null){
- moduleName = this.getName();
+ private String getModuleName() {
+ if (moduleName == null) {
+ moduleName = getName();
int lastSlash = moduleName.lastIndexOf('/')+1;
if (lastSlash < 0) {
lastSlash = 0;
@@ -495,10 +497,10 @@ public class ScriptConsole extends IOConsole {
moduleName = moduleName.substring(lastSlash, lastDot);
}
}
- return this.moduleName;
+ return moduleName;
}
- private String getStopString(){
+ private String getStopString() {
return "pkill -SIGINT -f stapio.*"+ getModuleName(); //$NON-NLS-1$
}
/**
@@ -506,16 +508,16 @@ public class ScriptConsole extends IOConsole {
*/
@Override
public void dispose() {
- if(!isDisposed()) {
- if(null != cmd) {
+ if (!isDisposed()) {
+ if (cmd != null) {
cmd.dispose();
}
cmd = null;
- if(null != errorDaemon) {
+ if (errorDaemon != null) {
errorDaemon.dispose();
}
errorDaemon = null;
- if(null != consoleDaemon) {
+ if (consoleDaemon != null) {
consoleDaemon.dispose();
}
consoleDaemon = null;
@@ -529,7 +531,7 @@ public class ScriptConsole extends IOConsole {
@Override
public void setName(String name) {
super.setName(name);
- if(null != ConsolePlugin.getDefault()) {
+ if (ConsolePlugin.getDefault() != null) {
ConsolePlugin.getDefault().getConsoleManager().refresh(this);
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
index fad891dbbc..bf9eeea4c0 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDEPlugin.java
@@ -97,8 +97,12 @@ public class IDEPlugin extends AbstractUIPlugin {
if (path == null) {
path = ""; //$NON-NLS-1$
}
+ int port = p.getInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+ if (port == 0) {
+ port = p.getDefaultInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+ }
try {
- return new URI("ssh", user, host, -1, path, null, null); //$NON-NLS-1$
+ return new URI("ssh", user, host, port, path, null, null); //$NON-NLS-1$
} catch (URISyntaxException uri) {
return null;
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
index ca6b379793..e154788ef8 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/Messages.java
@@ -74,6 +74,8 @@ public class Messages extends NLS {
public static String SystemTapScriptLaunchConfigurationTab_password;
public static String SystemTapScriptLaunchConfigurationTab_user;
public static String SystemTapScriptLaunchConfigurationTab_host;
+ public static String SystemTapScriptLaunchConfigurationTab_useDefaultPort;
+ public static String SystemTapScriptLaunchConfigurationTab_port;
public static String SystemTapScriptLaunchConfigurationTab_runLocally;
public static String SystemTapScriptLaunchConfigurationTab_hostname;
public static String SystemTapScriptLaunchConfigurationTab_general;
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
index c3eb692257..03b9130e81 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
@@ -44,7 +44,8 @@ import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.RemoteScriptOpt
public class SystemTapScriptLaunchConfigurationDelegate extends
LaunchConfigurationDelegate {
- private static String LOCALHOST = "localhost"; //$NON-NLS-1$
+ static final String LOCALHOST = "localhost"; //$NON-NLS-1$
+ static final int DEFAULT_PORT = 22;
static final String CONFIGURATION_TYPE = "org.eclipse.linuxtools.systemtap.ui.ide.SystemTapLaunchConfigurationType"; //$NON-NLS-1$
private IProject[] scriptProject;
@@ -139,7 +140,9 @@ public class SystemTapScriptLaunchConfigurationDelegate extends
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_NAME_ATTR, ""), //$NON-NLS-1$
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_PASS_ATTR, ""), //$NON-NLS-1$
configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.LOCAL_HOST_ATTR, true) ? LOCALHOST :
- configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.HOST_NAME_ATTR, LOCALHOST)));
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.HOST_NAME_ATTR, LOCALHOST),
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USE_DEFAULT_PORT_ATTR, true) ? DEFAULT_PORT :
+ configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.PORT_ATTR, DEFAULT_PORT)));
String value = configuration.getAttribute(IDEPreferenceConstants.STAP_CMD_OPTION[IDEPreferenceConstants.KEY], ""); //$NON-NLS-1$
if (!value.isEmpty()) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
index 8c612f2a88..e57aefe74a 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationTab.java
@@ -32,6 +32,8 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -56,19 +58,42 @@ public class SystemTapScriptLaunchConfigurationTab extends
static final String USER_PASS_ATTR = "userPassword"; //$NON-NLS-1$
static final String LOCAL_HOST_ATTR = "executeOnLocalHost"; //$NON-NLS-1$
static final String HOST_NAME_ATTR = "hostName"; //$NON-NLS-1$
+ static final String PORT_ATTR = "port"; //$NON-NLS-1$
+ static final String USE_DEFAULT_PORT_ATTR = "useDefaultPort"; //$NON-NLS-1$
private Text scriptPathText;
private Button currentUserCheckButton;
private Text userNameText;
+ private Label userNameLabel;
private Text userPasswordText;
+ private Label userPasswordLabel;
private Button localHostCheckButton;
private Group hostSettingsGroup;
private Text hostNameText;
- private Label userNameLabel;
- private Label userPasswordLabel;
- private Label hostNamelabel;
+ private Label hostNameLabel;
+ private Text portText;
+ private Label portLabel;
+ private Button portCheckButton;
private FileDialog fileDialog;
+ SelectionListener checkListener = new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ update();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ update();
+ }
+
+ private void update() {
+ updateLaunchConfigurationDialog();
+ }
+
+ };
+
/**
* @return The path of the chosen script the Run Configuration will be applied to,
* or <code>null</code> if no file exists at the given path.
@@ -81,7 +106,7 @@ public class SystemTapScriptLaunchConfigurationTab extends
@Override
public void createControl(Composite parent) {
- this.fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
+ fileDialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN);
fileDialog.setText(Messages.SystemTapScriptLaunchConfigurationTab_selectScript);
fileDialog.setFilterPath(Platform.getLocation().toOSString());
@@ -98,7 +123,7 @@ public class SystemTapScriptLaunchConfigurationTab extends
layout = new GridLayout();
layout.numColumns = 2;
scriptSettingsGroup.setLayout(layout);
- this.scriptPathText = new Text(scriptSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ scriptPathText = new Text(scriptSettingsGroup, SWT.SINGLE | SWT.BORDER);
scriptPathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scriptPathText.addModifyListener(new ModifyListener() {
@Override
@@ -133,44 +158,27 @@ public class SystemTapScriptLaunchConfigurationTab extends
layout.numColumns = 2;
userSettingsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- this.currentUserCheckButton = new Button(userSettingsGroup, SWT.CHECK);
+ currentUserCheckButton = new Button(userSettingsGroup, SWT.CHECK);
currentUserCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_currentUser);
currentUserCheckButton.setSelection(true);
gridData = new GridData();
gridData.horizontalSpan = 2;
currentUserCheckButton.setLayoutData(gridData);
+ currentUserCheckButton.addSelectionListener(checkListener);
- this.userNameLabel = new Label(userSettingsGroup, SWT.NONE);
+ userNameLabel = new Label(userSettingsGroup, SWT.NONE);
userNameLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_username);
- this.userNameText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ userNameText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER);
userNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- this.userPasswordLabel = new Label(userSettingsGroup, SWT.NONE);
+ userPasswordLabel = new Label(userSettingsGroup, SWT.NONE);
userPasswordLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_password);
- this.userPasswordText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
+ userPasswordText = new Text(userSettingsGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
userPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
userSettingsGroup.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, false));
userSettingsGroup.setText(Messages.SystemTapScriptLaunchConfigurationTab_user);
- currentUserCheckButton.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- update();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- update();
- }
-
- private void update() {
- boolean enable = !currentUserCheckButton.getSelection();
- setUserGroupEnablement(enable);
- updateLaunchConfigurationDialog();
- }
- });
-
userNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -193,32 +201,51 @@ public class SystemTapScriptLaunchConfigurationTab extends
hostSettingsGroup.setLayout(layout);
layout.numColumns = 2;
- this.localHostCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
+ localHostCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
localHostCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_runLocally);
gridData = new GridData();
gridData.horizontalSpan = 2;
- this.hostNamelabel = new Label(hostSettingsGroup, SWT.NONE);
- hostNamelabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_hostname);
- this.hostNameText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ hostNameLabel = new Label(hostSettingsGroup, SWT.NONE);
+ hostNameLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_hostname);
+ hostNameText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
hostNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
localHostCheckButton.setLayoutData(gridData);
- localHostCheckButton.addSelectionListener(new SelectionListener() {
+ localHostCheckButton.addSelectionListener(checkListener);
+ hostNameText.addModifyListener(new ModifyListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
- update();
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
}
+ });
+ portCheckButton = new Button(hostSettingsGroup, SWT.CHECK);
+ portCheckButton.setText(Messages.SystemTapScriptLaunchConfigurationTab_useDefaultPort);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ portCheckButton.setLayoutData(gridData);
+ portCheckButton.addSelectionListener(checkListener);
+
+ portLabel = new Label(hostSettingsGroup, SWT.NONE);
+ portLabel.setText(Messages.SystemTapScriptLaunchConfigurationTab_port);
+ portText = new Text(hostSettingsGroup, SWT.SINGLE | SWT.BORDER);
+ portText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ portText.setTextLimit(5);
+ portText.addVerifyListener(new VerifyListener() {
@Override
- public void widgetDefaultSelected(SelectionEvent e) {
- update();
- }
-
- private void update() {
- updateLaunchConfigurationDialog();
+ public void verifyText(VerifyEvent e) {
+ if (e.keyCode == SWT.BS) {
+ return;
+ }
+ for (int i = 0, n = e.text.length(); i < n; i++) {
+ if (!Character.isDigit(e.text.charAt(i))) {
+ e.doit = false;
+ return;
+ }
+ }
}
});
- hostNameText.addModifyListener(new ModifyListener() {
+ portText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog();
@@ -237,18 +264,26 @@ public class SystemTapScriptLaunchConfigurationTab extends
}
private void setHostGroupEnablement(boolean enable) {
- hostNamelabel.setEnabled(enable);
hostNameText.setEnabled(enable);
+ hostNameLabel.setEnabled(enable);
+ portCheckButton.setEnabled(enable);
+
+ boolean portEnabled = enable && !portCheckButton.getSelection();
+ portText.setEnabled(portEnabled);
+ portLabel.setEnabled(portEnabled);
}
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- configuration.setAttribute(SCRIPT_PATH_ATTR, this.getSelectedScriptPath());
+ configuration.setAttribute(SCRIPT_PATH_ATTR, getSelectedScriptPath());
configuration.setAttribute(CURRENT_USER_ATTR, true);
configuration.setAttribute(USER_NAME_ATTR, ""); //$NON-NLS-1$
configuration.setAttribute(USER_PASS_ATTR, ""); //$NON-NLS-1$
configuration.setAttribute(LOCAL_HOST_ATTR, true);
configuration.setAttribute(HOST_NAME_ATTR, ""); //$NON-NLS-1$
+ configuration.setAttribute(PORT_ATTR,
+ SystemTapScriptLaunchConfigurationDelegate.DEFAULT_PORT);
+ configuration.setAttribute(USE_DEFAULT_PORT_ATTR, true);
}
@Override
@@ -260,6 +295,9 @@ public class SystemTapScriptLaunchConfigurationTab extends
this.userPasswordText.setText(configuration.getAttribute(USER_PASS_ATTR, "")); //$NON-NLS-1$
this.localHostCheckButton.setSelection(configuration.getAttribute(LOCAL_HOST_ATTR, true));
this.hostNameText.setText(configuration.getAttribute(HOST_NAME_ATTR, "")); //$NON-NLS-1$
+ this.portText.setText(Integer.toString(configuration.getAttribute(PORT_ATTR,
+ SystemTapScriptLaunchConfigurationDelegate.DEFAULT_PORT)));
+ this.portCheckButton.setSelection(configuration.getAttribute(USE_DEFAULT_PORT_ATTR, true));
} catch (CoreException e) {
ExceptionErrorDialog.openError(Messages.SystemTapScriptLaunchConfigurationTab_errorInitializingTab, e);
}
@@ -274,6 +312,10 @@ public class SystemTapScriptLaunchConfigurationTab extends
configuration.setAttribute(LOCAL_HOST_ATTR, this.localHostCheckButton.getSelection());
configuration.setAttribute(HOST_NAME_ATTR, this.hostNameText.getText());
+ configuration.setAttribute(USE_DEFAULT_PORT_ATTR, portCheckButton.getSelection());
+ String portString = this.portText.getText();
+ configuration.setAttribute(PORT_ATTR, !portString.isEmpty() ? Integer.valueOf(portString) : 0);
+
boolean enable = !currentUserCheckButton.getSelection();
setUserGroupEnablement(enable);
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
index 7333366dd4..c24a7b7c1d 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/messages.properties
@@ -65,13 +65,15 @@ SystemTapScriptGraphOptionsTab_generateFromPrintsEmpty=No valid printf statement
SystemTapScriptLaunchConfigurationTab_script=Systemtap Script:
SystemTapScriptLaunchConfigurationTab_browse=Browse...
-SystemTapScriptLaunchConfigurationTab_currentUser=Execute script as current user.
+SystemTapScriptLaunchConfigurationTab_currentUser=Execute script as current user
SystemTapScriptLaunchConfigurationTab_username=User Name:
SystemTapScriptLaunchConfigurationTab_password=Password:
SystemTapScriptLaunchConfigurationTab_user=User:
SystemTapScriptLaunchConfigurationTab_host=Host:
-SystemTapScriptLaunchConfigurationTab_runLocally=Run script on localhost.
+SystemTapScriptLaunchConfigurationTab_runLocally=Run script on localhost
SystemTapScriptLaunchConfigurationTab_hostname=Host Name:
+SystemTapScriptLaunchConfigurationTab_useDefaultPort=Use default port
+SystemTapScriptLaunchConfigurationTab_port=Port:
SystemTapScriptLaunchConfigurationTab_general=General
SystemTapScriptLaunchConfigurationTab_tabName=Systemtap
SystemTapScriptLaunchConfigurationTab_selectScript=Select Systemtap Script
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
index 8dd1c6f218..e24af415b0 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/Messages.java
@@ -23,6 +23,8 @@ public class Messages extends NLS {
public static String TapsetParser_CannotRunStapMessage;
public static String TapsetParser_CannotRunStapTitle;
public static String TapsetParser_ErrorRunningSystemtap;
+ public static String TapsetParser_RemoteCredentialErrorTitle;
+ public static String TapsetParser_RemoteCredentialErrorMessage;
public static String SharedParser_NoOutput;
static {
// initialize resource bundle
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
index 77e446c6bb..833722a394 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -29,6 +29,7 @@ import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.PreferenceCo
import org.eclipse.linuxtools.man.parser.ManPage;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener;
+import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -141,6 +142,7 @@ public final class TapsetLibrary {
private static void init() {
IPreferenceStore preferenceStore = IDEPlugin.getDefault().getPreferenceStore();
preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ ConsoleLogPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(credentialChangeListener);
functionParser.addListener(functionCompletionListener);
probeParser.addListener(probeCompletionListener);
@@ -158,7 +160,8 @@ public final class TapsetLibrary {
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property.equals(IDEPreferenceConstants.P_TAPSETS)
- || property.equals(PreferenceConstants.P_ENV.SYSTEMTAP_TAPSET.toPrefKey())) {
+ || property.equals(PreferenceConstants.P_ENV.SYSTEMTAP_TAPSET.toPrefKey())
+ || property.equals(IDEPreferenceConstants.P_REMOTE_PROBES)) {
runStapParser();
} else if (property.equals(IDEPreferenceConstants.P_STORED_TREE)) {
if (event.getNewValue().equals(false)) {
@@ -173,6 +176,13 @@ public final class TapsetLibrary {
}
};
+ private static final IPropertyChangeListener credentialChangeListener = new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ runStapParser();
+ }
+ };
+
private static class ParseCompletionListener implements IUpdateListener {
TreeTapsetParser parser;
public ParseCompletionListener(TreeTapsetParser parser) {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
index 62812afb8b..b25dcbf081 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/TapsetParser.java
@@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.structures;
import java.io.File;
import java.io.IOException;
+import java.net.ConnectException;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -31,9 +32,13 @@ import org.eclipse.linuxtools.systemtap.structures.runnable.StringStreamGobbler;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSchException;
@@ -52,6 +57,7 @@ import com.jcraft.jsch.JSchException;
public abstract class TapsetParser extends Job {
private static AtomicBoolean displayingError = new AtomicBoolean(false);
+ private static AtomicBoolean displayingCredentialDialog = new AtomicBoolean(false);
private ArrayList<IUpdateListener> listeners = new ArrayList<>();
private boolean cancelRequested = false;
@@ -135,6 +141,7 @@ public abstract class TapsetParser extends Job {
.getString(IDEPreferenceConstants.P_TAPSETS).split(File.pathSeparator);
boolean noTapsets = tapsets[0].trim().isEmpty();
boolean noOptions = options[0].trim().isEmpty();
+ final boolean remote = IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES);
int size = probe != null ? 2 : 1;
if (!noTapsets) {
@@ -147,7 +154,8 @@ public abstract class TapsetParser extends Job {
args = new String[size];
args[0] = "stap"; //$NON-NLS-1$
if (probe != null) {
- args[size-1] = probe;
+ // Workaround for the fact that remote & local execution methods use string args differently
+ args[size - 1] = !remote ? probe : '\'' + probe + '\'';
}
//Add extra tapset directories
@@ -158,53 +166,18 @@ public abstract class TapsetParser extends Job {
}
}
if (!noOptions) {
- for (int i = 0, s = noTapsets ? 1 : 1 + tapsets.length*2; i<options.length; i++) {
+ for (int i = 0, s = noTapsets ? 1 : 1 + tapsets.length*2; i < options.length; i++) {
args[s + i] = options[i];
}
}
try {
- if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
- StringOutputStream str = new StringOutputStream();
- StringOutputStream strErr = new StringOutputStream();
-
- IPreferenceStore p = ConsoleLogPlugin.getDefault().getPreferenceStore();
- String user = p.getString(ConsoleLogPreferenceConstants.SCP_USER);
- String host = p.getString(ConsoleLogPreferenceConstants.HOST_NAME);
- String password = p.getString(ConsoleLogPreferenceConstants.SCP_PASSWORD);
-
- Channel channel = SystemtapProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password);
- if (channel == null) {
- displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
- }
-
- return (!getErrors ? str : strErr).toString();
+ if (!remote) {
+ return runLocalStap(args, getErrors);
} else {
- Process process = RuntimeProcessFactory.getFactory().exec(
- args, EnvironmentVariablesPreferencePage.getEnvironmentVariables(), null);
- if (process == null) {
- displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
- return null;
- }
-
- StringStreamGobbler gobbler = new StringStreamGobbler(process.getInputStream());
- StringStreamGobbler egobbler = null;
- gobbler.start();
- if (getErrors) {
- egobbler = new StringStreamGobbler(process.getErrorStream());
- egobbler.start();
- }
- process.waitFor();
- gobbler.stop();
- if (egobbler == null) {
- return gobbler.getOutput().toString();
- } else {
- egobbler.stop();
- return egobbler.getOutput().toString();
- }
+ return runRemoteStapAttempt(args, getErrors);
}
-
- } catch (JSchException|IOException e) {
+ } catch (IOException e) {
displayError(Messages.TapsetParser_ErrorRunningSystemtap, e.getMessage());
} catch (InterruptedException e) {
// Interrupted; exit.
@@ -213,6 +186,83 @@ public abstract class TapsetParser extends Job {
return null;
}
+ private String runLocalStap(String[] args, boolean getErrors) throws IOException, InterruptedException {
+ Process process = RuntimeProcessFactory.getFactory().exec(
+ args, EnvironmentVariablesPreferencePage.getEnvironmentVariables(), null);
+ if (process == null) {
+ displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
+ return null;
+ }
+
+ StringStreamGobbler gobbler = new StringStreamGobbler(process.getInputStream());
+ StringStreamGobbler egobbler = null;
+ gobbler.start();
+ if (getErrors) {
+ egobbler = new StringStreamGobbler(process.getErrorStream());
+ egobbler.start();
+ }
+ process.waitFor();
+ gobbler.stop();
+ if (egobbler == null) {
+ return gobbler.getOutput().toString();
+ } else {
+ egobbler.stop();
+ return egobbler.getOutput().toString();
+ }
+ }
+
+ private String runRemoteStapAttempt(String[] args, boolean getErrors) {
+ int attemptsLeft = 3;
+ while (true) {
+ try {
+ return runRemoteStap(args, getErrors);
+ } catch (JSchException e) {
+ if (!(e.getCause() instanceof ConnectException) || --attemptsLeft == 0) {
+ askIfEditCredentials();
+ return null;
+ }
+ }
+ }
+ }
+
+ private String runRemoteStap(String[] args, boolean getErrors) throws JSchException {
+ StringOutputStream str = new StringOutputStream();
+ StringOutputStream strErr = new StringOutputStream();
+
+ IPreferenceStore p = ConsoleLogPlugin.getDefault().getPreferenceStore();
+ String user = p.getString(ConsoleLogPreferenceConstants.SCP_USER);
+ String host = p.getString(ConsoleLogPreferenceConstants.HOST_NAME);
+ String password = p.getString(ConsoleLogPreferenceConstants.SCP_PASSWORD);
+ int port = p.getInt(ConsoleLogPreferenceConstants.PORT_NUMBER);
+
+ Channel channel = SystemtapProcessFactory.execRemoteAndWait(args, str, strErr, user, host, password,
+ port, EnvironmentVariablesPreferencePage.getEnvironmentVariables());
+ if (channel == null) {
+ displayError(Messages.TapsetParser_CannotRunStapTitle, Messages.TapsetParser_CannotRunStapMessage);
+ }
+
+ return (!getErrors ? str : strErr).toString();
+ }
+
+ private void askIfEditCredentials() {
+ if (displayingCredentialDialog.compareAndSet(false, true)) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ dialog.setText(Messages.TapsetParser_RemoteCredentialErrorTitle);
+ dialog.setMessage(Messages.TapsetParser_RemoteCredentialErrorMessage);
+ if (dialog.open() == SWT.YES) {
+ String pageID = "org.eclipse.linuxtools.systemtap.prefs.consoleLog"; //$NON-NLS-1$
+ PreferencesUtil.createPreferenceDialogOn(shell, pageID, new String[]{pageID}, null).open();
+ }
+ displayingCredentialDialog.set(false);
+ }
+ });
+ }
+ }
+
private void displayError(final String title, final String error) {
if (displayingError.compareAndSet(false, true)) {
Display.getDefault().asyncExec(new Runnable() {
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
index 1b53522a4b..dbe41099f2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/structures/messages.properties
@@ -15,4 +15,6 @@ ProbeParser_aliasProbes=Probe Aliases
TapsetParser_CannotRunStapMessage=Make sure SystemTap is installed.
TapsetParser_CannotRunStapTitle=Cannot Run SystemTap
TapsetParser_ErrorRunningSystemtap=Error Running SystemTap
+TapsetParser_RemoteCredentialErrorTitle=Remote Login Error
+TapsetParser_RemoteCredentialErrorMessage=Unable to login to the remote host for loading tapset contents. Edit the login credentials now?
SharedParser_NoOutput=No stap output was generated \ No newline at end of file

Back to the top