KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > mapping > CommonMenuManager


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.mapping;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.commands.IHandler;
17 import org.eclipse.jface.action.MenuManager;
18
19 /**
20  * An extended menu manager that support handlers
21  */

22 public class CommonMenuManager extends MenuManager {
23
24     private Map JavaDoc handlers = new HashMap JavaDoc();
25     
26     public CommonMenuManager(String JavaDoc id) {
27         super(id);
28     }
29
30     /**
31      * Clear are the handlers registered with this manager.
32      *
33      */

34     public void clearHandlers() {
35         handlers.clear();
36     }
37
38     /**
39      * Register the handler with the given actionId. Only one
40      * handler can be registered for each action. If multiple
41      * are registered, none will be used.
42      * @param actionId the action id
43      * @param handler the handler
44      */

45     public void registerHandler(String JavaDoc actionId, IHandler handler) {
46         // TODO Handle conflicts
47
handlers.put(actionId, handler);
48     }
49
50     public IHandler getHandler(String JavaDoc actionId) {
51         return (IHandler)handlers.get(actionId);
52     }
53
54 }
55
Popular Tags