001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/editormodules/AbstractEditorModule.java,v 1.1 2005/04/20 22:20:29 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.editormodules;
019:
020: import javax.swing.JMenu;
021: import org.jdesktop.j3dedit.J3dEditContext;
022:
023: /**
024: *
025: * @author paulby
026: * @version 1.4 01/18/02
027: */
028: public abstract class AbstractEditorModule extends java.lang.Object {
029:
030: /** Creates new AbstractEditorModule */
031: public AbstractEditorModule() {
032: }
033:
034: /**
035: * Return the name of the module.
036: *
037: * The name will be used in the mode button for selecting this
038: * module
039: */
040: public abstract String getModuleName();
041:
042: /**
043: * Activate/Deactive this module.
044: *
045: * When a module is activated this method will create, display and
046: * arrange all the windows. It will also add the appropriate GUI
047: * listeners.
048: *
049: *
050: * When deactived the windows are hidden and possibly destroyed and all
051: * listeners (for menu events etc) are detached
052: */
053: public abstract void setActive(boolean active);
054:
055: /**
056: * Called when the module is added to the editor. The module should
057: * add any menu items it requires to the menus in the menu bar.
058: *
059: * Use getMenu below to locate the correct menu in which to add content
060: */
061: public void populateMenuBar(javax.swing.JMenuBar menuBar) {
062: }
063:
064: /**
065: * Make preperations to save a project
066: *
067: * The scenegraph will not be live when this method is called
068: */
069: public void prepareToSave() {
070: }
071:
072: /**
073: * Save operation is complete, return system to runtime state
074: */
075: public void saveComplete() {
076: }
077:
078: /**
079: * Return the named menu from the J3dFly main Menu bar. If the menu
080: * does not exist it will be created.
081: */
082: protected JMenu getMenu(J3dFlyEditorModule j3dFlyModule,
083: String menuName) {
084: JMenu ret = null;
085: J3dEditContext j3dflyContext = (J3dEditContext) j3dFlyModule
086: .getContext();
087:
088: int i = 0;
089: while (ret == null
090: && i < j3dflyContext.getMainMenuBar().getMenuCount()) {
091: if (j3dflyContext.getMainMenuBar().getMenu(i).getText()
092: .equals(menuName))
093: ret = j3dflyContext.getMainMenuBar().getMenu(i);
094: i++;
095: }
096:
097: if (ret == null) {
098: ret = new JMenu(menuName);
099: j3dflyContext.getMainMenuBar().add(ret);
100: }
101:
102: return ret;
103: }
104: }
|