| author | Camilo Bernal | 2012-07-24 15:24:08 (EDT) |
|---|---|---|
| committer | Roland Grunberg | 2012-07-25 12:19:31 (EDT) |
| commit | 1c58fc257958485ca1a67c587074069142c8bb17 (patch) (side-by-side diff) | |
| tree | 31229ed034c8aedbf8c9b23bd427a946885999ed | |
| parent | aef8d167854ad0a4843fb9bba4eca90065dd1ae4 (diff) | |
| download | org.eclipse.linuxtools-1c58fc257958485ca1a67c587074069142c8bb17.zip org.eclipse.linuxtools-1c58fc257958485ca1a67c587074069142c8bb17.tar.gz org.eclipse.linuxtools-1c58fc257958485ca1a67c587074069142c8bb17.tar.bz2 | |
Add name attribute to launch provider schema.
Launch provider has name attribute, this is done to avoid using id's in
the lauch provider combo.
Change-Id: I7885a7eae1d250e1eee1e6434ee3d6fa08a09d87
Reviewed-on: https://git.eclipse.org/r/6950
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
IP-Clean: Roland Grunberg <rgrunber@redhat.com>
Tested-by: Roland Grunberg <rgrunber@redhat.com>
3 files changed, 47 insertions, 3 deletions
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 e509892..811a522 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 @@ -101,6 +101,13 @@ Invalid values will be assigned the lowest priority to the extension. </appinfo> </annotation> </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + Name of launch provider. + </documentation> + </annotation> + </attribute> </complexType> </element> 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 bb6b07d..6ae830c 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 @@ -12,6 +12,7 @@ package org.eclipse.linuxtools.profiling.launch; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import org.eclipse.cdt.launch.ui.CArgumentsTab; import org.eclipse.cdt.launch.ui.CMainTab; @@ -148,4 +149,34 @@ public abstract class ProfileLaunchConfigurationTabGroup extends AbstractLaunchC return ret.toArray(new String [] {}); } + /** + * Get map of all pairs of names and IDs of the specific provider 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>HashMap<String, String></code> of all pairs of names and IDs + * of the specific type. + * @since 1.1 + */ + public static HashMap<String, String> getTabGroupNamesForType(String type) { + HashMap<String, String> ret = new HashMap<String, 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 currentName = config.getAttribute("name"); //$NON-NLS-1$ + String currentType = config.getAttribute("type"); //$NON-NLS-1$ + if (currentType != null && type != null + && currentType.equals(type) && currentName != null) { + ret.put(currentName, currentId); + } + } + } + return ret; + } }
\ No newline at end of file diff --git a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/SnapshotOptionsTab.java b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/SnapshotOptionsTab.java index b83bc14..980dadc 100644 --- a/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/SnapshotOptionsTab.java +++ b/profiling/org.eclipse.linuxtools.profiling.snapshot/src/org/eclipse/linuxtools/profiling/snapshot/SnapshotOptionsTab.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.linuxtools.profiling.snapshot; +import java.util.HashMap; +import java.util.Set; + import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -33,14 +36,17 @@ public class SnapshotOptionsTab extends ProfileLaunchConfigurationTab { AbstractLaunchConfigurationTab[] tabs; ILaunchConfiguration initial; String providerId = ""; + HashMap<String, String> comboItems; public void createControl(Composite parent) { top = new Composite(parent, SWT.NONE); setControl(top); top.setLayout(new GridLayout(1, true)); providerCombo = new Combo(top, SWT.READ_ONLY); - providerCombo.setItems(ProfileLaunchConfigurationTabGroup - .getTabGroupIdsForType("snapshot")); + comboItems = ProfileLaunchConfigurationTabGroup + .getTabGroupNamesForType("snapshot"); + Set<String> providerNames = comboItems.keySet(); + providerCombo.setItems(providerNames.toArray(new String[0])); final CTabFolder tabgroup = new CTabFolder(top, SWT.NONE); @@ -52,7 +58,7 @@ public class SnapshotOptionsTab extends ProfileLaunchConfigurationTab { item.dispose(); } - providerId = providerCombo.getText(); + providerId = comboItems.get(providerCombo.getText()); // get the tabs associated with the selected ID tabs = ProfileLaunchConfigurationTabGroup .getTabGroupProviderFromId(providerId) |

