1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.handlers
;
15 import java
.util
.HashMap
;
16 import java
.util
.LinkedList
;
18 import java
.util
.Map
.Entry
;
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
;
29 public class SelectParserContributionItem
extends CompoundContributionItem
{
32 protected IContributionItem
[] getContributionItems() {
33 Map
<String
, String
> params
;
34 LinkedList
<IContributionItem
> list
= new LinkedList
<IContributionItem
>();
36 ParserProviderManager
.getParserMap();
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$
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$
49 null, // disabled icon
51 entry
.getKey().replaceAll("&", "&&"), // label //$NON-NLS-1$//$NON-NLS-2$
54 CommandContributionItem
.STYLE_PUSH
,
55 null, // help context id
59 subMenu
.add(new CommandContributionItem(param
));
64 return (IContributionItem
[]) list
.toArray(new IContributionItem
[list
.size()]);