01: /*******************************************************************************
02: * Copyright (c) 2000, 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Common Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/cpl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.openwfe.gpe.actions;
11:
12: import org.eclipse.jface.action.IAction;
13: import org.eclipse.jface.action.IMenuManager;
14: import org.eclipse.ui.IWorkbenchActionConstants;
15:
16: import org.eclipse.gef.ContextMenuProvider;
17: import org.eclipse.gef.EditPartViewer;
18: import org.eclipse.gef.ui.actions.ActionRegistry;
19: import org.eclipse.gef.ui.actions.GEFActionConstants;
20:
21: /**
22: * Provides a context menu for the flow editor.
23: * @author Daniel Lee
24: */
25: public class FlowContextMenuProvider extends ContextMenuProvider {
26:
27: /**
28: *
29: * @uml.property name="actionRegistry"
30: * @uml.associationEnd multiplicity="(1 1)"
31: */
32: private ActionRegistry actionRegistry;
33:
34: /**
35: * Creates a new FlowContextMenuProvider assoicated with the given viewer and
36: * action registry.
37: * @param viewer the viewer
38: * @param registry the action registry
39: */
40: public FlowContextMenuProvider(EditPartViewer viewer,
41: ActionRegistry registry) {
42: super (viewer);
43: setActionRegistry(registry);
44: }
45:
46: /**
47: * @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager)
48: */
49: public void buildContextMenu(IMenuManager menu) {
50: GEFActionConstants.addStandardActionGroups(menu);
51:
52: IAction action;
53: action = getActionRegistry().getAction(GEFActionConstants.UNDO);
54: menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
55:
56: action = getActionRegistry().getAction(GEFActionConstants.REDO);
57: menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
58:
59: action = getActionRegistry().getAction(
60: IWorkbenchActionConstants.DELETE);
61: if (action.isEnabled())
62: menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
63:
64: }
65:
66: /**
67: *
68: * @uml.property name="actionRegistry"
69: */
70: private ActionRegistry getActionRegistry() {
71: return actionRegistry;
72: }
73:
74: /**
75: * Sets the action registry
76: * @param registry the action registry
77: *
78: * @uml.property name="actionRegistry"
79: */
80: public void setActionRegistry(ActionRegistry registry) {
81: actionRegistry = registry;
82: }
83:
84: }
|