001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/PluginTemplate.java,v 1.1 2005/04/20 21:04:42 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 Java 3D(tm) Fly Through.
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.j3dfly.plugins;
019:
020: import org.jdesktop.j3dfly.J3dFlyContext;
021:
022: /**
023: * This is a Template for a J3dFly Plugin.
024: *
025: * To make it easy to generate comlex menu's for a plugin this code
026: * 'tricks' Netbeans into thinking this is a GUI component and hence
027: * allows the Netbeans GUI editor to be used to edit the menu.
028: *
029: * @author Paul Byrne
030: * @version $Revision: 1.1 $
031: */
032: public class PluginTemplate extends J3dFlyPlugin {
033:
034: private java.lang.ref.SoftReference panelReference = null;
035:
036: /** Creates new form PluginTemplate */
037: public PluginTemplate() {
038: super ();
039: }
040:
041: /** This method is called from within the constructor to
042: * initialize the form.
043: * WARNING: Do NOT modify this code. The content of this method is
044: * always regenerated by the Form Editor.
045: */
046: private void initComponents() {//GEN-BEGIN:initComponents
047: menuBar = new javax.swing.JMenuBar();
048: pluginMenu = new javax.swing.JMenu();
049:
050: pluginMenu.setText("Menu");
051: menuBar.add(pluginMenu);
052:
053: }//GEN-END:initComponents
054:
055: /**
056: * Returns the control panel for this plugin, or null if there
057: * is no control panel
058: */
059: public javax.swing.JPanel getControlPanel() {
060:
061: // Uncomment this code and change XXXX to instantiate the panel for
062: // this Plugin if it has one, otherwise return null
063:
064: //if (panelReference==null || panelReference.get()==null )
065: // panelReference = new java.lang.ref.SoftReference( new XXXXX() );
066:
067: //return (javax.swing.JPanel)panelReference.get();
068:
069: return null;
070: }
071:
072: /**
073: * Install the plugin and add it's menu item to the menu
074: */
075: public void installPlugin(PluginPreference pluginPref,
076: J3dFlyContext j3dflyContext) {
077: super .installPlugin(pluginPref, j3dflyContext);
078: initComponents();
079:
080: menuBar.removeAll();
081: menuBar = null;
082:
083: // By default the menu item for this plugin will be added to
084: // the plugins Menu in the main menu bar for the application.
085: // You must set the super.menu object to point to the menu item
086: // you want displayed.
087:
088: // Set the menu item for this plugin to be another menu
089: //menu = pluginMenu;
090: if (pluginPref.isInstallInMenu())
091: getMenu("Plugins").add(menu);
092: }
093:
094: /**
095: * Uninstall this plugin
096: */
097: public void uninstallPlugin() {
098: super .uninstallPlugin();
099: if (pluginPref.isInstallInMenu())
100: getMenu("Plugins").remove(menu);
101: menu = null;
102: }
103:
104: /**
105: * Returns the class of the plugin preference.
106: *
107: * Plugins that require more preference information should provide a
108: * subclass of PluginPrefernece that contains all the extra preference
109: * data. This class must be Serializable.
110: */
111: public Class getPluginPreferenceClass() {
112: return PluginTemplatePreference.class;
113: }
114:
115: public static class PluginTemplatePreference extends
116: PluginPreference {
117: public PluginTemplatePreference() {
118: super ();
119: }
120:
121: public PluginTemplatePreference(boolean enabled,
122: boolean installed) {
123: super (enabled, installed);
124: }
125:
126: public J3dFlyPlugin instantiatePlugin() {
127: plugin = new PluginTemplate();
128: return plugin;
129: }
130:
131: /**
132: * Return a description of this plugin
133: */
134: public String getDescription() {
135: return "Plugin Description";
136: }
137:
138: /**
139: * Return the name of the Plugin for this prefernece.
140: * This is the name that will appear in the list of plugins
141: */
142: public String getName() {
143: return this .getClass().getName();
144: }
145:
146: }
147:
148: // Variables declaration - do not modify//GEN-BEGIN:variables
149: private javax.swing.JMenuBar menuBar;
150: private javax.swing.JMenu pluginMenu;
151: // End of variables declaration//GEN-END:variables
152:
153: }
|