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.draw2d.PositionConstants;
20: import org.eclipse.gef.ui.actions.ActionBarContributor;
21: import org.eclipse.gef.ui.actions.AlignmentRetargetAction;
22: import org.eclipse.gef.ui.actions.DeleteRetargetAction;
23: import org.eclipse.gef.ui.actions.GEFActionConstants;
24: import org.eclipse.gef.ui.actions.RedoRetargetAction;
25: import org.eclipse.gef.ui.actions.UndoRetargetAction;
26: import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
27: import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
28: import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
29: import org.eclipse.jface.action.IToolBarManager;
30: import org.eclipse.jface.action.Separator;
31: import org.eclipse.ui.actions.ActionFactory;
32: import org.eclipse.ui.actions.RetargetAction;
33:
34: /**
35: * Common implementation of a ActionBarContributor.
36: *
37: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
38: */
39: public class GenericActionBarContributor extends ActionBarContributor {
40:
41: protected void buildActions() {
42: addRetargetAction(new UndoRetargetAction());
43: addRetargetAction(new RedoRetargetAction());
44: addRetargetAction(new DeleteRetargetAction());
45:
46: addRetargetAction(new ZoomInRetargetAction());
47: addRetargetAction(new ZoomOutRetargetAction());
48:
49: addRetargetAction(new AlignmentRetargetAction(
50: PositionConstants.LEFT));
51: addRetargetAction(new AlignmentRetargetAction(
52: PositionConstants.CENTER));
53: addRetargetAction(new AlignmentRetargetAction(
54: PositionConstants.RIGHT));
55: addRetargetAction(new AlignmentRetargetAction(
56: PositionConstants.TOP));
57: addRetargetAction(new AlignmentRetargetAction(
58: PositionConstants.MIDDLE));
59: addRetargetAction(new AlignmentRetargetAction(
60: PositionConstants.BOTTOM));
61:
62: addRetargetAction(new RetargetAction(
63: GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid"));
64: }
65:
66: public void contributeToToolBar(IToolBarManager toolBarManager) {
67: toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
68: toolBarManager.add(getAction(ActionFactory.REDO.getId()));
69: toolBarManager.add(new Separator());
70: toolBarManager.add(new ZoomComboContributionItem(getPage()));
71: toolBarManager.add(new Separator());
72:
73: DropDownMenuWithDefaultAction alignMenu = new DropDownMenuWithDefaultAction(
74: getActionRegistry().getAction(
75: GEFActionConstants.ALIGN_LEFT));
76: alignMenu.add(getActionRegistry().getAction(
77: GEFActionConstants.ALIGN_LEFT));
78: alignMenu.add(getActionRegistry().getAction(
79: GEFActionConstants.ALIGN_CENTER));
80: alignMenu.add(getActionRegistry().getAction(
81: GEFActionConstants.ALIGN_RIGHT));
82: alignMenu.add(new Separator());
83: alignMenu.add(getActionRegistry().getAction(
84: GEFActionConstants.ALIGN_TOP));
85: alignMenu.add(getActionRegistry().getAction(
86: GEFActionConstants.ALIGN_MIDDLE));
87: alignMenu.add(getActionRegistry().getAction(
88: GEFActionConstants.ALIGN_BOTTOM));
89: toolBarManager.add(alignMenu);
90:
91: toolBarManager.add(new Separator());
92: toolBarManager
93: .add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));
94: }
95:
96: protected void declareGlobalActionKeys() {
97: }
98: }
|