aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Ashford2012-01-30 17:06:37 (EST)
committerOtavio Pontes2012-05-29 10:19:28 (EDT)
commit592a9da0fbdc42c6c7d0dad561c19af5080dd511 (patch)
tree09ac087a8b7ce4e69207f11ebdba1ea15a25724b
parent566268337f524d708f3169d6286ed1a9eb7988a8 (diff)
downloadorg.eclipse.linuxtools-592a9da0fbdc42c6c7d0dad561c19af5080dd511.zip
org.eclipse.linuxtools-592a9da0fbdc42c6c7d0dad561c19af5080dd511.tar.gz
org.eclipse.linuxtools-592a9da0fbdc42c6c7d0dad561c19af5080dd511.tar.bz2
Add ResourceSelectorWidget to be used to construct Remote launch configs
This commit adds a widget that uses a similar selector to what is used by Eclipse's project creation wizard, where you can choose a filesystem and a path, potentially on a remote machine. Signed-off-by: Corey Ashford <cjashfor@linux.vnet.ibm.com>
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.classpath7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.project34
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/META-INF/MANIFEST.MF14
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/build.properties6
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/plugin.xml21
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Activator.java69
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Messages.java16
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java101
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/messages.properties2
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/.classpath7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/.project28
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/META-INF/MANIFEST.MF11
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/build.properties7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/plugin.xml15
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/schema/RemoteResourceSelectorProxy.exsd128
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/Activator.java70
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemElement.java44
-rwxr-xr-xprofiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java210
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java21
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/LocalResourceSelectorProxy.java55
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java242
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidgetMessages.java38
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/messages.properties13
25 files changed, 1175 insertions, 0 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.classpath b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.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.profiling.launch.ui.rdt.proxy/.project b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.project
new file mode 100644
index 0000000..06c47e3
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.profiling.launch.ui.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>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..551acd3
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Dec 12 19:03:49 PST 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.profiling.launch.ui.rdt.proxy/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..9e5bcc2
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Resource Selector Proxy for RDT
+Bundle-SymbolicName: org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ptp.remote.core;bundle-version="5.0.0",
+ org.eclipse.ptp.remote.ui;bundle-version="5.0.0",
+ org.eclipse.linuxtools.profiling.launch.ui;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/build.properties b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/build.properties
new file mode 100644
index 0000000..2dcc4bd
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ bin/
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/plugin.xml b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/plugin.xml
new file mode 100644
index 0000000..d2925bc
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.linuxtools.profiling.launch.ui.RemoteResourceSelectorProxy">
+ <resourceSelectorProxy
+ class="org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy.RDTResourceSelectorProxy"
+ scheme="remotetools"
+ schemeLabel="Remote Tools">
+ </resourceSelectorProxy>
+ </extension>
+ <extension
+ point="org.eclipse.linuxtools.profiling.launch.ui.RemoteResourceSelectorProxy">
+ <resourceSelectorProxy
+ class="org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy.RDTResourceSelectorProxy"
+ scheme="rse"
+ schemeLabel="RSE">
+ </resourceSelectorProxy>
+ </extension>
+
+</plugin>
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Activator.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Activator.java
new file mode 100644
index 0000000..b903cdb
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Activator.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui.rdt.proxy;
+
+import org.eclipse.core.runtime.Status;
+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.profiling.launch.ui.rdt.proxy"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * 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;
+ }
+
+ /*
+ * (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 shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static void log(int status, String msg, Throwable e) {
+ plugin.getLog().log(new Status(status, PLUGIN_ID, Status.OK, msg, e));
+ }
+
+ public static void log(int status, String msg) {
+ log(status, msg, null);
+ }
+
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Messages.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Messages.java
new file mode 100644
index 0000000..77235e9
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/Messages.java
@@ -0,0 +1,16 @@
+package org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy.messages"; //$NON-NLS-1$
+ public static String RDTResourceSelectorProxy_unsupported_resourceType;
+ public static String RDTResourceSelectorProxy_URI_syntax_error;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java
new file mode 100644
index 0000000..d0a68c8
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/RDTResourceSelectorProxy.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui.rdt.proxy;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.profiling.launch.ui.IRemoteResourceSelectorProxy;
+
+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;
+import org.eclipse.ptp.remote.ui.IRemoteUIConstants;
+import org.eclipse.ptp.remote.ui.IRemoteUIFileManager;
+import org.eclipse.ptp.remote.ui.IRemoteUIServices;
+import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin;
+
+import org.eclipse.swt.widgets.Shell;
+
+public class RDTResourceSelectorProxy implements IRemoteResourceSelectorProxy {
+
+ private enum ResourceType { FILE, DIRECTORY };
+
+ private URI getEmptyPathURI(String scheme) {
+ try {
+ return new URI(scheme, null, "/", null); //$NON-NLS-1$
+ } catch (URISyntaxException e) {
+ Activator.log(Status.ERROR, Messages.RDTResourceSelectorProxy_URI_syntax_error, e);
+ return null;
+ }
+ }
+
+ private URI selectResource(String scheme, String initialPath, String prompt, Shell shell, ResourceType resourceType) {
+ IRemoteUIFileManager uiFileManager;
+ boolean schemeSwitch = false;
+ URI uri;
+ try {
+ uri = new URI(initialPath);
+ if (!scheme.equals(uri.getScheme())) {
+ uri = getEmptyPathURI(scheme);
+ schemeSwitch = true;
+ }
+ } catch (URISyntaxException e) {
+ uri = getEmptyPathURI(scheme);
+ schemeSwitch = true;
+ }
+ // If the user is switching schemes, start with an empty host and path
+ IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri);
+ services.initialize();
+
+ IRemoteUIServices uiServices = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(services);
+ uiFileManager = uiServices.getUIFileManager();
+ uiFileManager.showConnections(true);
+ IRemoteConnection connection = null;
+ if (!schemeSwitch) {
+ connection = services.getConnectionManager().getConnection(uri);
+ uiFileManager.setConnection(connection);
+ }
+ String selectedPath = null;
+ switch (resourceType) {
+ case FILE:
+ selectedPath = uiFileManager.browseFile(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
+ break;
+ case DIRECTORY:
+ selectedPath = uiFileManager.browseDirectory(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
+ break;
+ default:
+ Activator.log(Status.ERROR, Messages.RDTResourceSelectorProxy_unsupported_resourceType + resourceType);
+ return null;
+ }
+ URI selectedURI = null;
+ if (selectedPath != null) {
+ connection = uiFileManager.getConnection();
+ IRemoteFileManager remoteFileManager = services.getFileManager(connection);
+ selectedURI = remoteFileManager.toURI(selectedPath);
+ }
+ return selectedURI;
+ }
+
+ @Override
+ public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
+ return selectResource(scheme, initialPath, prompt, shell, ResourceType.FILE);
+ }
+
+ @Override
+ public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell) {
+ return selectResource(scheme, initialPath, prompt, shell, ResourceType.DIRECTORY);
+ }
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/messages.properties b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/messages.properties
new file mode 100644
index 0000000..0a93f52
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui.rdt.proxy/src/org/eclipse/linuxtools/profiling/launch/ui/rdt/proxy/messages.properties
@@ -0,0 +1,2 @@
+RDTResourceSelectorProxy_unsupported_resourceType=Internal error: unsupported resourceType argument:
+RDTResourceSelectorProxy_URI_syntax_error=URI syntax error in RDTResourceSelector
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/.classpath b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.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.profiling.launch.ui/.project b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.project
new file mode 100644
index 0000000..d9f35db
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.profiling.launch.ui</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.profiling.launch.ui/.settings/org.eclipse.jdt.core.prefs b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..d778498
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Dec 12 12:56:00 PST 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.profiling.launch.ui/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.profiling.launch.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..c059884
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.eclipse.linuxtools.profiling.launch.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.linuxtools.profiling.launch.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.profiling.launch.ui
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/build.properties b/profiling/org.eclipse.linuxtools.profiling.launch.ui/build.properties
new file mode 100644
index 0000000..2e3b21f
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ schema/,\
+ bin/
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/plugin.xml b/profiling/org.eclipse.linuxtools.profiling.launch.ui/plugin.xml
new file mode 100644
index 0000000..d24607d
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="RemoteResourceSelectorProxy" name="Remote Resource Selector Proxy" schema="schema/RemoteResourceSelectorProxy.exsd"/>
+ <extension
+ point="org.eclipse.linuxtools.profiling.launch.ui.RemoteResourceSelectorProxy">
+ <resourceSelectorProxy
+ class="org.eclipse.linuxtools.profiling.launch.ui.LocalResourceSelectorProxy"
+ isDefault="true"
+ scheme="local"
+ schemeLabel="Local">
+ </resourceSelectorProxy>
+ </extension>
+
+</plugin>
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/schema/RemoteResourceSelectorProxy.exsd b/profiling/org.eclipse.linuxtools.profiling.launch.ui/schema/RemoteResourceSelectorProxy.exsd
new file mode 100644
index 0000000..3ac067e
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/schema/RemoteResourceSelectorProxy.exsd
@@ -0,0 +1,128 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.linuxtools.profiling.launch.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.linuxtools.profiling.launch.ui" id="RemoteResourceSelectorProxy" name="Remote Resource Selector Proxy"/>
+ </appinfo>
+ <documentation>
+ Use this to identify a Remote Resource Selector Proxy object of type IRemoteResourceSelectorProxy.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="resourceSelectorProxy"/>
+ </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="resourceSelectorProxy">
+ <annotation>
+ <documentation>
+ A class which implements IRemoteResourceSelectorProxy.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Identifier of class which implements IRemoteResourceSelectorProxy interface.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.profiling.launch.ui.IRemoteResourceSelectorProxy"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="scheme" type="string" use="required">
+ <annotation>
+ <documentation>
+ Connection scheme that this Remote Resource Selector Proxy supports.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="schemeLabel" type="string">
+ <annotation>
+ <documentation>
+ Label to be shown in the UI for this Resource Selector Proxy.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="isDefault" type="boolean">
+ <annotation>
+ <documentation>
+ Indicates if this the default scheme to be shown in the selector.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.1.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>
+
+
+</schema>
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/Activator.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/Activator.java
new file mode 100644
index 0000000..b18b3dd
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/Activator.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import org.eclipse.core.runtime.Status;
+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.profiling.launch.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * 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;
+ }
+
+ /*
+ * (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 shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static void log(int status, String msg, Throwable e) {
+ plugin.getLog().log(new Status(status, PLUGIN_ID, Status.OK, msg, e));
+ }
+
+ public static void log(int status, String msg) {
+ log(status, msg, null);
+ }
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemElement.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemElement.java
new file mode 100644
index 0000000..672bf49
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemElement.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+public class FileSystemElement {
+
+ private String scheme;
+ private String schemeLabel;
+ private boolean isDefault;
+ private IRemoteResourceSelectorProxy selectorProxy;
+
+ public FileSystemElement(String scheme, String schemeLabel, boolean isDefault, IRemoteResourceSelectorProxy selectorProxy) {
+ this.schemeLabel = schemeLabel;
+ this.scheme = scheme;
+ this.isDefault = isDefault;
+ this.selectorProxy = selectorProxy;
+ }
+
+ public String getSchemeLabel() {
+ return schemeLabel;
+ }
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public boolean getIsDefault() {
+ return isDefault;
+ }
+
+ public IRemoteResourceSelectorProxy getSelectorProxy() {
+ return selectorProxy;
+ }
+
+};
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java
new file mode 100755
index 0000000..0f526ce
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/FileSystemSelectionArea.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+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.core.runtime.Status;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * FileSystemSelectionArea is the area used to select the file system.
+ *
+ */
+
+public class FileSystemSelectionArea {
+
+ private Label fileSystemTitle;
+ private ComboViewer fileSystems;
+
+ private static final String EXTENSION_POINT_ID = "RemoteResourceSelectorProxy"; //$NON-NLS-1$
+ private static final String RESOURCE_SELECTOR_PROXY_NAME = "resourceSelectorProxy"; //$NON-NLS-1$
+ private static final String SCHEME_ID = "scheme"; //$NON-NLS-1$
+ private static final String SCHEME_LABEL_ID = "schemeLabel"; //$NON-NLS-1$
+ private static final String IS_DEFAULT_ID = "isDefault"; //$NON-NLS-1$
+ private static final String EXT_ATTR_CLASS = "class"; //$NON-NLS-1$
+
+ private LinkedList<FileSystemElement> fsElements;
+
+ /**
+ * Create a new instance of the receiver.
+ */
+ public FileSystemSelectionArea(){
+ }
+
+ private FileSystemElement[] getSchemes() {
+ if (fsElements == null) {
+ fsElements = new LinkedList<FileSystemElement>();
+
+ // Add all of the ones declared by the registry.
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(Activator.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(RESOURCE_SELECTOR_PROXY_NAME)) {
+ IRemoteResourceSelectorProxy remoteSelector = null;
+ try {
+ Object obj = configurationElement.createExecutableExtension(EXT_ATTR_CLASS);
+ if (obj instanceof IRemoteResourceSelectorProxy) {
+ remoteSelector = (IRemoteResourceSelectorProxy)obj;
+ }
+ } catch (CoreException e) {
+ Activator.log(Status.ERROR, ResourceSelectorWidgetMessages.FileSystemSelectionArea_exception_while_creating_runnable_class + configurationElement.getAttribute(EXT_ATTR_CLASS), e);
+ }
+ FileSystemElement element = new FileSystemElement(
+ configurationElement.getAttribute(SCHEME_ID),
+ configurationElement.getAttribute(SCHEME_LABEL_ID),
+ Boolean.valueOf(configurationElement.getAttribute(IS_DEFAULT_ID)),
+ remoteSelector);
+ fsElements.addLast(element);
+ }
+ }
+ }
+ return fsElements.toArray(new FileSystemElement[fsElements.size()]);
+ }
+
+ /**
+ * Create the contents of the receiver in composite.
+ * @param composite
+ */
+ public void createContents(Composite composite) {
+
+ fileSystemTitle = new Label(composite, SWT.NONE);
+ fileSystemTitle.setText(ResourceSelectorWidgetMessages.fileSystemSelectionText);
+ fileSystemTitle.setFont(composite.getFont());
+
+ fileSystems = new ComboViewer(composite, SWT.READ_ONLY);
+ fileSystems.getControl().setFont(composite.getFont());
+
+ fileSystems.setLabelProvider(new LabelProvider() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ return ((FileSystemElement)element).getSchemeLabel();
+ }
+ });
+
+ fileSystems.setContentProvider(new IStructuredContentProvider() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return getSchemes();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(org.eclipse.jface.viewers.Viewer viewer,
+ Object oldInput, Object newInput) {
+ // Nothing to do
+ }
+ });
+
+ fileSystems.setInput(this);
+ Iterator<FileSystemElement> fsEltItr = fsElements.iterator();
+ boolean foundDefault = false;
+ while (fsEltItr.hasNext()) {
+ FileSystemElement fsElt = fsEltItr.next();
+ if (fsElt.getIsDefault()) {
+ if (foundDefault) {
+ Activator.log(Status.WARNING, ResourceSelectorWidgetMessages.FileSystemSelectionArea_found_multiple_default_extensions + fsElt.getScheme());
+ // use only the first one we found marked as default
+ continue;
+ }
+ fileSystems.setSelection(new StructuredSelection(fsElt));
+ foundDefault = true;
+ }
+ }
+ }
+
+ /**
+ * Return the selected file system.
+ * @return FileSystemElement or <code>null</code> if nothing
+ * is selected.
+ */
+ public FileSystemElement getSelectedFileSystem() {
+ ISelection selection = fileSystems.getSelection();
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structured = (IStructuredSelection) selection;
+ if (structured.size() == 1) {
+ return ((FileSystemElement) structured.getFirstElement());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Set the filesystem selection combo box to the specified scheme. If the scheme isn't
+ * legal, throw a CoreException.
+ * @param scheme name of scheme, e.g. "rse"
+ */
+ public void setSelectedFileSystem(String scheme) throws CoreException {
+ Iterator<FileSystemElement> fsEltItr = fsElements.iterator();
+ boolean foundMatch = false;
+ while (fsEltItr.hasNext()) {
+ FileSystemElement fsElt = fsEltItr.next();
+ if (fsElt.getScheme().equalsIgnoreCase(scheme)) {
+ foundMatch = true;
+ fileSystems.setSelection(new StructuredSelection(fsElt));
+ break;
+ }
+ }
+ if (!foundMatch) {
+ throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, Status.OK,
+ ResourceSelectorWidgetMessages.FileSystemSelectionArea_unrecognized_scheme + scheme, null));
+ }
+ }
+
+
+ /**
+ * Set the enablement state of the widget.
+ * @param enabled
+ */
+ public void setEnabled(boolean enabled) {
+ fileSystemTitle.setEnabled(enabled);
+ fileSystems.getControl().setEnabled(enabled);
+ }
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java
new file mode 100644
index 0000000..59b4027
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/IRemoteResourceSelectorProxy.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import java.net.URI;
+
+import org.eclipse.swt.widgets.Shell;
+
+public interface IRemoteResourceSelectorProxy {
+ public URI selectFile(String scheme, String initialPath, String prompt, Shell shell);
+ public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell);
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/LocalResourceSelectorProxy.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/LocalResourceSelectorProxy.java
new file mode 100644
index 0000000..21215e7
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/LocalResourceSelectorProxy.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class LocalResourceSelectorProxy implements IRemoteResourceSelectorProxy {
+
+ public URI selectFile(String scheme, String initialPath, String prompt, Shell shell) {
+ FileDialog dialog = new FileDialog(shell, SWT.SHEET);
+ dialog.setText(prompt);
+ dialog.setFilterPath(initialPath);
+ try {
+ String path = dialog.open();
+ if (path != null)
+ return new URI(path);
+ else
+ return null;
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
+ public URI selectDirectory(String scheme, String initialPath, String prompt, Shell shell) {
+ DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SHEET);
+ dialog.setText(prompt);
+ dialog.setFilterPath(initialPath);
+ try {
+ String path = dialog.open();
+ if (path != null)
+ return new URI(path);
+ else
+ return null;
+ } catch (URISyntaxException e) {
+ return null;
+ }
+
+ }
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java
new file mode 100644
index 0000000..4da94e5
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidget.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class ResourceSelectorWidget {
+
+ public enum ResourceType { FILE, DIRECTORY };
+
+ private static String BROWSE_LABEL = ResourceSelectorWidgetMessages.browseLabelText;
+
+ private ResourceType resourceType;
+ private Group mainComp;
+ private String sectionLabelText;
+ protected Label sectionLabel;
+ private Label uriLabel;
+ private Text uriField;
+ private Button browseButton;
+ private FileSystemSelectionArea fileSystemSelectionArea;
+
+ /**
+ * Return the path on the URI field.
+ *
+ * @return the path or the field's text if the path is invalid
+ */
+ public String getPathFromURIField() {
+ URI fieldURI;
+ try {
+ fieldURI = new URI(uriField.getText());
+ } catch (URISyntaxException e) {
+ return uriField.getText();
+ }
+ String path = fieldURI.getPath();
+ return path != null ? path : uriField.getText();
+ }
+
+ /**
+ * Open an appropriate directory browser
+ */
+ private void handleURIBrowseButtonPressed() {
+
+ String selectedResource = null;
+ String path = getURIText().getText();
+ FileSystemElement fileSystem = fileSystemSelectionArea.getSelectedFileSystem();
+
+ IRemoteResourceSelectorProxy resourceSelector = fileSystem.getSelectorProxy();
+ if (resourceSelector != null) {
+ switch (resourceType) {
+ case FILE: {
+ URI uri = resourceSelector.selectFile(fileSystem.getScheme(), path, ResourceSelectorWidgetMessages.ResourceSelectorWidget_select + sectionLabelText, browseButton.getShell());
+ if (uri != null)
+ selectedResource = uri.toString();
+ break;
+ }
+ case DIRECTORY: {
+ URI uri = resourceSelector.selectDirectory(fileSystem.getScheme(), path, ResourceSelectorWidgetMessages.ResourceSelectorWidget_select + sectionLabelText, browseButton.getShell());
+ if (uri != null)
+ selectedResource = uri.toString();
+ break;
+ }
+ default:
+ Activator.log(Status.ERROR, ResourceSelectorWidgetMessages.ResourceSelectorWidget_unrecognized_resourceType);
+ return;
+ }
+ } else {
+ Activator.log(Status.ERROR, ResourceSelectorWidgetMessages.ResourceSelectorWidget_getSelectorProxy_returned_null);
+ }
+
+ if (selectedResource != null) {
+ updateURIField(selectedResource);
+ }
+ }
+
+
+
+ /**
+ * Update the filesystem selector, if possible
+ *
+ * @param newPath
+ */
+ private void updateFilesystemSelector(String newPath) {
+ try {
+ URI selectedURI = new URI(newPath);
+ String scheme = selectedURI.getScheme();
+ try {
+ if (scheme == null) {
+ fileSystemSelectionArea.setSelectedFileSystem("local"); //$NON-NLS-1$
+ } else {
+ fileSystemSelectionArea.setSelectedFileSystem(scheme);
+ }
+ } catch (CoreException e) {
+ // Probably an unrecognized scheme. Don't change the setting of
+ // the filesystem selector.
+ }
+ } catch (URISyntaxException e) {
+ // This error can be ignored because we just won't set the filesystem selector
+ // to a anything
+ }
+ }
+
+ /**
+ * Update the URI field based on the selected path.
+ *
+ * @param selectedPath
+ */
+ private void updateURIField(String selectedPath) {
+ uriField.setText(TextProcessor.process(selectedPath));
+ updateFilesystemSelector(selectedPath);
+ }
+
+ /**
+ * Create the file system selection area.
+ *
+ * @param composite
+ */
+ private void createFileSystemSelection(Composite composite) {
+ fileSystemSelectionArea = new FileSystemSelectionArea();
+ fileSystemSelectionArea.createContents(composite);
+ }
+
+ /**
+ * Create the area for user entry.
+ *
+ * @param composite
+ * @param defaultEnabled
+ */
+ private void createUserEntryArea(Composite composite, String uriLabelText, boolean defaultEnabled) {
+ // location label
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ uriLabel = new Label(composite, SWT.NONE);
+ if (uriLabelText != null)
+ uriLabel.setText(uriLabelText);
+ else
+ uriLabel.setText(ResourceSelectorWidgetMessages.uriLabelText);
+
+ // project location entry field
+ uriField = new Text(composite, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+
+ data.horizontalSpan = 1;
+ uriField.setLayoutData(data);
+
+ // create a blank space to align the filesystem selector with the path box.
+ new Label(composite, SWT.NONE);
+
+ Composite browserComp = new Composite(composite, SWT.NONE);
+ FillLayout browserLayout = new FillLayout(SWT.HORIZONTAL);
+ browserComp.setLayout(browserLayout);
+
+ createFileSystemSelection(browserComp);
+
+ // browse button
+ browseButton = new Button(browserComp, SWT.PUSH);
+ browseButton.setText(BROWSE_LABEL);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ handleURIBrowseButtonPressed();
+ }
+ });
+
+ uriField.addModifyListener(new ModifyListener() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText(ModifyEvent e) {
+ updateFilesystemSelector(uriField.getText());
+ }
+ });
+ }
+
+ public ResourceSelectorWidget(Composite parent, ResourceType resourceType, int colSpan, String sectionLabelText, String uriLabelText) {
+ this.resourceType = resourceType;
+ this.sectionLabelText = sectionLabelText;
+ mainComp = new Group(parent, SWT.NONE);
+ GridLayout mainLayout = new GridLayout();
+ mainLayout.numColumns = 5;
+ mainLayout.marginHeight = 0;
+ mainLayout.marginWidth = 0;
+ mainComp.setLayout(mainLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = colSpan;
+ mainComp.setLayoutData(gd);
+ mainComp.setText(sectionLabelText);
+ createUserEntryArea(mainComp, uriLabelText, true);
+ }
+
+ public void setEnabled(boolean enabled) {
+ if (mainComp != null)
+ mainComp.setEnabled(enabled);
+ if (sectionLabel != null)
+ sectionLabel.setEnabled(enabled);
+ if (uriLabel != null)
+ uriLabel.setEnabled(enabled);
+ if (browseButton != null)
+ browseButton.setEnabled(enabled);
+ if (uriField != null)
+ uriField.setEnabled(enabled);
+ if (fileSystemSelectionArea != null)
+ fileSystemSelectionArea.setEnabled(enabled);
+ }
+
+ public Text getURIText() {
+ return uriField;
+ }
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidgetMessages.java b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidgetMessages.java
new file mode 100644
index 0000000..b4a3dac
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/ResourceSelectorWidgetMessages.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.profiling.launch.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ResourceSelectorWidgetMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.profiling.launch.ui.messages";//$NON-NLS-1$
+
+ public static String uriLabelText;
+ public static String browseLabelText;
+
+ public static String FileSystemSelectionArea_unrecognized_scheme;
+
+ public static String FileSystemSelectionArea_exception_while_creating_runnable_class;
+
+ public static String FileSystemSelectionArea_found_multiple_default_extensions;
+ public static String fileSystemSelectionText;
+
+ public static String ResourceSelectorWidget_getSelectorProxy_returned_null;
+ public static String ResourceSelectorWidget_invalid_location;
+ public static String ResourceSelectorWidget_select;
+ public static String ResourceSelectorWidget_unrecognize_resourceType;
+ public static String ResourceSelectorWidget_unrecognized_resourceType;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ResourceSelectorWidgetMessages.class);
+ }
+
+}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/messages.properties b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/messages.properties
new file mode 100644
index 0000000..3c6852d
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.profiling.launch.ui/src/org/eclipse/linuxtools/profiling/launch/ui/messages.properties
@@ -0,0 +1,13 @@
+# org.eclipse.linuxtoos.profiling.launch.ui.messages
+
+uriLabelText=URI:
+browseLabelText=Browse...
+FileSystemSelectionArea_unrecognized_scheme=Unrecognized scheme:
+FileSystemSelectionArea_exception_while_creating_runnable_class=CoreException thrown while creating runnable class for IRemoteResourceSelector:
+FileSystemSelectionArea_found_multiple_default_extensions=Found multiple RemoteResourceSelectorProxy extensions marked as default;
+fileSystemSelectionText=Choose file system:
+ResourceSelectorWidget_getSelectorProxy_returned_null=getSelectorProxy returned a null pointer
+ResourceSelectorWidget_invalid_location=Invalid location:
+ResourceSelectorWidget_select=Select the
+ResourceSelectorWidget_unrecognize_resourceType=Unrecognized resourceType value.
+ResourceSelectorWidget_unrecognized_resourceType=Unrecognized resourceType value.