diff options
author | Jeff Johnston | 2011-10-07 20:28:50 +0000 |
---|---|---|
committer | Jeff Johnston | 2011-10-07 20:28:50 +0000 |
commit | 5a936b1e9ec455b5e7904c139df5904bfb7261ef (patch) | |
tree | 144671b744366f09f9ad556820a7fef1cb00e1fc | |
parent | 6bd6bdd57c133c110b5f3ef92a845454968830e9 (diff) | |
download | org.eclipse.linuxtools-5a936b1e9ec455b5e7904c139df5904bfb7261ef.tar.gz org.eclipse.linuxtools-5a936b1e9ec455b5e7904c139df5904bfb7261ef.tar.xz org.eclipse.linuxtools-5a936b1e9ec455b5e7904c139df5904bfb7261ef.zip |
Add RDT Proxy plugin.
* src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProcess.java: New
file.
* src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java: New
file.
*
src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java:
New file.
* build.properties: New file.
* META-INF/MANIFEST.MF: New file.
* src/org/eclipse/linuxtools/rdt/proxy/Resources.properties: New file.
* src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java: New file.
* src/org/eclipse/linuxtools/rdt/proxy/Activator.java: New file.
13 files changed, 768 insertions, 0 deletions
diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/.classpath b/profiling/org.eclipse.linuxtools.rdt.proxy/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/.project b/profiling/org.eclipse.linuxtools.rdt.proxy/.project new file mode 100644 index 0000000000..f4fe7fa564 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.linuxtools.rdt.proxy</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.rdt.proxy/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..4a71d6ad19 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Oct 06 17:12:25 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/ChangeLog b/profiling/org.eclipse.linuxtools.rdt.proxy/ChangeLog new file mode 100644 index 0000000000..a413ff21b7 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/ChangeLog @@ -0,0 +1,10 @@ +2011-10-07 Jeff Johnston <jjohnstn@redhat.com> + + * src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProcess.java: New file. + * src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java: New file. + * src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java: New file. + * build.properties: New file. + * META-INF/MANIFEST.MF: New file. + * src/org/eclipse/linuxtools/rdt/proxy/Resources.properties: New file. + * src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java: New file. + * src/org/eclipse/linuxtools/rdt/proxy/Activator.java: New file.
\ No newline at end of file diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.rdt.proxy/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5565187e35 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %bundleName +Bundle-SymbolicName: org.eclipse.linuxtools.rdt.proxy +Bundle-Version: 0.0.1.qualifier +Bundle-Activator: org.eclipse.linuxtools.rdt.proxy.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.ptp.rdt.core;bundle-version="3.1.0", + org.eclipse.ptp.remote.core;bundle-version="5.0.0", + org.eclipse.linuxtools.profiling.launch;bundle-version="0.8.0", + org.eclipse.core.resources;bundle-version="3.7.100", + org.eclipse.core.filesystem;bundle-version="1.3.100" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Vendor: %provider diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/build.properties b/profiling/org.eclipse.linuxtools.rdt.proxy/build.properties new file mode 100644 index 0000000000..2b0d95b6b0 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + . diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java new file mode 100644 index 0000000000..08376d57a4 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 2005, 2009, 2011 IBM Corporation and others. + * 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 + * Red Hat Inc. - modify to use with RDT + *******************************************************************************/ +package org.eclipse.linuxtools.internal.rdt.proxy; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; +import java.util.Arrays; +import java.util.Map; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.linuxtools.profiling.launch.IProcess; +import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; +import org.eclipse.linuxtools.rdt.proxy.Activator; +import org.eclipse.ptp.remote.core.IRemoteConnection; +import org.eclipse.ptp.remote.core.IRemoteFileManager; +import org.eclipse.ptp.remote.core.IRemoteProcess; +import org.eclipse.ptp.remote.core.IRemoteProcessBuilder; +import org.eclipse.ptp.remote.core.IRemoteServices; +import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; + +/** + * @noextend This class is not intended to be subclassed by clients. + */ +public class RDTCommandLauncher implements IRemoteCommandLauncher { + + public final static int COMMAND_CANCELED = IRemoteCommandLauncher.COMMAND_CANCELED; + public final static int ILLEGAL_COMMAND = IRemoteCommandLauncher.ILLEGAL_COMMAND; + public final static int OK = IRemoteCommandLauncher.OK; + + + protected IRemoteProcess fProcess; + protected boolean fShowCommand; + protected String[] fCommandArgs; + + protected String fErrorMessage = ""; //$NON-NLS-1$ + + private String lineSeparator; + private IProject fProject; + + /** + * The number of milliseconds to pause between polling. + */ + protected static final long DELAY = 50L; + + /** + * Creates a new launcher Fills in stderr and stdout output to the given + * streams. Streams can be set to <code>null</code>, if output not + * required + */ + public RDTCommandLauncher(IProject project) { + fProcess = null; + fShowCommand = false; + fProject = project; + lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void showCommand(boolean show) { + fShowCommand = show; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage() + */ + public String getErrorMessage() { + return fErrorMessage; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.ICommandLauncher#setErrorMessage(java.lang.String) + */ + public void setErrorMessage(String error) { + fErrorMessage = error; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.ICommandLauncher#getCommandArgs() + */ + public String[] getCommandArgs() { + return fCommandArgs; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.ICommandLauncher#getCommandLine() + */ + public String getCommandLine() { + return getCommandLine(getCommandArgs()); + } + + /** + * Constructs a command array that will be passed to the process + */ + protected String[] constructCommandArray(String command, String[] commandArgs) { + String[] args = new String[1 + commandArgs.length]; + args[0] = command; + System.arraycopy(commandArgs, 0, args, 1, commandArgs.length); + return args; + } + + + /** + * @see org.eclipse.cdt.core.IRemoteCommandLauncher#execute(IPath, String[], String[], IPath, IProgressMonitor) + */ + public IProcess execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, IProgressMonitor monitor) throws CoreException { + try { + // add platform specific arguments (shell invocation) + fCommandArgs = constructCommandArray(commandPath.toOSString(), args); + fShowCommand = true; + URI uri = fProject.getLocationURI(); + IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); + IRemoteConnection connection = services.getConnectionManager().getConnection(uri); + IRemoteFileManager fm = services.getFileManager(connection); + IRemoteProcessBuilder builder = services.getProcessBuilder(connection, Arrays.asList(fCommandArgs)); + + if (changeToDirectory != null) + builder.directory(fm.getResource(changeToDirectory.toString())); + + Map<String,String> envMap = builder.environment(); + + for (int i = 0; i < env.length; ++i) { + String s = env[i]; + String[] tokens = s.split("=", 2); + envMap.put(tokens[0], tokens[1]); + } + + fProcess = builder.start(); + fErrorMessage = ""; //$NON-NLS-1$ + } catch (IOException e) { + setErrorMessage(e.getMessage()); + fProcess = null; + } + return new RDTProcess(fProcess); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IRemoteCommandLauncher#waitAndRead(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor) + */ + public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) { + if (fShowCommand) { + printCommandLine(output); + } + + if (fProcess == null) { + return ILLEGAL_COMMAND; + } + + RemoteProcessClosure closure = new RemoteProcessClosure(fProcess, output, err); + closure.runNonBlocking(); + while (!monitor.isCanceled() && closure.isAlive()) { + try { + Thread.sleep(DELAY); + } catch (InterruptedException ie) { + // ignore + } + } + + int state = OK; + + // Operation canceled by the user, terminate abnormally. + if (monitor.isCanceled()) { + closure.terminate(); + state = COMMAND_CANCELED; + setErrorMessage(Activator.getResourceString("CommandLauncher.error.commandCanceled")); //$NON-NLS-1$ + } + + try { + fProcess.waitFor(); + } catch (InterruptedException e) { + // ignore + } + return state; + } + + protected void printCommandLine(OutputStream os) { + if (os != null) { + String cmd = getCommandLine(getCommandArgs()); + try { + os.write(cmd.getBytes()); + os.flush(); + } catch (IOException e) { + // ignore; + } + } + } + + protected String getCommandLine(String[] commandArgs) { + StringBuffer buf = new StringBuffer(); + if (fCommandArgs != null) { + for (String commandArg : commandArgs) { + buf.append(commandArg); + buf.append(' '); + } + buf.append(lineSeparator); + } + return buf.toString(); + } + +}
\ No newline at end of file diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java new file mode 100644 index 0000000000..2c9935ca76 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java @@ -0,0 +1,50 @@ +package org.eclipse.linuxtools.internal.rdt.proxy; + +import java.net.URI; + +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; +import org.eclipse.ptp.remote.core.IRemoteConnection; +import org.eclipse.ptp.remote.core.IRemoteFileManager; +import org.eclipse.ptp.remote.core.IRemoteServices; +import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; + +public class RDTFileProxy implements IRemoteFileProxy { + + private IRemoteFileManager manager; + + public RDTFileProxy(IProject project) { + URI uri = project.getLocationURI(); + IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); + IRemoteConnection connection = services.getConnectionManager().getConnection(uri); + manager = services.getFileManager(connection); + } + + @Override + public URI toURI(IPath path) { + return manager.toURI(path); + } + + @Override + public URI toURI(String path) { + return manager.toURI(path); + } + + @Override + public String toPath(URI uri) { + return manager.toPath(uri); + } + + @Override + public String getDirectorySeparator() { + return manager.getDirectorySeparator(); + } + + @Override + public IFileStore getResource(String path) { + return manager.getResource(path); + } + +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProcess.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProcess.java new file mode 100644 index 0000000000..3985cee952 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTProcess.java @@ -0,0 +1,37 @@ +package org.eclipse.linuxtools.internal.rdt.proxy; + +import java.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.linuxtools.profiling.launch.IProcess; +import org.eclipse.ptp.remote.core.IRemoteProcess; + +public class RDTProcess implements IProcess { + + private IRemoteProcess process; + + public RDTProcess(IRemoteProcess process) { + this.process = process; + } + + @Override + public OutputStream getOutputStream() { + return process.getOutputStream(); + } + + @Override + public InputStream getInputStream() { + return process.getInputStream(); + } + + @Override + public InputStream getErrorStream() { + return process.getErrorStream(); + } + + @Override + public int exitValue() { + return process.exitValue(); + } + +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java new file mode 100644 index 0000000000..e8191a011b --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RemoteProcessClosure.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. + * 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.internal.rdt.proxy; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; + +import org.eclipse.ptp.remote.core.IRemoteProcess; + +/** + * Bundled state of a launched process including the threads linking the process + * in/output to console documents. + */ +public class RemoteProcessClosure { + + /** + * Thread which continuously reads from a input stream and pushes the read + * data to an output stream which is immediately flushed afterwards. + */ + protected static class ReaderThread extends Thread { + + private InputStream fInputStream; + private OutputStream fOutputStream; + private boolean fFinished = false; + private String lineSeparator; + /* + * outputStream can be null + */ + public ReaderThread(ThreadGroup group, String name, InputStream in, OutputStream out) { + super(group, name); + fOutputStream = out; + fInputStream = in; + setDaemon(true); + lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$ + } + + @Override + public void run() { + try { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream)); + String line; + while ((line = reader.readLine()) != null) { + line += lineSeparator; + fOutputStream.write(line.getBytes()); + } + } catch (IOException x) { + // ignore + } finally { + try { + // writer.flush(); + fOutputStream.flush(); + } catch (IOException e) { + // ignore + } + try { + fInputStream.close(); + } catch (IOException e) { + // ignore + } + } + } finally { + complete(); + } + } + + public synchronized boolean finished() { + return fFinished; + } + + public synchronized void waitFor() { + while (!fFinished) { + try { + wait(); + } catch (InterruptedException e) { + } + } + } + + public synchronized void complete() { + fFinished = true; + notify(); + } + + public void close() { + try { + fOutputStream.close(); + } catch (IOException e) { + // ignore + } + } + } + + protected static int fCounter = 0; + + protected IRemoteProcess fProcess; + + protected OutputStream fOutput; + protected OutputStream fError; + + protected ReaderThread fOutputReader; + protected ReaderThread fErrorReader; + + /** + * Creates a process closure and connects the launched process with a + * console document. + * + * @param outputStream + * prcess stdout is written to this stream. Can be + * <code>null</code>, if not interested in reading the output + * @param errorStream + * prcess stderr is written to this stream. Can be + * <code>null</code>, if not interested in reading the output + */ + public RemoteProcessClosure(IRemoteProcess process, OutputStream outputStream, OutputStream errorStream) { + fProcess = process; + fOutput = outputStream; + fError = errorStream; + } + + /** + * Live links the launched process with the configured in/out streams using + * reader threads. + */ + public void runNonBlocking() { + ThreadGroup group = new ThreadGroup("CBuilder" + fCounter++); //$NON-NLS-1$ + + InputStream stdin = fProcess.getInputStream(); + InputStream stderr = fProcess.getErrorStream(); + + fOutputReader = new ReaderThread(group, "OutputReader", stdin, fOutput); //$NON-NLS-1$ + fErrorReader = new ReaderThread(group, "ErrorReader", stderr, fError); //$NON-NLS-1$ + + fOutputReader.start(); + fErrorReader.start(); + } + + public void runBlocking() { + runNonBlocking(); + + boolean finished = false; + while (!finished) { + try { + fProcess.waitFor(); + } catch (InterruptedException e) { + //System.err.println("Closure exception " +e); + } + try { + fProcess.exitValue(); + finished = true; + } catch (IllegalThreadStateException e) { + //System.err.println("Closure exception " +e); + } + } + + // @@@FIXME: Windows 2000 is screwed; double-check using output threads + if (!fOutputReader.finished()) { + fOutputReader.waitFor(); + } + + if (!fErrorReader.finished()) { + fErrorReader.waitFor(); + } + + fOutputReader.close(); + fErrorReader.close(); + // it seems that thread termination and stream closing is working + // without + // any help + fProcess = null; + fOutputReader = null; + fErrorReader = null; + } + + public boolean isAlive() { + if (fProcess != null) { + if (fOutputReader.isAlive() || fErrorReader.isAlive()) { + return true; + } + fProcess = null; + fOutputReader.close(); + fErrorReader.close(); + fOutputReader = null; + fErrorReader = null; + } + return false; + } + + /** + * The same functionality as "isAlive()" + * but does not affect out streams, + * because they can be shared among processes + */ + public boolean isRunning() { + if (fProcess != null) { + if (fOutputReader.isAlive() || fErrorReader.isAlive()) { + return true; + } + fProcess = null; + } + return false; + } + /** + * Forces the termination the launched process + */ + public void terminate() { + if (fProcess != null) { + fProcess.destroy(); + fProcess = null; + } + if (!fOutputReader.finished()) { + fOutputReader.waitFor(); + } + if (!fErrorReader.finished()) { + fErrorReader.waitFor(); + } + fOutputReader.close(); + fErrorReader.close(); + fOutputReader = null; + fErrorReader = null; + } +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Activator.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Activator.java new file mode 100644 index 0000000000..2358c93e24 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Activator.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2011 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 Incorporated - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.rdt.proxy; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.linuxtools.rdt.proxy"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + private ResourceBundle resourceBundle; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + try { + resourceBundle = ResourceBundle.getBundle(PLUGIN_ID + ".Resources"); //$NON-NLS-1$ + } catch (MissingResourceException x) { + resourceBundle = null; + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + * + * @param key the message key + * @return the resource bundle message + */ + public static String getResourceString(String key) { + ResourceBundle bundle = plugin.getResourceBundle(); + try { + return bundle.getString(key); + } catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java new file mode 100644 index 0000000000..165c5b1fcb --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 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 Incorporated - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.rdt.proxy; + +import java.net.URI; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.linuxtools.internal.rdt.proxy.RDTCommandLauncher; +import org.eclipse.linuxtools.internal.rdt.proxy.RDTFileProxy; +import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; +import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; +import org.eclipse.linuxtools.profiling.launch.IRemoteProxyManager; +import org.eclipse.ptp.remote.core.IRemoteConnection; +import org.eclipse.ptp.remote.core.IRemoteServices; +import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; + +public class RDTProxyManager implements IRemoteProxyManager { + + @Override + public IRemoteFileProxy getFileProxy(IProject project) throws CoreException { + return new RDTFileProxy(project); + } + + @Override + public IRemoteCommandLauncher getLauncher(IProject project) + throws CoreException { + return new RDTCommandLauncher(project); + } + + @Override + public String getOS(IProject project) throws CoreException { + // TODO Auto-generated method stub + URI uri = project.getLocationURI(); + IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); + IRemoteConnection connection = services.getConnectionManager().getConnection(uri); + return connection.getProperty(IRemoteConnection.OS_NAME_PROPERTY); + } + +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Resources.properties b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Resources.properties new file mode 100644 index 0000000000..dd85f8fcb9 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/Resources.properties @@ -0,0 +1,11 @@ +#******************************************************************************* +# Copyright (c) 2011 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 Incorporated - initial API and implementation +#*******************************************************************************/ +CommandLauncher.error.commandCanceled=Command canceled
\ No newline at end of file |