aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2012-08-09 10:51:57 (EDT)
committerRoland Grunberg2012-08-09 17:16:39 (EDT)
commit3a4e285b915e2a1d4c7a6f39eba8def33b0f21d9 (patch)
tree88b225737e76184e9122fa7364f2266897ff373a
parentb35ae49281d9a6547b78099c9ef545f88444f0ae (diff)
downloadorg.eclipse.linuxtools-3a4e285b915e2a1d4c7a6f39eba8def33b0f21d9.zip
org.eclipse.linuxtools-3a4e285b915e2a1d4c7a6f39eba8def33b0f21d9.tar.gz
org.eclipse.linuxtools-3a4e285b915e2a1d4c7a6f39eba8def33b0f21d9.tar.bz2
Add default attribute to launch provider schema.
The launch provider schema has a default attribute to assign a launch provider as a default. Respective functionality is implemented in ProfileLaunchShortcut in order to retrieve the default attribute. Also, Perf's launch provider extension point has been updated to reflect this change. Change-Id: If187a6779243aefeea99fc03286bbe53323199ed Reviewed-on: https://git.eclipse.org/r/7165 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.xml1
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/schema/org.eclipse.linuxtools.profiling.launch.provider.exsd7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java80
3 files changed, 88 insertions, 0 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.xml b/perf/org.eclipse.linuxtools.perf/plugin.xml
index 2a8d41f..4db4b15 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.xml
+++ b/perf/org.eclipse.linuxtools.perf/plugin.xml
@@ -135,6 +135,7 @@
<extension
point="org.eclipse.linuxtools.profiling.launch.launchProvider">
<provider
+ default="true"
delegate="org.eclipse.linuxtools.internal.perf.launch.PerfLaunchConfigDelegate"
id="org.eclipse.linuxtools.perf.provider"
name="Perf"
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/schema/org.eclipse.linuxtools.profiling.launch.provider.exsd b/profiling/org.eclipse.linuxtools.profiling.launch/schema/org.eclipse.linuxtools.profiling.launch.provider.exsd
index 811a522..6af63a7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/schema/org.eclipse.linuxtools.profiling.launch.provider.exsd
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/schema/org.eclipse.linuxtools.profiling.launch.provider.exsd
@@ -108,6 +108,13 @@ Invalid values will be assigned the lowest priority to the extension.
</documentation>
</annotation>
</attribute>
+ <attribute name="default" type="boolean" use="required">
+ <annotation>
+ <documentation>
+ If true, this launch provider is set as default for the given type.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
index 58c43fc..1512500 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java
@@ -152,6 +152,86 @@ public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
}
/**
+ * Get id of default profiling launch shortcut that provides the type
+ * of profiling. This looks through extensions of the
+ * <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
+ * extension point that have a specific type attribute.
+ *
+ * @param type A profiling type (eg. memory, snapshot, timing, etc.)
+ * @return an id of the profiling launch shortcut that implements
+ * <code>ProfileLaunchShortcut</code> and provides the necessary
+ * profiling type, or <code>null</code> if none could be found.
+ * @since 1.2
+ */
+ public static String getDefaultLaunchShortcutProviderId(String type) {
+ IExtensionPoint extPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID,
+ "launchProvider"); //$NON-NLS-1$
+ IConfigurationElement[] configs = extPoint.getConfigurationElements();
+ for (IConfigurationElement config : configs) {
+ if (config.getName().equals("provider")) { //$NON-NLS-1$
+ String currentType = config.getAttribute("type"); //$NON-NLS-1$
+ String shortcut = config.getAttribute("shortcut"); //$NON-NLS-1$
+ if (currentType != null && shortcut != null
+ && currentType.equals(type)) {
+ String isDefault = config.getAttribute("default");
+ if (isDefault != null && isDefault.equals("true")) {
+ try {
+ Object obj = config
+ .createExecutableExtension("shortcut"); //$NON-NLS-1$
+ if (obj instanceof ProfileLaunchShortcut) {
+ return config.getAttribute("id");
+ }
+ } catch (CoreException e) {
+ // continue, perhaps another configuration will
+ // succeed
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get a profiling launch shortcut that is associated with the specified id.
+ * This looks through extensions of the extension point
+ * <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
+ * that have a specific id.
+ *
+ * @param id A unique identifier
+ * @return a profiling launch shortcut that implements <code>ProfileLaunchShortcut</code>
+ * and provides the necessary profiling type, or <code>null</code> if none could be found.
+ * @since 1.2
+ */
+ public static ProfileLaunchShortcut getLaunchShortcutProviderFromId(
+ String id) {
+ IExtensionPoint extPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID,
+ "launchProvider"); //$NON-NLS-1$
+ IConfigurationElement[] configs = extPoint.getConfigurationElements();
+ for (IConfigurationElement config : configs) {
+ if (config.getName().equals("provider")) { //$NON-NLS-1$
+ String currentId = config.getAttribute("id"); //$NON-NLS-1$
+ String shortcut = config.getAttribute("shortcut"); //$NON-NLS-1$
+ if (currentId != null && shortcut != null
+ && currentId.equals(id)) {
+ try {
+ Object obj = config
+ .createExecutableExtension("shortcut"); //$NON-NLS-1$
+ if (obj instanceof ProfileLaunchShortcut) {
+ return (ProfileLaunchShortcut) obj;
+ }
+ } catch (CoreException e) {
+ // continue, perhaps another configuration will succeed
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* Locate a configuration to relaunch for the given type. If one cannot be found, create one.
*
* @return a re-useable config or <code>null</code> if none