001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.window.menus;
020:
021: import java.awt.Font;
022: import java.util.ArrayList;
023: import java.util.Iterator;
024:
025: import javax.swing.JMenu;
026: import javax.swing.JMenuBar;
027:
028: import org.openharmonise.him.actions.*;
029: import org.openharmonise.him.actions.file.*;
030: import org.openharmonise.him.actions.help.*;
031: import org.openharmonise.him.actions.publish.*;
032: import org.openharmonise.him.actions.system.*;
033: import org.openharmonise.vfs.context.*;
034:
035: import org.openharmonise.him.actions.system.ActionExportContent;
036:
037: /**
038: * Main menu bar for the application.
039: *
040: * @author Matthew Large
041: * @version $Revision: 1.3 $
042: *
043: */
044: public class MenuBar extends JMenuBar implements ContextListener {
045:
046: /**
047: * List of {@link HIMAction} objects.
048: */
049: private ArrayList m_aActions = new ArrayList();
050:
051: /**
052: * Constructs a new menu bar.
053: */
054: public MenuBar() {
055: super ();
056: this .setup();
057: }
058:
059: /**
060: * Initialises this component.
061: *
062: */
063: private void setup() {
064: this .add(this .getSystemMenu());
065: this .add(this .getFileMenu());
066: this .add(this .getPublishMenu());
067: this .add(this .getCMHelpMenu());
068:
069: ContextHandler.getInstance().addListener(
070: ContextType.CONTEXT_FILES, this );
071: ContextHandler.getInstance().addListener(
072: ContextType.CONTEXT_DIRS, this );
073: ContextHandler.getInstance().addListener(
074: ContextType.CONTEXT_TABS, this );
075: }
076:
077: /**
078: * Gets the System menu.
079: *
080: * @return System menu.
081: */
082: private JMenu getSystemMenu() {
083: JMenu menu = new JMenu("System");
084: menu.setMnemonic('S');
085:
086: String fontName = "Dialog";
087: int fontSize = 11;
088: Font font = new Font(fontName, Font.PLAIN, fontSize);
089: menu.setFont(font);
090:
091: HIMAction action = new ActionSystemSettings();
092: this .m_aActions.add(action);
093: menu.add(action.getMenuItem());
094:
095: action = new ActionPreviewSettings();
096: this .m_aActions.add(action);
097: menu.add(action.getMenuItem());
098:
099: action = new ActionCustomise();
100: this .m_aActions.add(action);
101: menu.add(action.getMenuItem());
102:
103: action = new ActionChangeMyPassword();
104: this .m_aActions.add(action);
105: menu.add(action.getMenuItem());
106:
107: menu.addSeparator();
108:
109: action = new ActionRefresh();
110: this .m_aActions.add(action);
111: menu.add(action.getMenuItem());
112:
113: action = new ActionSyncWithServer();
114: this .m_aActions.add(action);
115: menu.add(action.getMenuItem());
116:
117: action = new ActionExportContent();
118: this .m_aActions.add(action);
119: menu.add(action.getMenuItem());
120:
121: menu.addSeparator();
122:
123: action = new ActionExitReject();
124: this .m_aActions.add(action);
125: menu.add(action.getMenuItem());
126:
127: action = new ActionExitCommit();
128: this .m_aActions.add(action);
129: menu.add(action.getMenuItem());
130:
131: return menu;
132: }
133:
134: /**
135: * Gets the File menu.
136: *
137: * @return File menu.
138: */
139: private JMenu getFileMenu() {
140: JMenu menu = new JMenu("Resource");
141: menu.setMnemonic('R');
142:
143: String fontName = "Dialog";
144: int fontSize = 11;
145: Font font = new Font(fontName, Font.PLAIN, fontSize);
146: menu.setFont(font);
147:
148: HIMAction action = new ActionNewFile();
149: this .m_aActions.add(action);
150: menu.add(action.getMenuItem());
151:
152: action = new ActionUpload();
153: this .m_aActions.add(action);
154: menu.add(action.getMenuItem());
155:
156: action = new ActionNewCollection();
157: this .m_aActions.add(action);
158: menu.add(action.getMenuItem());
159:
160: menu.addSeparator();
161:
162: action = new ActionOpen();
163: this .m_aActions.add(action);
164: menu.add(action.getMenuItem());
165:
166: //commenting out as renaming a resource changes the path
167: //which then can mess up property domain references
168: //will be fixed in later releases
169:
170: // action = new ActionRename();
171: // this.m_aActions.add(action);
172: // menu.add(action.getMenuItem());
173:
174: action = new ActionCreateCopy();
175: this .m_aActions.add(action);
176: menu.add(action.getMenuItem());
177:
178: menu.addSeparator();
179:
180: action = new ActionSynchronise();
181: this .m_aActions.add(action);
182: menu.add(action.getMenuItem());
183:
184: action = new ActionLock();
185: this .m_aActions.add(action);
186: menu.add(action.getMenuItem());
187:
188: action = new ActionUnlock();
189: this .m_aActions.add(action);
190: menu.add(action.getMenuItem());
191:
192: return menu;
193: }
194:
195: /**
196: * Gets the Publish menu.
197: *
198: * @return Publish menu.
199: */
200: private JMenu getPublishMenu() {
201: JMenu menu = new JMenu("Publish");
202: menu.setMnemonic('P');
203:
204: String fontName = "Dialog";
205: int fontSize = 11;
206: Font font = new Font(fontName, Font.PLAIN, fontSize);
207: menu.setFont(font);
208:
209: HIMAction action = new ActionPreview();
210: this .m_aActions.add(action);
211: menu.add(action.getMenuItem());
212:
213: action = new ActionPublishToInternet();
214: this .m_aActions.add(action);
215: menu.add(action.getMenuItem());
216:
217: action = new ActionExport();
218: this .m_aActions.add(action);
219: menu.add(action.getMenuItem());
220:
221: menu.addSeparator();
222:
223: action = new ActionArchive();
224: this .m_aActions.add(action);
225: menu.add(action.getMenuItem());
226:
227: action = new ActionRetrieve();
228: this .m_aActions.add(action);
229: menu.add(action.getMenuItem());
230:
231: return menu;
232: }
233:
234: /**
235: * Gets the Help menu.
236: *
237: * @return Help menu.
238: */
239: private JMenu getCMHelpMenu() {
240: JMenu menu = new JMenu("Help");
241: menu.setMnemonic('H');
242:
243: String fontName = "Dialog";
244: int fontSize = 11;
245: Font font = new Font(fontName, Font.PLAIN, fontSize);
246: menu.setFont(font);
247:
248: HIMAction action = new ActionHelp();
249: this .m_aActions.add(action);
250: menu.add(action.getMenuItem());
251:
252: action = new ActionKeyboardShortcuts();
253: this .m_aActions.add(action);
254: menu.add(action.getMenuItem());
255:
256: action = new ActionAbout();
257: this .m_aActions.add(action);
258: menu.add(action.getMenuItem());
259:
260: return menu;
261: }
262:
263: /* (non-Javadoc)
264: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
265: */
266: public void contextMessage(ContextEvent ce) {
267: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_DIRS) {
268: Iterator itor = this .m_aActions.iterator();
269: while (itor.hasNext()) {
270: HIMAction action = (HIMAction) itor.next();
271: action.isEnabled(ce);
272: }
273: } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILES) {
274: Iterator itor = this .m_aActions.iterator();
275: while (itor.hasNext()) {
276: HIMAction action = (HIMAction) itor.next();
277: action.isEnabled(ce);
278: }
279: } else if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS) {
280: Iterator itor = this .m_aActions.iterator();
281: while (itor.hasNext()) {
282: HIMAction action = (HIMAction) itor.next();
283: action.isEnabled(ce);
284: }
285: }
286: }
287:
288: }
|