aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2012-08-31 15:50:51 (EDT)
committerRoland Grunberg2012-09-04 15:28:18 (EDT)
commit24c6de80d252339b51b2ab11a093d34d91f1d91f (patch)
tree687dd0ae1c660c3d594dc84988159dd6078d06ef
parent4b1f81bef4faf5e32e3d41124b25dd21530fbb03 (diff)
downloadorg.eclipse.linuxtools-24c6de80d252339b51b2ab11a093d34d91f1d91f.zip
org.eclipse.linuxtools-24c6de80d252339b51b2ab11a093d34d91f1d91f.tar.gz
org.eclipse.linuxtools-24c6de80d252339b51b2ab11a093d34d91f1d91f.tar.bz2
Profiling type launch shortcuts should call provider's launch shortcut.
Launch method for the provider's launch shortcut is implemented to differentiate launching from a shortcut from launching through the dialog menu, the former is handled in the provider's launch delegate class. Change-Id: I8b182312f5a528d3394c2851ef18b62458b84a06 Reviewed-on: https://git.eclipse.org/r/7555 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.provider/src/org/eclipse/linuxtools/internal/profiling/provider/ProviderOptionsTab.java19
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java1
-rw-r--r--profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/ProviderLaunchConfigurationDelegate.java30
-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, 71 insertions, 41 deletions
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 3c6498c..b14e070 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
@@ -19,6 +19,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.linuxtools.internal.profiling.provider.launch.Messages;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTab;
import org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup;
import org.eclipse.swt.SWT;
@@ -40,7 +41,7 @@ public abstract class ProviderOptionsTab extends ProfileLaunchConfigurationTab {
HashMap<String, String> comboItems;
CTabFolder tabgroup;
Boolean initialized;
- private static final String PROVIDER_CONFIG_ATT = "provider"; //$NON-NLS-1$
+ public static final String PROVIDER_CONFIG_ATT = "provider"; //$NON-NLS-1$
public void createControl(Composite parent) {
top = new Composite(parent, SWT.NONE);
@@ -221,6 +222,22 @@ public abstract class ProviderOptionsTab extends ProfileLaunchConfigurationTab {
return getItemIndex(providerName);
}
+ @Override
+ public boolean isValid(ILaunchConfiguration config) {
+ String provider;
+ try {
+ provider = config.getAttribute(PROVIDER_CONFIG_ATT, "");
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ return false;
+ }
+ if (provider.equals("")) {
+ setErrorMessage(Messages.ProviderOptionsTab_0);
+ return false;
+ }
+ return true;
+ }
+
/**
* Get profiling type of this plug-in.
*
diff --git a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java
index b816846..5056e2d 100644
--- a/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java
+++ b/profiling/org.eclipse.linuxtools.profiling.provider/src/org/eclipse/linuxtools/internal/profiling/provider/launch/Messages.java
@@ -17,6 +17,7 @@ public class Messages extends NLS {
public static String ProviderLaunchShortcut_0;
public static String ProviderPreferencesPage_0;
public static String ProviderPreferencesPage_1;
+ public static String ProviderOptionsTab_0;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
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 166e044..46ebff8 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,13 +12,10 @@ 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.AbstractProviderPreferencesPage;
+import org.eclipse.linuxtools.internal.profiling.provider.ProviderOptionsTab;
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 {
@@ -31,9 +28,10 @@ public abstract class ProviderLaunchConfigurationDelegate extends
if (config != null) {
// get provider id from configuration.
String providerId = config.getAttribute(
- AbstractProviderPreferencesPage.PREFS_KEY, "");
+ ProviderOptionsTab.PROVIDER_CONFIG_ATT, "");
if (providerId.equals("")) {
- providerId = getProviderIdToRun();
+ // No provider available in the configuration.
+ return;
}
// get configuration delegate associated with provider id.
ProfileLaunchConfigurationDelegate delegate = getConfigurationDelegateFromId(providerId);
@@ -47,28 +45,8 @@ 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 42b6d8d..69eb8b6 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,16 +10,27 @@
*******************************************************************************/
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
- protected ILaunchConfigurationType getLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType(getLaunchConfigID());
+ 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());
+ }
}
@Override
@@ -30,10 +41,39 @@ 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 getLaunchConfigID();
+ protected abstract String getProfilingType();
+ @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 a64b428..fada366 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
@@ -1,4 +1,5 @@
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 ccbd144..4ac9291 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,9 +24,4 @@ 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 718b2be..d8f23cb 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,14 +15,12 @@ import org.eclipse.linuxtools.profiling.snapshot.SnapshotProviderPlugin;
/**
* The launch shortcut for this plug-in.
- *
+ *
*/
public class SnapshotLaunchShortcut extends ProviderLaunchShortcut {
@Override
- protected String getLaunchConfigID() {
- return SnapshotProviderPlugin.PLUGIN_CONFIG_ID;
+ protected String getProfilingType() {
+ return SnapshotProviderPlugin.PROFILING_TYPE;
}
-
-
}