001: /*--
002:
003: Copyright (C) 2002 Anthony Eden.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: me@anthonyeden.com.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Anthony Eden (me@anthonyeden.com).
027:
028: In addition, I request (but do not require) that you include in the
029: end-user documentation provided with the redistribution and/or in the
030: software itself an acknowledgement equivalent to the following:
031: "This product includes software developed by
032: Anthony Eden (http://www.anthonyeden.com/)."
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
038: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
039: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
040: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
041: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
042: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
043: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
044: POSSIBILITY OF SUCH DAMAGE.
045:
046: For more information on OBE, please see <http://obe.sourceforge.net/>.
047:
048: */
049:
050: package org.obe.designer;
051:
052: import java.awt.Event;
053: import java.awt.event.KeyEvent;
054: import java.util.Map;
055:
056: import javax.swing.JMenu;
057: import javax.swing.JMenuBar;
058: import javax.swing.JMenuItem;
059: import javax.swing.Action;
060: import javax.swing.KeyStroke;
061:
062: import org.obe.designer.menu.ModeMenu;
063: import org.obe.designer.menu.ZoomMenu;
064:
065: public class OBEDesignerMenuBar extends JMenuBar {
066:
067: private OBEDesigner parent;
068:
069: private JMenu fileMenu;
070: private JMenu editMenu;
071: private JMenu workflowMenu;
072: private JMenu helpMenu;
073:
074: private JMenu zoomMenu;
075: private JMenu modeMenu;
076:
077: private JMenuItem newMenuItem;
078: private JMenuItem openMenuItem;
079: private JMenuItem closeMenuItem;
080: private JMenuItem revertMenuItem;
081: private JMenuItem propertiesMenuItem;
082: private JMenuItem saveMenuItem;
083: private JMenuItem saveAsMenuItem;
084: private JMenuItem quitMenuItem;
085: private JMenuItem cutMenuItem;
086: private JMenuItem copyMenuItem;
087: private JMenuItem pasteMenuItem;
088: private JMenuItem selectAllMenuItem;
089: private JMenuItem selectNoneMenuItem;
090: private JMenuItem preferencesMenuItem;
091: private JMenuItem addWorkflowMenuItem;
092: private JMenuItem editWorkflowMenuItem;
093: private JMenuItem removeWorkflowMenuItem;
094: private JMenuItem cleanUpWorkflowMenuItem;
095:
096: public OBEDesignerMenuBar(OBEDesigner parent) {
097: this .parent = parent;
098: init();
099: }
100:
101: public void loadResources() {
102: fileMenu.setText("File");
103: fileMenu.setMnemonic('f');
104:
105: newMenuItem.setText("New");
106: newMenuItem.setMnemonic('n');
107: newMenuItem.setAccelerator(KeyStroke.getKeyStroke(
108: KeyEvent.VK_N, Event.CTRL_MASK));
109:
110: openMenuItem.setText("Open");
111: openMenuItem.setMnemonic('o');
112: openMenuItem.setAccelerator(KeyStroke.getKeyStroke(
113: KeyEvent.VK_O, Event.CTRL_MASK));
114:
115: closeMenuItem.setText("Close");
116: closeMenuItem.setAccelerator(KeyStroke.getKeyStroke(
117: KeyEvent.VK_W, Event.CTRL_MASK));
118:
119: revertMenuItem.setText("Revert");
120:
121: propertiesMenuItem.setText("Package Properties");
122:
123: saveMenuItem.setText("Save");
124: saveMenuItem.setMnemonic('s');
125: saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(
126: KeyEvent.VK_S, Event.CTRL_MASK));
127:
128: saveAsMenuItem.setText("Save As...");
129: saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(
130: KeyEvent.VK_S, Event.CTRL_MASK + Event.SHIFT_MASK));
131:
132: quitMenuItem.setText("Quit");
133: quitMenuItem.setMnemonic('q');
134: quitMenuItem.setAccelerator(KeyStroke.getKeyStroke(
135: KeyEvent.VK_Q, Event.CTRL_MASK));
136:
137: editMenu.setText("Edit");
138: editMenu.setMnemonic('e');
139:
140: cutMenuItem.setText("Cut");
141: cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(
142: KeyEvent.VK_X, Event.CTRL_MASK));
143:
144: copyMenuItem.setText("Copy");
145: copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(
146: KeyEvent.VK_C, Event.CTRL_MASK));
147:
148: pasteMenuItem.setText("Paste");
149: pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(
150: KeyEvent.VK_V, Event.CTRL_MASK));
151:
152: selectAllMenuItem.setText("Select All");
153: selectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(
154: KeyEvent.VK_A, Event.CTRL_MASK));
155:
156: selectNoneMenuItem.setText("Select None");
157: selectNoneMenuItem.setAccelerator(KeyStroke.getKeyStroke(
158: KeyEvent.VK_A, Event.CTRL_MASK + Event.SHIFT_MASK));
159:
160: zoomMenu.setText("Zoom");
161:
162: modeMenu.setText("Mode");
163:
164: workflowMenu.setText("Workflow");
165:
166: preferencesMenuItem.setText("Preferences...");
167:
168: addWorkflowMenuItem.setText("Add Process...");
169: addWorkflowMenuItem.setAccelerator(KeyStroke.getKeyStroke(
170: KeyEvent.VK_N, Event.CTRL_MASK + Event.SHIFT_MASK));
171:
172: editWorkflowMenuItem.setText("Edit Process...");
173:
174: removeWorkflowMenuItem.setText("Remove Process");
175:
176: cleanUpWorkflowMenuItem.setText("Clean Up");
177: }
178:
179: private void init() {
180: zoomMenu = new ZoomMenu(parent);
181: modeMenu = new ModeMenu(parent);
182:
183: Map actions = parent.getActions();
184:
185: fileMenu = new JMenu();
186: newMenuItem = fileMenu.add((Action) actions.get("file.new"));
187: openMenuItem = fileMenu.add((Action) actions.get("file.open"));
188: closeMenuItem = fileMenu
189: .add((Action) actions.get("file.close"));
190: fileMenu.addSeparator();
191: revertMenuItem = fileMenu.add((Action) actions
192: .get("file.revert"));
193: fileMenu.addSeparator();
194: propertiesMenuItem = fileMenu.add((Action) actions
195: .get("file.properties"));
196: fileMenu.addSeparator();
197: saveMenuItem = fileMenu.add((Action) actions.get("file.save"));
198: saveAsMenuItem = fileMenu.add((Action) actions
199: .get("file.saveAs"));
200: fileMenu.addSeparator();
201: quitMenuItem = fileMenu.add((Action) actions.get("file.quit"));
202: add(fileMenu);
203:
204: editMenu = new JMenu();
205: cutMenuItem = editMenu.add((Action) actions.get("edit.cut"));
206: copyMenuItem = editMenu.add((Action) actions.get("edit.copy"));
207: pasteMenuItem = editMenu
208: .add((Action) actions.get("edit.paste"));
209: editMenu.addSeparator();
210: selectAllMenuItem = editMenu.add((Action) actions
211: .get("edit.selectAll"));
212: selectNoneMenuItem = editMenu.add((Action) actions
213: .get("edit.selectNone"));
214: editMenu.addSeparator();
215: editMenu.add(zoomMenu);
216: editMenu.addSeparator();
217: editMenu.add(modeMenu);
218: editMenu.addSeparator();
219: preferencesMenuItem = editMenu.add((Action) actions
220: .get("edit.preferences"));
221: add(editMenu);
222:
223: workflowMenu = new JMenu();
224: addWorkflowMenuItem = workflowMenu.add((Action) actions
225: .get("workflow.add"));
226: editWorkflowMenuItem = workflowMenu.add((Action) actions
227: .get("workflow.edit"));
228: removeWorkflowMenuItem = workflowMenu.add((Action) actions
229: .get("workflow.remove"));
230: workflowMenu.addSeparator();
231: cleanUpWorkflowMenuItem = workflowMenu.add((Action) actions
232: .get("workflow.cleanup"));
233: add(workflowMenu);
234:
235: loadResources();
236: }
237:
238: }
|