diff options
12 files changed, 268 insertions, 10 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java index 7ceae70c27..7209d9c491 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java @@ -37,6 +37,7 @@ import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCou import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin; import org.eclipse.linuxtools.internal.oprofile.ui.view.OprofileView; import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; +import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate; import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager; import org.eclipse.ui.PartInitException; @@ -78,9 +79,8 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil */ //set up and launch the local c/c++ program IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(Oprofile.OprofileProject.getProject()); - - URI workingDirURI = Oprofile.OprofileProject.getProject().getLocationURI(); - + IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject()); + URI workingDirURI = proxy.getWorkingDir(); IPath workingDirPath = new Path(workingDirURI.getPath()); String arguments[] = getProgramArgumentsArray( config ); diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/plugin.xml b/profiling/org.eclipse.linuxtools.profiling.launch/plugin.xml index a52b7ac3c5..7f4ebbbd82 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/plugin.xml +++ b/profiling/org.eclipse.linuxtools.profiling.launch/plugin.xml @@ -4,6 +4,7 @@ <extension-point id="RemoteProxyManager" name="Remote Proxy Manager" schema="schema/RemoteProxyManager.exsd"/> <extension-point id="launchProvider" name="Launch Provider" schema="schema/org.eclipse.linuxtools.profiling.launch.provider.exsd"/> <extension-point id="RemoteResourceSelectorProxy" name="Remote Resource Selector Proxy" schema="schema/RemoteResourceSelectorProxy.exsd"/> + <extension-point id="RemoteProxyNatureMapping" name="RemoteProxyNatureMapping" schema="schema/RemoteProxyNatureMapping.exsd"/> <extension point="org.eclipse.ui.preferencePages"> diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/schema/RemoteProxyNatureMapping.exsd b/profiling/org.eclipse.linuxtools.profiling.launch/schema/RemoteProxyNatureMapping.exsd new file mode 100644 index 0000000000..e19f92e6c3 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.profiling.launch/schema/RemoteProxyNatureMapping.exsd @@ -0,0 +1,122 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.linuxtools.profiling.launch" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.linuxtools.profiling.launch" id="RemoteProxyNatureMapping" name="RemoteProxyNatureMapping"/> + </appinfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="mapping"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="mapping"> + <complexType> + <attribute name="nature" type="string" use="required"> + <annotation> + <documentation> + The nature of the project. + </documentation> + </annotation> + </attribute> + <attribute name="schema" type="string" use="required"> + <annotation> + <documentation> + Schema that must be used with the corresponding nature. + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 2.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="apiinfo"/> + </appinfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> +/******************************************************************************* + * Copyright (c) 2013 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: + * Rodrigo Fraxino Araujo <rfaraujo@br.ibm.com> - initial API and implementation + *******************************************************************************/ + </documentation> + </annotation> +</schema> diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalFileProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalFileProxy.java index 06a8449a33..f71206de56 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalFileProxy.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/LocalFileProxy.java @@ -21,6 +21,12 @@ import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; public class LocalFileProxy implements IRemoteFileProxy { + URI workingDirURI; + + public LocalFileProxy(URI uri) { + workingDirURI=uri; + } + public URI toURI(IPath path) { return path.toFile().toURI(); } @@ -47,4 +53,8 @@ public class LocalFileProxy implements IRemoteFileProxy { return EFS.getLocalFileSystem().getStore(new Path(path)); } + public URI getWorkingDir() { + return workingDirURI; + } + } diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteFileProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteFileProxy.java index 1faf52dbe9..6c92f71d63 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteFileProxy.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteFileProxy.java @@ -16,11 +16,15 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.IPath; public interface IRemoteFileProxy { - + public URI toURI(IPath path); public URI toURI(String path); public String toPath(URI uri); public String getDirectorySeparator(); public IFileStore getResource(String path); + /** + * @since 2.0 + */ + public URI getWorkingDir(); } diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java index 04f2645058..84c74c73e0 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java @@ -30,9 +30,10 @@ public class RemoteProxyManager implements IRemoteProxyManager { private static final String EXT_ATTR_CLASS = "class"; //$NON-NLS-1$ private static final String LOCALSCHEME = "file"; //$NON-NLS-1$ - + private static RemoteProxyManager manager; private LocalFileProxy lfp; + private RemoteProxyNatureMapping mapping = new RemoteProxyNatureMapping(); private Map<String, IRemoteProxyManager> remoteManagers = new HashMap<String, IRemoteProxyManager>(); private RemoteProxyManager() { @@ -45,9 +46,9 @@ public class RemoteProxyManager implements IRemoteProxyManager { return manager; } - LocalFileProxy getLocalFileProxy() { + LocalFileProxy getLocalFileProxy(URI uri) { if (lfp == null) - lfp = new LocalFileProxy(); + lfp = new LocalFileProxy(uri); return lfp; } @@ -83,12 +84,18 @@ public class RemoteProxyManager implements IRemoteProxyManager { throw new CoreException(new Status(IStatus.ERROR, ProfileLaunchPlugin.PLUGIN_ID, IStatus.OK, Messages.RemoteProxyManager_unrecognized_scheme + scheme, null)); } - return getLocalFileProxy(); + return getLocalFileProxy(uri); } public IRemoteFileProxy getFileProxy(IProject project) throws CoreException { if (project == null) { - return getLocalFileProxy(); + return getLocalFileProxy(null); + } + String scheme = mapping.getSchemeFromNature(project); + if (scheme!=null) { + IRemoteProxyManager manager = getRemoteManager(scheme); + if (manager != null) + return manager.getFileProxy(project); } URI projectURI = project.getLocationURI(); return getFileProxy(projectURI); @@ -108,6 +115,11 @@ public class RemoteProxyManager implements IRemoteProxyManager { if (project == null){ return new LocalLauncher(); } + String scheme = mapping.getSchemeFromNature(project); + if (scheme!=null) { + IRemoteProxyManager manager = getRemoteManager(scheme); + return manager.getLauncher(project); + } URI projectURI = project.getLocationURI(); return getLauncher(projectURI); } @@ -123,6 +135,11 @@ public class RemoteProxyManager implements IRemoteProxyManager { } public String getOS(IProject project) throws CoreException { + String scheme = mapping.getSchemeFromNature(project); + if (scheme!=null) { + IRemoteProxyManager manager = getRemoteManager(scheme); + return manager.getOS(project); + } URI projectURI = project.getLocationURI(); return getOS(projectURI); } diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java new file mode 100644 index 0000000000..960b0a2640 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyNatureMapping.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Rodrigo Fraxino Araujo <rfaraujo@br.ibm.com> - initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.profiling.launch; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin; + +public class RemoteProxyNatureMapping { + + String EXTENSION_POINT_ID = "RemoteProxyNatureMapping"; //$NON-NLS-1$ + String MANAGER_NAME = "mapping"; //$NON-NLS-1$ + String NATURE_ID = "nature"; //$NON-NLS-1$ + String SCHEME_ID = "schema"; //$NON-NLS-1$ + + public String getSchemeFromNature(IProject project) throws CoreException { + + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID, EXTENSION_POINT_ID); + IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); + for(int i = 0; i < infos.length; i++) { + IConfigurationElement configurationElement = infos[i]; + if (configurationElement.getName().equals(MANAGER_NAME)) { + for (int j=0;j<natures.length;j++) { + if (configurationElement.getAttribute(NATURE_ID).equals(natures[j])) { + return configurationElement.getAttribute(SCHEME_ID); + } + } + } + } + return null; + } +} diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/plugin.xml b/profiling/org.eclipse.linuxtools.rdt.proxy/plugin.xml index 59b605fbdc..8484442b3a 100644 --- a/profiling/org.eclipse.linuxtools.rdt.proxy/plugin.xml +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/plugin.xml @@ -15,5 +15,12 @@ scheme="remotetools"> </manager> </extension> + <extension + point="org.eclipse.linuxtools.profiling.launch.RemoteProxyNatureMapping"> + <mapping + nature="org.eclipse.ptp.rdt.sync.core.remoteSyncNature" + schema="remotetools"> + </mapping> + </extension> </plugin> 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 index ae20b879ca..731c3919f1 100644 --- 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 @@ -18,15 +18,18 @@ 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.core.runtime.IStatus; import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; import org.eclipse.linuxtools.rdt.proxy.Activator; +import org.eclipse.linuxtools.rdt.proxy.RDTProxyManager; 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.IRemoteResource; import org.eclipse.ptp.remote.core.IRemoteServices; import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; import org.eclipse.ptp.remote.core.RemoteProcessAdapter; @@ -63,7 +66,16 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { public RDTCommandLauncher(IProject project) { fProcess = null; fShowCommand = false; - uri = project.getLocationURI(); + try { + if (project.hasNature(RDTProxyManager.SYNC_NATURE)) { + IRemoteResource remoteRes = (IRemoteResource)project.getAdapter(IRemoteResource.class); + uri = remoteRes.getActiveLocationURI(); + } else{ + uri = project.getLocationURI(); + } + } catch (CoreException e) { + uri = project.getLocationURI(); + } lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } 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 index 0436feda56..88f5a8c727 100644 --- 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 @@ -14,20 +14,27 @@ import java.net.URI; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; import org.eclipse.linuxtools.rdt.proxy.Activator; +import org.eclipse.linuxtools.rdt.proxy.RDTProxyManager; import org.eclipse.ptp.remote.core.IRemoteConnection; import org.eclipse.ptp.remote.core.IRemoteFileManager; +import org.eclipse.ptp.remote.core.IRemoteResource; import org.eclipse.ptp.remote.core.IRemoteServices; import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; public class RDTFileProxy implements IRemoteFileProxy { + private IProject project; private IRemoteFileManager manager; + private IRemoteResource remoteRes; private void initialize(URI uri) throws CoreException { IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); @@ -45,7 +52,16 @@ public class RDTFileProxy implements IRemoteFileProxy { } public RDTFileProxy(IProject project) throws CoreException { + this.project = project; URI uri = project.getLocationURI(); + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = workspaceRoot.findMember(project.getName()); + if (resource != null) { + remoteRes = (IRemoteResource)resource.getAdapter(IRemoteResource.class); + if (project.hasNature(RDTProxyManager.SYNC_NATURE)) { + uri = remoteRes.getActiveLocationURI(); + } + } initialize(uri); } @@ -74,4 +90,15 @@ public class RDTFileProxy implements IRemoteFileProxy { return manager.getResource(path); } + @Override + public URI getWorkingDir() { + try { + if (project.hasNature(RDTProxyManager.SYNC_NATURE)) + return remoteRes.getActiveLocationURI(); + } catch (CoreException e) { + return project.getLocationURI(); + } + return project.getLocationURI(); + } + } 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 index 4affa00a9c..66c17aecbf 100644 --- 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 @@ -25,6 +25,8 @@ import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; public class RDTProxyManager implements IRemoteProxyManager { + public final static String SYNC_NATURE = "org.eclipse.ptp.rdt.sync.core.remoteSyncNature"; //$NON-NLS-1$ + @Override public IRemoteFileProxy getFileProxy(URI uri) throws CoreException { return new RDTFileProxy(uri); diff --git a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java index 12ab6f5dda..c65e0215d9 100644 --- a/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java +++ b/profiling/org.eclipse.linuxtools.ssh.proxy/src/org/eclipse/linuxtools/internal/ssh/proxy/SSHFileProxy.java @@ -19,8 +19,11 @@ import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; public class SSHFileProxy extends SSHBase implements IRemoteFileProxy { + URI uri; + public SSHFileProxy(URI uri) { super(uri); + this.uri = uri; } @Override @@ -54,4 +57,9 @@ public class SSHFileProxy extends SSHBase implements IRemoteFileProxy { return null; } } + + @Override + public URI getWorkingDir() { + return uri; + } } |