01: package org.drools.eclipse.flow.common.editor;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.eclipse.gef.ContextMenuProvider;
20: import org.eclipse.gef.GraphicalViewer;
21: import org.eclipse.gef.ui.actions.ActionRegistry;
22: import org.eclipse.gef.ui.actions.GEFActionConstants;
23: import org.eclipse.jface.action.IAction;
24: import org.eclipse.jface.action.IMenuManager;
25: import org.eclipse.ui.actions.ActionFactory;
26:
27: /**
28: * Common implementation of a ContextMenuProvider.
29: *
30: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
31: */
32: public class GenericContextMenuProvider extends ContextMenuProvider {
33:
34: private ActionRegistry actionRegistry;
35:
36: public GenericContextMenuProvider(GraphicalViewer viewer,
37: ActionRegistry registry) {
38: super (viewer);
39: setActionRegistry(registry);
40: }
41:
42: public void buildContextMenu(IMenuManager menu) {
43: GEFActionConstants.addStandardActionGroups(menu);
44:
45: IAction action = getActionRegistry().getAction(
46: ActionFactory.UNDO.getId());
47: menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
48:
49: action = getActionRegistry().getAction(
50: ActionFactory.REDO.getId());
51: menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
52:
53: action = getActionRegistry().getAction(
54: ActionFactory.DELETE.getId());
55: if (action.isEnabled()) {
56: menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
57: }
58: }
59:
60: private ActionRegistry getActionRegistry() {
61: return actionRegistry;
62: }
63:
64: public void setActionRegistry(ActionRegistry registry) {
65: actionRegistry = registry;
66: }
67:
68: }
|