Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2012-09-05 15:43:46 +0000
committerRoland Grunberg2012-09-05 20:00:01 +0000
commit756c7d1a765fdc6bc314ae13378d94fe9ff1fd22 (patch)
tree05beccb05bc3fd9e7efef0b354ef6f0e8bdbf568
parent40a29fe7cc5a77052018fcae03bc04cb510d36d7 (diff)
downloadorg.eclipse.linuxtools-756c7d1a765fdc6bc314ae13378d94fe9ff1fd22.tar.gz
org.eclipse.linuxtools-756c7d1a765fdc6bc314ae13378d94fe9ff1fd22.tar.xz
org.eclipse.linuxtools-756c7d1a765fdc6bc314ae13378d94fe9ff1fd22.zip
Revert "Profiling type launch shortcuts should call provider's launch shortcut."
This reverts commit 24c6de80d252339b51b2ab11a093d34d91f1d91f, which separated launching from a shortcut and launching from a delegate. This functionality was not correct as it did not allow to change the underlying tool which was providing the delegate and shortcut classes. In addition, the configuration passed on to the delagate is updated to include plug-in specfic launch configuration attributes. Change-Id: I34131c7e6ddd26c141eabc7a89030795e0f4a38f Reviewed-on: https://git.eclipse.org/r/7627 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchShortcut.java18
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java2
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java36
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java46
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties1
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchConfigurationDelegate.java7
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchShortcut.java8
7 files changed, 64 insertions, 54 deletions
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 1512500f26..8df9721606 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
@@ -284,9 +284,25 @@ public abstract class ProfileLaunchShortcut implements ILaunchShortcut {
* @return
*/
protected abstract ILaunchConfigurationType getLaunchConfigType();
-
+
protected abstract void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException;
+ /**
+ * Set default attributes for the given configuration.
+ *
+ * @param config
+ * @since 1.2
+ */
+ public void setDefaultProfileLaunchShortcutAttributes(ILaunchConfiguration config){
+ try {
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ setDefaultProfileAttributes(wc);
+ config = wc.doSave();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
protected ILaunchConfiguration createConfiguration(IBinary bin) {
ILaunchConfiguration config = null;
try {
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java
index b14e0704dd..114ef8c0ce 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java
@@ -41,7 +41,7 @@ public abstract class ProviderOptionsTab extends ProfileLaunchConfigurationTab {
HashMap<String, String> comboItems;
CTabFolder tabgroup;
Boolean initialized;
- public static final String PROVIDER_CONFIG_ATT = "provider"; //$NON-NLS-1$
+ private static final String PROVIDER_CONFIG_ATT = "provider"; //$NON-NLS-1$
public void createControl(Composite parent) {
top = new Composite(parent, SWT.NONE);
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java
index 46ebff8f36..f9c57e13be 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java
@@ -12,10 +12,13 @@ package org.eclipse.linuxtools.internal.profiling.provider.launch;
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.linuxtools.internal.profiling.provider.ProviderOptionsTab;
+import org.eclipse.linuxtools.internal.profiling.provider.AbstractProviderPreferencesPage;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationDelegate;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
public abstract class ProviderLaunchConfigurationDelegate extends
ProfileLaunchConfigurationDelegate {
@@ -28,13 +31,18 @@ public abstract class ProviderLaunchConfigurationDelegate extends
if (config != null) {
// get provider id from configuration.
String providerId = config.getAttribute(
- ProviderOptionsTab.PROVIDER_CONFIG_ATT, "");
+ AbstractProviderPreferencesPage.PREFS_KEY, "");
if (providerId.equals("")) {
- // No provider available in the configuration.
- return;
+ providerId = getProviderIdToRun();
}
// get configuration delegate associated with provider id.
+ ProfileLaunchShortcut shortcut= ProfileLaunchShortcut.getLaunchShortcutProviderFromId(providerId);
+ // set attributes related to the specific profiling shortcut configuration.
+ shortcut.setDefaultProfileLaunchShortcutAttributes(config);
+ // get delegate associated with provider id.
ProfileLaunchConfigurationDelegate delegate = getConfigurationDelegateFromId(providerId);
+
+ // launch delegate
if (delegate != null) {
delegate.launch(config, mode, launch, monitor);
}
@@ -45,8 +53,28 @@ public abstract class ProviderLaunchConfigurationDelegate extends
return;
}
+ private String getProviderIdToRun() {
+ // Get self assigned default
+ String providerId = ConfigurationScope.INSTANCE.getNode(
+ getProfilingType()).get(
+ AbstractProviderPreferencesPage.PREFS_KEY, "");
+ if (providerId.equals("")) {
+ providerId = ProfileLaunchConfigurationTabGroup
+ .getHighestProviderId(getProfilingType());
+ if (providerId.equals("")) {
+ // Get highest priority provider
+ providerId = ProfileLaunchShortcut
+ .getDefaultLaunchShortcutProviderId(getProfilingType());
+ }
+ }
+ return providerId;
+ }
+
@Override
public String generateCommand(ILaunchConfiguration config) {
return null;
}
+
+ public abstract String getProfilingType();
+
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java
index 69eb8b64dd..42b6d8d0fb 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchShortcut.java
@@ -10,27 +10,16 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.profiling.provider.launch;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.linuxtools.internal.profiling.provider.AbstractProviderPreferencesPage;
-import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
public abstract class ProviderLaunchShortcut extends ProfileLaunchShortcut {
@Override
- public void launch(IBinary bin, String mode) {
- String providerId = getProviderIdToRun();
- ProfileLaunchShortcut shortcut = ProfileLaunchShortcut
- .getLaunchShortcutProviderFromId(providerId);
- if (shortcut != null) {
- shortcut.launch(bin, mode);
- } else {
- handleFail(Messages.ProviderLaunchShortcut_0 + getProfilingType());
- }
+ protected ILaunchConfigurationType getLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(getLaunchConfigID());
}
@Override
@@ -41,39 +30,10 @@ public abstract class ProviderLaunchShortcut extends ProfileLaunchShortcut {
}
/**
- * Get id of provider to launch.
- *
- * @return unique id of provider to launch.
- */
- private String getProviderIdToRun() {
- String profilingType = getProfilingType();
- // Get launch provider id from preferences.
- String providerId = ConfigurationScope.INSTANCE.getNode(
- profilingType).get(
- AbstractProviderPreferencesPage.PREFS_KEY, "");
- if (providerId.equals("")) {
- // Get highest priority launch provider id.
- providerId = ProfileLaunchConfigurationTabGroup
- .getHighestProviderId(profilingType);
- if (providerId.equals("")) {
- // Get self assigned default.
- providerId = ProfileLaunchShortcut
- .getDefaultLaunchShortcutProviderId(profilingType);
- }
- }
- return providerId;
- }
-
- /**
* Get profiling type of this plug-in.
*
* @return String profiling type this plug-in supports.
*/
- protected abstract String getProfilingType();
+ protected abstract String getLaunchConfigID();
- @Override
- protected ILaunchConfigurationType getLaunchConfigType() {
- // Not needed since we are overriding launch method.
- return null;
- }
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties
index fada366d50..ea914350af 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/messages.properties
@@ -2,4 +2,3 @@ ProviderLaunchShortcut_0=Could not find a provider for profiling type :
ProviderPreferencesPage_0=Profiling Preferences
ProviderPreferencesPage_1=Choose default launch provider
ProviderOptionsTab_0=No plug-in provider found in launch configuration
-
diff --git a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchConfigurationDelegate.java
index 4ac92913b1..ccbd1442bc 100644
--- a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchConfigurationDelegate.java
+++ b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchConfigurationDelegate.java
@@ -15,7 +15,7 @@ import org.eclipse.linuxtools.profiling.snapshot.SnapshotProviderPlugin;
/**
* The launch configuration delegate for this plug-in.
- *
+ *
*/
public class SnapshotLaunchConfigurationDelegate extends
ProviderLaunchConfigurationDelegate {
@@ -24,4 +24,9 @@ public class SnapshotLaunchConfigurationDelegate extends
protected String getPluginID() {
return SnapshotProviderPlugin.PLUGIN_ID;
}
+
+ @Override
+ public String getProfilingType() {
+ return SnapshotProviderPlugin.PROFILING_TYPE;
+ }
}
diff --git a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchShortcut.java b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchShortcut.java
index d8f23cb06e..718b2be731 100644
--- a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchShortcut.java
+++ b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/launch/SnapshotLaunchShortcut.java
@@ -15,12 +15,14 @@ import org.eclipse.linuxtools.profiling.snapshot.SnapshotProviderPlugin;
/**
* The launch shortcut for this plug-in.
- *
+ *
*/
public class SnapshotLaunchShortcut extends ProviderLaunchShortcut {
@Override
- protected String getProfilingType() {
- return SnapshotProviderPlugin.PROFILING_TYPE;
+ protected String getLaunchConfigID() {
+ return SnapshotProviderPlugin.PLUGIN_CONFIG_ID;
}
+
+
}

Back to the top