2010-11-09 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug315307
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / project / handlers / SelectParserContributionItem.java
1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.project.handlers;
14
15 import java.util.HashMap;
16 import java.util.LinkedList;
17 import java.util.Map;
18 import java.util.Map.Entry;
19
20 import org.eclipse.jface.action.IContributionItem;
21 import org.eclipse.jface.action.MenuManager;
22 import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager;
23 import org.eclipse.ui.PlatformUI;
24 import org.eclipse.ui.actions.CompoundContributionItem;
25 import org.eclipse.ui.menus.CommandContributionItem;
26 import org.eclipse.ui.menus.CommandContributionItemParameter;
27
28
29 public class SelectParserContributionItem extends CompoundContributionItem {
30
31 @Override
32 protected IContributionItem[] getContributionItems() {
33 Map<String, String> params;
34 LinkedList<IContributionItem> list = new LinkedList<IContributionItem>();
35
36 ParserProviderManager.getParserMap();
37
38 for(Entry<String, Map<String, String>> providerEntry : ParserProviderManager.getParserMap().entrySet()) {
39 MenuManager subMenu = new MenuManager(providerEntry.getKey());
40 for(Entry<String, String> entry : providerEntry.getValue().entrySet()) {
41 params = new HashMap<String, String>();
42 params.put("org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.selectparser.parser", entry.getValue()); //$NON-NLS-1$
43
44 CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
45 "my.parameterid", //$NON-NLS-1$
46 "org.eclipse.linuxtools.tmf.ui.command.project.trace.selectparser", //$NON-NLS-1$
47 params,
48 null, // icon
49 null, // disabled icon
50 null, // hover icon
51 entry.getKey().replaceAll("&", "&&"), // label //$NON-NLS-1$//$NON-NLS-2$
52 null, // mnemonic
53 null, // tooltip
54 CommandContributionItem.STYLE_PUSH,
55 null, // help context id
56 true // visibleEnable
57 );
58
59 subMenu.add(new CommandContributionItem(param));
60 }
61 list.add(subMenu);
62 }
63
64 return (IContributionItem[]) list.toArray(new IContributionItem[list.size()]);
65 }
66
67 }
This page took 0.031946 seconds and 5 git commands to generate.