summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2012-12-17 11:39:47 (EST)
committer Roland Grunberg2012-12-17 14:28:01 (EST)
commitaf7f7c510fc3a16e1990415c424f2344f85b6f67 (patch)
tree961e505208bd6a779e62e1318327b1d582c5e84b
parenta27b20c009899e41fe83c07292384825c4b5160d (diff)
downloadorg.eclipse.linuxtools-af7f7c510fc3a16e1990415c424f2344f85b6f67.zip
org.eclipse.linuxtools-af7f7c510fc3a16e1990415c424f2344f85b6f67.tar.gz
org.eclipse.linuxtools-af7f7c510fc3a16e1990415c424f2344f85b6f67.tar.bz2
Move launchProvider extension access methods to ProviderFramework.refs/changes/69/9269/3
Methods to access information provided to the launchProvider extension are now located at a common class. Change-Id: I285b4c3b2f97a2ba8bb655c9dad218358dcc4501 Reviewed-on: https://git.eclipse.org/r/9269 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/internal/gprof/test/GprofShortcutTest.java4
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPreferencesPage.java33
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java34
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/ProviderOptionsTab.java5
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java192
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java63
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchShortcut.java6
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java111
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java29
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/ExtensionPointTest.java7
10 files changed, 202 insertions, 282 deletions
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/internal/gprof/test/GprofShortcutTest.java b/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/internal/gprof/test/GprofShortcutTest.java
index 2fae870..8ccd309 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/internal/gprof/test/GprofShortcutTest.java
+++ b/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/internal/gprof/test/GprofShortcutTest.java
@@ -24,7 +24,7 @@ import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
import org.eclipse.linuxtools.internal.gprof.launch.GprofLaunchConfigurationDelegate;
import org.eclipse.linuxtools.internal.profiling.launch.provider.ProviderProfileConstants;
-import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderLaunchShortcut;
import org.eclipse.linuxtools.profiling.tests.AbstractTest;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
@@ -93,7 +93,7 @@ public class GprofShortcutTest extends AbstractTest {
@Test
public void testShortCut() {
try {
- String id = ProviderLaunchConfigurationDelegate.getProviderIdToRun(wc, GPROF_CATEGORY);
+ String id = ProviderFramework.getProviderIdToRun(wc, GPROF_CATEGORY);
assertTrue(id.equals(GPROF_PROVIDER_ID));
shortcut.launch(proj.getBinaryContainer().getBinaries()[0], ILaunchManager.PROFILE_MODE);
} catch (Exception e) {
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPreferencesPage.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPreferencesPage.java
index 4b690dd..52030e7 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPreferencesPage.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPreferencesPage.java
@@ -16,13 +16,10 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
-import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.Messages;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
import org.eclipse.swt.widgets.Composite;
@@ -97,7 +94,7 @@ public class AbstractProviderPreferencesPage extends
int i = 0;
for (Entry<String, String> entry : map.entrySet()) {
String toolId = entry.getValue();
- String toolDescription = getToolInformationFromId(toolId, PROVIDER_ATT_DESC);
+ String toolDescription = ProviderFramework.getToolInformationFromId(toolId, PROVIDER_ATT_DESC);
String toolName = entry.getKey();
// Append tool description to tool name if available.
@@ -127,7 +124,7 @@ public class AbstractProviderPreferencesPage extends
// Get tool specific information from provider id.
String curProviderId = (String) control.getData();
// Set tool tip description text.
- String toolDescription = getToolInformationFromId(curProviderId,
+ String toolDescription = ProviderFramework.getToolInformationFromId(curProviderId,
PROVIDER_ATT_INFO);
if (toolDescription != null && !toolDescription.equals("")) {
control.setToolTipText(toolDescription);
@@ -152,30 +149,4 @@ public class AbstractProviderPreferencesPage extends
private void setProfilingType(String profilingType) {
type = profilingType;
}
-
- /**
- * Get content of attribute <code>attribute</code> from the launch provider
- * with id <code>toolId</code>.
- *
- * @param toolId String unique id of the tool.
- * @return String description of tool.
- */
- private static String getToolInformationFromId(String toolId,
- String attribute) {
- 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 currentToolDescription = config.getAttribute(attribute); //$NON-NLS-1$
- if (currentId != null && currentToolDescription != null
- && currentId.equals(toolId)) {
- return currentToolDescription;
- }
- }
- }
- return null;
- }
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
index c630f3e..274b942 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/AbstractProviderPropertyTab.java
@@ -19,12 +19,8 @@ import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.Messages;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
import org.eclipse.swt.SWT;
@@ -110,7 +106,7 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab {
int i = 0;
for (Entry<String, String> entry : map.entrySet()) {
String toolId = entry.getValue();
- String toolDescription = getToolInformationFromId(toolId, PROVIDER_ATT_DESC);
+ String toolDescription = ProviderFramework.getToolInformationFromId(toolId, PROVIDER_ATT_DESC);
String toolName = entry.getKey();
// Append tool description to tool name if available.
@@ -140,7 +136,7 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab {
String[] labelAndValue = providerList[j];
String curProviderId = labelAndValue[1];
// Set tool tip description text.
- String toolInfo = getToolInformationFromId(curProviderId,
+ String toolInfo = ProviderFramework.getToolInformationFromId(curProviderId,
PROVIDER_ATT_INFO);
if (toolInfo != null && !toolInfo.equals("")) {
radio.setToolTipText(toolInfo);
@@ -274,30 +270,4 @@ public abstract class AbstractProviderPropertyTab extends AbstractCPropertyTab {
@Override
protected void updateData(ICResourceDescription cfg) {/* Empty block */}
- /**
- * Get content of attribute <code>attribute</code> from the launch provider
- * with id <code>toolId</code>.
- *
- * @param toolId String unique id of the tool.
- * @return String description of tool.
- */
- private static String getToolInformationFromId(String toolId,
- String attribute) {
- 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 currentToolDescription = config.getAttribute(attribute); //$NON-NLS-1$
- if (currentId != null && currentToolDescription != null
- && currentId.equals(toolId)) {
- return currentToolDescription;
- }
- }
- }
- return null;
- }
-
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/ProviderOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/ProviderOptionsTab.java
index fe66599..c0234d3 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/ProviderOptionsTab.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/ProviderOptionsTab.java
@@ -21,7 +21,6 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.Messages;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
-import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderLaunchConfigurationDelegate;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderLaunchShortcut;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTab;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
@@ -100,14 +99,14 @@ public class ProviderOptionsTab extends ProfileLaunchConfigurationTab {
if (curProviderId == null || "".equals(curProviderId)) {
// get the id of a provider
- curProviderId = ProviderLaunchConfigurationDelegate
+ curProviderId = ProviderFramework
.getProviderIdToRun(null, getProfilingType());
}
// starting initialization of this tab's controls
initialized.put(curProviderId, false);
- tabGroupConfig = ProfileLaunchConfigurationTabGroup
+ tabGroupConfig = ProviderFramework
.getTabGroupProviderFromId(curProviderId);
if (tabGroupConfig == null) {
// no provider found
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
index 8ad2082..52cddc0 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderFramework.java
@@ -15,13 +15,21 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
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.preferences.ConfigurationScope;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.linuxtools.internal.profiling.launch.provider.ProviderProfileConstants;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
/**
* This class has various methods to access relevant information from
@@ -252,14 +260,11 @@ public class ProviderFramework {
* extensions of the
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
* extensions point.
- *
- * @since 1.2
+ *
+ * @since 2.0
*/
public static String getProviderToolNameFromId(String id) {
- IExtensionPoint extPoint = Platform.getExtensionRegistry()
- .getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID,
- "launchProvider"); //$NON-NLS-1$
- IConfigurationElement[] configs = extPoint.getConfigurationElements();
+ IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) { //$NON-NLS-1$
String currentId = config.getAttribute("id"); //$NON-NLS-1$
@@ -271,4 +276,179 @@ public class ProviderFramework {
return null;
}
+ /**
+ * Get content of attribute <code>attribute</code> from the launch provider
+ * with id <code>toolId</code>.
+ *
+ * @param toolId String unique id of the tool.
+ * @return String description of tool.
+ * @since 2.0
+ */
+ public static String getToolInformationFromId(String toolId,
+ String attribute) {
+ IConfigurationElement[] configs = getConfigurationElements();
+ for (IConfigurationElement config : configs) {
+ if (config.getName().equals("provider")) { //$NON-NLS-1$
+ String currentId = config.getAttribute("id"); //$NON-NLS-1$
+ String currentToolDescription = config.getAttribute(attribute); //$NON-NLS-1$
+ if (currentId != null && currentToolDescription != null
+ && currentId.equals(toolId)) {
+ return currentToolDescription;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get a profiling tab that provides the specified type of profiling. This
+ * looks through extensions of the extension point
+ * <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that have a
+ * specific type attribute.
+ *
+ * @param type A profiling type (eg. memory, snapshot, timing, etc.)
+ * @return a tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
+ * and provides the necessary profiling type, or <code>null</code> if none could be found.
+ * @since 2.0
+ */
+ public static ProfileLaunchConfigurationTabGroup getTabGroupProvider(String type) {
+ IConfigurationElement[] configs = 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("tabgroup"); //$NON-NLS-1$
+ if (currentType != null && shortcut != null
+ && currentType.equals(type)) {
+ try {
+ Object obj = config
+ .createExecutableExtension("tabgroup"); //$NON-NLS-1$
+ if (obj instanceof ProfileLaunchConfigurationTabGroup) {
+ return (ProfileLaunchConfigurationTabGroup) obj;
+ }
+ } catch (CoreException e) {
+ // continue, perhaps another configuration will succeed
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get a profiling tab 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 tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
+ * and provides the necessary profiling type, or <code>null</code> if none could be found.
+ * @since 2.0
+ */
+ public static ProfileLaunchConfigurationTabGroup getTabGroupProviderFromId(
+ String id) {
+ IConfigurationElement[] configs = getConfigurationElements();
+ for (IConfigurationElement config : configs) {
+ if (config.getName().equals("provider")) { //$NON-NLS-1$
+ String currentId = config.getAttribute("id"); //$NON-NLS-1$
+ String tabgroup = config.getAttribute("tabgroup"); //$NON-NLS-1$
+ if (currentId != null && tabgroup != null
+ && currentId.equals(id)) {
+ try {
+ Object obj = config
+ .createExecutableExtension("tabgroup"); //$NON-NLS-1$
+ if (obj instanceof ProfileLaunchConfigurationTabGroup) {
+ return (ProfileLaunchConfigurationTabGroup) obj;
+ }
+ } catch (CoreException e) {
+ // continue, perhaps another configuration will succeed
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all IDs of the specific type. This looks through extensions of
+ * the extension point <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
+ * that have a specific type.
+ *
+ * @param type A profiling type (eg. memory, snapshot, timing, etc.)
+ * @return A <code>String []</code> of all IDs of the specific type.
+ * @since 2.0
+ */
+ public static String[] getProviderIdsForType(String type) {
+ ArrayList<String> ret = new ArrayList<String> ();
+ IConfigurationElement[] configs = getConfigurationElements();
+ for (IConfigurationElement config : configs) {
+ if (config.getName().equals("provider")) { //$NON-NLS-1$
+ String currentId = config.getAttribute("id"); //$NON-NLS-1$
+ String currentType = config.getAttribute("type"); //$NON-NLS-1$
+ if (currentType != null && type != null
+ && currentType.equals(type)) {
+ ret.add(currentId);
+ }
+ }
+ }
+ return ret.toArray(new String [] {});
+ }
+
+ /**
+ * Get a provider id to run for the given profiling type.
+ *
+ * This first checks for a provider in the project properties if the project
+ * can be found and has indicated that project preferences are to override
+ * the workspace preferences. If no project is obtainable or the project
+ * has not indicated override, then it looks at provider preferences. If these
+ * are not set or the specified preference points to a non-installed provider,
+ * it will look for the provider with the highest priority for the specified type.
+ * If this fails, it will look for the default provider.
+ *
+ * @param type a profiling type
+ * @return a provider id that contributes to the specified type
+ * @since 2.0
+ */
+
+ public static String getProviderIdToRun(ILaunchConfigurationWorkingCopy wc, String type) {
+ String providerId = null;
+ // Look for a project first
+ if (wc != null) {
+ try {
+ IResource[] resources = wc.getMappedResources();
+ if(resources != null){
+ for (int i = 0; i < resources.length; ++i) {
+ IResource resource = resources[i];
+ if (resource instanceof IProject) {
+ IProject project = (IProject)resource;
+ ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project),
+ ProviderProfileConstants.PLUGIN_ID);
+ Boolean use_project_settings = store.getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + type);
+ if (use_project_settings.booleanValue() == true) {
+ String provider = store.getString(ProviderProfileConstants.PREFS_KEY + type);
+ if (!provider.equals(""))
+ providerId = provider;
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ // if no providerId specified for project, get one from the preferences
+ if (providerId == null) {
+ // Look in the preferences for a provider
+ providerId = ConfigurationScope.INSTANCE.getNode(
+ ProviderProfileConstants.PLUGIN_ID).get(
+ ProviderProfileConstants.PREFS_KEY + type, "");
+ if (providerId.equals("") || getConfigurationDelegateFromId(providerId) == null) {
+
+ // Get highest priority provider
+ providerId = getHighestProviderId(type);
+ }
+ }
+ return providerId;
+ }
+
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java
index 5de6677..24d8b2f 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java
@@ -10,18 +10,12 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.profiling.launch.provider.launch;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.linuxtools.internal.profiling.launch.provider.ProviderProfileConstants;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class ProviderLaunchConfigurationDelegate extends
ProfileLaunchConfigurationDelegate {
@@ -46,63 +40,6 @@ public class ProviderLaunchConfigurationDelegate extends
}
}
- /**
- * Get a provider id to run for the given profiling type.
- *
- * This first checks for a provider in the project properties if the project
- * can be found and has indicated that project preferences are to override
- * the workspace preferences. If no project is obtainable or the project
- * has not indicated override, then it looks at provider preferences. If these
- * are not set or the specified preference points to a non-installed provider,
- * it will look for the provider with the highest priority for the specified type.
- * If this fails, it will look for the default provider.
- *
- * @param type a profiling type
- * @return a provider id that contributes to the specified type
- */
-
- public static String getProviderIdToRun(ILaunchConfigurationWorkingCopy wc, String type) {
- String providerId = null;
- // Look for a project first
- if (wc != null) {
- try {
- IResource[] resources = wc.getMappedResources();
- if(resources != null){
- for (int i = 0; i < resources.length; ++i) {
- IResource resource = resources[i];
- if (resource instanceof IProject) {
- IProject project = (IProject)resource;
- ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project),
- ProviderProfileConstants.PLUGIN_ID);
- Boolean use_project_settings = store.getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + type);
- if (use_project_settings.booleanValue() == true) {
- String provider = store.getString(ProviderProfileConstants.PREFS_KEY + type);
- if (!provider.equals(""))
- providerId = provider;
- }
- }
- }
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- // if no providerId specified for project, get one from the preferences
- if (providerId == null) {
- // Look in the preferences for a provider
- providerId = ConfigurationScope.INSTANCE.getNode(
- ProviderProfileConstants.PLUGIN_ID).get(
- ProviderProfileConstants.PREFS_KEY + type, "");
- if (providerId.equals("") || ProviderFramework.getConfigurationDelegateFromId(providerId) == null) {
-
- // Get highest priority provider
- providerId = ProviderFramework
- .getHighestProviderId(type);
- }
- }
- return providerId;
- }
-
@Override
public String generateCommand(ILaunchConfiguration config) {
return null;
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchShortcut.java
index 9ebe6cb..8380e1f 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchShortcut.java
@@ -72,7 +72,7 @@ public class ProviderLaunchShortcut extends ProfileLaunchShortcut implements IEx
String providerId = null;
try {
- providerId = ProviderLaunchConfigurationDelegate.getProviderIdToRun(config.getWorkingCopy(), type);
+ providerId = ProviderFramework.getProviderIdToRun(config.getWorkingCopy(), type);
} catch (CoreException e1) {
e1.printStackTrace();
}
@@ -150,13 +150,13 @@ public class ProviderLaunchShortcut extends ProfileLaunchShortcut implements IEx
protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) {
// acquire a provider id to run.
- final String providerId = ProviderLaunchConfigurationDelegate.getProviderIdToRun(wc, getProfilingType());
+ final String providerId = ProviderFramework.getProviderIdToRun(wc, getProfilingType());
// get tool name from id.
final String providerToolName = ProviderFramework.getProviderToolNameFromId(providerId);
// get tab group associated with provider id.
- final ProfileLaunchConfigurationTabGroup tabgroup = ProfileLaunchConfigurationTabGroup.getTabGroupProviderFromId(providerId);
+ final ProfileLaunchConfigurationTabGroup tabgroup = ProviderFramework.getTabGroupProviderFromId(providerId);
/**
* Certain tabs' setDefaults(ILaunchConfigurationWorkingCopy) may
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java
index f3b2949..7d29dd4 100644
--- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java
+++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationTabGroup.java
@@ -15,17 +15,13 @@ import java.util.Arrays;
import org.eclipse.cdt.launch.ui.CArgumentsTab;
import org.eclipse.cdt.launch.ui.CMainTab;
-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.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
-import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
+import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
public abstract class ProfileLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
@@ -46,81 +42,6 @@ public abstract class ProfileLaunchConfigurationTabGroup extends AbstractLaunchC
public abstract AbstractLaunchConfigurationTab[] getProfileTabs();
/**
- * Get a profiling tab that provides the specified type of profiling. This
- * looks through extensions of the extension point
- * <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that have a
- * specific type attribute.
- *
- * @param type A profiling type (eg. memory, snapshot, timing, etc.)
- * @return a tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
- * and provides the necessary profiling type, or <code>null</code> if none could be found.
- * @since 1.1
- */
- public static ProfileLaunchConfigurationTabGroup getTabGroupProvider(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("tabgroup"); //$NON-NLS-1$
- if (currentType != null && shortcut != null
- && currentType.equals(type)) {
- try {
- Object obj = config
- .createExecutableExtension("tabgroup"); //$NON-NLS-1$
- if (obj instanceof ProfileLaunchConfigurationTabGroup) {
- return (ProfileLaunchConfigurationTabGroup) obj;
- }
- } catch (CoreException e) {
- // continue, perhaps another configuration will succeed
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Get a profiling tab 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 tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
- * and provides the necessary profiling type, or <code>null</code> if none could be found.
- * @since 1.1
- */
- public static ProfileLaunchConfigurationTabGroup getTabGroupProviderFromId(
- 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 tabgroup = config.getAttribute("tabgroup"); //$NON-NLS-1$
- if (currentId != null && tabgroup != null
- && currentId.equals(id)) {
- try {
- Object obj = config
- .createExecutableExtension("tabgroup"); //$NON-NLS-1$
- if (obj instanceof ProfileLaunchConfigurationTabGroup) {
- return (ProfileLaunchConfigurationTabGroup) obj;
- }
- } catch (CoreException e) {
- // continue, perhaps another configuration will succeed
- }
- }
- }
- }
- return null;
- }
-
- /**
* Get all IDs of the specific type. This looks through extensions of
* the extension point <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
* that have a specific type.
@@ -132,35 +53,7 @@ public abstract class ProfileLaunchConfigurationTabGroup extends AbstractLaunchC
*/
@Deprecated
public static String[] getTabGroupIdsForType(String type) {
- return getProviderIdsForType(type);
- }
-
- /**
- * Get all IDs of the specific type. This looks through extensions of
- * the extension point <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
- * that have a specific type.
- *
- * @param type A profiling type (eg. memory, snapshot, timing, etc.)
- * @return A <code>String []</code> of all IDs of the specific type.
- * @since 1.2
- */
- public static String[] getProviderIdsForType(String type) {
- ArrayList<String> ret = new ArrayList<String> ();
- 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 currentType = config.getAttribute("type"); //$NON-NLS-1$
- if (currentType != null && type != null
- && currentType.equals(type)) {
- ret.add(currentId);
- }
- }
- }
- return ret.toArray(new String [] {});
+ return ProviderFramework.getProviderIdsForType(type);
}
} \ No newline at end of file
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 ebfd45f..8974c72 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
@@ -27,7 +27,6 @@ import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -48,7 +47,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.profiling.launch.Messages;
import org.eclipse.linuxtools.internal.profiling.launch.ProfileLaunchPlugin;
-import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
@@ -74,33 +72,6 @@ public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
}
/**
- * Get a profiling launch shortcut that provides the specified type of profiling. This
- * looks through extensions of the extension point
- * <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that have a
- * specific type attribute.
- *
- * @param type A profiling type (eg. memory, snapshot, timing, etc.)
- * @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 ProfileLaunchShortcut getProfilingProvider(String type) {
- ArrayList<IConfigurationElement> configList = ProviderFramework.getOrderedConfigElements(type);
-
- for (IConfigurationElement config : configList) {
- try {
- Object obj = config.createExecutableExtension("shortcut"); //$NON-NLS-1$
- if (obj instanceof ProfileLaunchShortcut) {
- return (ProfileLaunchShortcut) obj;
- }
- } catch (CoreException e) {
- // continue, other configuration may 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
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/ExtensionPointTest.java b/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/ExtensionPointTest.java
index 26bb7f7..45c61c9 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/ExtensionPointTest.java
+++ b/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/ExtensionPointTest.java
@@ -17,7 +17,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import org.eclipse.linuxtools.internal.profiling.launch.provider.ProviderLaunchConfigurationTabGroup;
import org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderFramework;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
@@ -37,7 +36,7 @@ public class ExtensionPointTest {
String highestProviderId = ProviderFramework.getHighestProviderId(PROFILING_TYPE);
assertEquals(PLUGIN_ID + "1", highestProviderId);
- String[] providerIds = ProviderLaunchConfigurationTabGroup.getProviderIdsForType(PROFILING_TYPE);
+ String[] providerIds = ProviderFramework.getProviderIdsForType(PROFILING_TYPE);
HashSet<String> set = new HashSet<String>(Arrays.asList(providerIds));
for (int i = 0; i < providerIds.length; i++){
assertTrue(set.contains(PLUGIN_ID + (i+1)));
@@ -71,8 +70,8 @@ public class ExtensionPointTest {
@Test
public void testTabGroup () {
- ProfileLaunchConfigurationTabGroup tabgroup = ProviderLaunchConfigurationTabGroup.getTabGroupProvider(PROFILING_TYPE);
- ProfileLaunchConfigurationTabGroup tabgroup2 = ProviderLaunchConfigurationTabGroup.getTabGroupProviderFromId(PLUGIN_ID + "1");
+ ProfileLaunchConfigurationTabGroup tabgroup = ProviderFramework.getTabGroupProvider(PROFILING_TYPE);
+ ProfileLaunchConfigurationTabGroup tabgroup2 = ProviderFramework.getTabGroupProviderFromId(PLUGIN_ID + "1");
assertTrue(tabgroup instanceof StubbyLaunchConfigurationTabGroup);
assertTrue(tabgroup2 instanceof StubbyLaunchConfigurationTabGroup);