</extension>
<extension
point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="menu:org.eclipse.ui.navigator.ProjectExplorer">
- <command
- commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"
- id="org.eclipse.linuxtools.tmf.ui.menu.managecustomparsers"
- style="push">
- </command>
- </menuContribution>
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
name="org.eclipse.linuxtools.tmf.ui.separator3"
visible="true">
</separator>
+ <command
+ commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"
+ icon="icons/etool16/customparser_wizard.gif"
+ id="org.eclipse.linuxtools.tmf.ui.menu.managecustomparsers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
<menu
label="%command.select_trace_type"
mnemonic="%command.select_trace_type.mnemonic"
class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectTraceTypeContributionItem"
id="org.eclipse.linuxtools.tmf.ui.command.select_trace_type.dynamic">
</dynamic>
+ <separator
+ name="org.eclipse.linuxtools.tmf.ui.separator6"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers"
+ icon="icons/etool16/customparser_wizard.gif"
+ style="push">
+ </command>
<visibleWhen
checkEnabled="false">
<with
@Override
protected IContributionItem[] getContributionItems() {
+
+ Set<String> selectedTraceTypes = new HashSet<String>();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ ISelection selection = page.getSelection();
+ if (selection instanceof StructuredSelection) {
+ for (Object element : ((StructuredSelection) selection).toList()) {
+ if (element instanceof TmfTraceElement) {
+ TmfTraceElement trace = (TmfTraceElement) element;
+ selectedTraceTypes.add(trace.getTraceType());
+ }
+ }
+ }
+
List<IContributionItem> list = new LinkedList<IContributionItem>();
Map<String, MenuManager> categoriesMap = new HashMap<String, MenuManager>();
TmfTraceType.TMF_TRACE_TYPE_ID);
for (IConfigurationElement ce : config) {
if (ce.getName().equals(TmfTraceType.CATEGORY_ELEM)) {
- MenuManager subMenu = new MenuManager(ce.getAttribute(TmfTraceType.NAME_ATTR));
- categoriesMap.put(ce.getAttribute(TmfTraceType.ID_ATTR), subMenu);
+ String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR);
+ ImageDescriptor icon = isSelectedCategory(categoryId, config, selectedTraceTypes) ? SELECTED_ICON : null;
+ MenuManager subMenu = new MenuManager(ce.getAttribute(TmfTraceType.NAME_ATTR), icon, null);
+ categoriesMap.put(categoryId, subMenu);
list.add(subMenu);
}
}
- if (CustomTxtTraceDefinition.loadAll().length > 0) {
- MenuManager subMenu = new MenuManager(CUSTOM_TXT_CATEGORY);
+ CustomTxtTraceDefinition[] customTxtTraceDefinitions = CustomTxtTraceDefinition.loadAll();
+ if (customTxtTraceDefinitions.length > 0) {
+ ImageDescriptor icon = isSelectedCategory(customTxtTraceDefinitions, selectedTraceTypes) ? SELECTED_ICON : null;
+ MenuManager subMenu = new MenuManager(CUSTOM_TXT_CATEGORY, icon, null);
categoriesMap.put(CUSTOM_TXT_CATEGORY, subMenu);
list.add(subMenu);
}
- if (CustomXmlTraceDefinition.loadAll().length > 0) {
- MenuManager subMenu = new MenuManager(CUSTOM_XML_CATEGORY);
+ CustomXmlTraceDefinition[] customXmlTraceDefinitions = CustomXmlTraceDefinition.loadAll();
+ if (customXmlTraceDefinitions.length > 0) {
+ ImageDescriptor icon = isSelectedCategory(customXmlTraceDefinitions, selectedTraceTypes) ? SELECTED_ICON : null;
+ MenuManager subMenu = new MenuManager(CUSTOM_XML_CATEGORY, icon, null);
categoriesMap.put(CUSTOM_XML_CATEGORY, subMenu);
list.add(subMenu);
}
- Set<String> selectedTraceTypes = new HashSet<String>();
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- ISelection selection = page.getSelection();
- if (selection instanceof StructuredSelection) {
- for (Object element : ((StructuredSelection) selection).toList()) {
- if (element instanceof TmfTraceElement) {
- TmfTraceElement trace = (TmfTraceElement) element;
- selectedTraceTypes.add(trace.getTraceType());
- }
- }
- }
-
for (IConfigurationElement ce : config) {
if (ce.getName().equals(TmfTraceType.TYPE_ELEM)) {
String traceBundle = ce.getContributor().getName();
}
// add the custom trace types
- for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+ for (CustomTxtTraceDefinition def : customTxtTraceDefinitions) {
String traceBundle = Activator.getDefault().getBundle().getSymbolicName();
String traceTypeId = CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
String traceIcon = DEFAULT_TRACE_ICON_PATH;
addContributionItem(list, traceBundle, traceTypeId, traceIcon, label, selected, subMenu);
}
- for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+ for (CustomXmlTraceDefinition def : customXmlTraceDefinitions) {
String traceBundle = Activator.getDefault().getBundle().getSymbolicName();
String traceTypeId = CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
String traceIcon = DEFAULT_TRACE_ICON_PATH;
list.add(new CommandContributionItem(param));
}
}
+
+ private static boolean isSelectedCategory(String categoryId, IConfigurationElement[] config, Set<String> selectedTraceTypes) {
+ for (IConfigurationElement ce : config) {
+ if (ce.getName().equals(TmfTraceType.TYPE_ELEM)) {
+ String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR);
+ if (selectedTraceTypes.contains(traceTypeId)) {
+ if (categoryId.equals(ce.getAttribute(TmfTraceType.CATEGORY_ATTR))) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean isSelectedCategory(CustomTxtTraceDefinition[] customTxtTraceDefinitions, Set<String> selectedTraceTypes) {
+ for (CustomTxtTraceDefinition def : customTxtTraceDefinitions) {
+ String traceTypeId = CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
+ if (selectedTraceTypes.contains(traceTypeId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isSelectedCategory(CustomXmlTraceDefinition[] customXmlTraceDefinitions, Set<String> selectedTraceTypes) {
+ for (CustomXmlTraceDefinition def : customXmlTraceDefinitions) {
+ String traceTypeId = CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
+ if (selectedTraceTypes.contains(traceTypeId)) {
+ return true;
+ }
+ }
+ return false;
+ }
}