Source Code Cross Referenced for J3dFlyPlugin.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dfly » plugins » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » org.jdesktop.j3dfly.plugins 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/plugins/J3dFlyPlugin.java,v 1.1 2005/04/20 21:04:40 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 javax.media.j3d.BranchGroup;
021:        import org.jdesktop.j3dfly.J3dFlyContext;
022:        import javax.swing.JDialog;
023:        import javax.swing.JPanel;
024:        import javax.swing.JButton;
025:        import javax.swing.JMenu;
026:        import javax.swing.JTabbedPane;
027:
028:        /**
029:         * The interface for all J3dFly PlugIn's
030:         *
031:         * @author  Paul Byrne
032:         * @version $Revision: 1.1 $
033:         */
034:        public abstract class J3dFlyPlugin {
035:
036:            protected J3dFlyContext j3dflyContext;
037:            /**
038:             * The tool wide preferences for this plugin
039:             */
040:            protected PluginPreference pluginPref;
041:
042:            protected javax.swing.JMenuItem menu = null;
043:
044:            /**
045:             * TODO remove this debug support once we've implemented uninstall
046:             * in all the plugins
047:             */
048:            //protected boolean uninstallDone = false;
049:            /**
050:             * Create a new instance of the plugin.
051:             *
052:             * Once the Plugin is create it must be installed by calling
053:             * installPlugin
054:             */
055:            public J3dFlyPlugin() {
056:            }
057:
058:            /**
059:             * Install the plugin into j3dfly with the supplied preferences
060:             *
061:             * Access this functionality through the preference object for this 
062:             * plugin
063:             */
064:            public void installPlugin(PluginPreference pluginPref,
065:                    J3dFlyContext j3dflyContext) {
066:                this .pluginPref = pluginPref;
067:                this .j3dflyContext = j3dflyContext;
068:                j3dflyContext.getPluginPreferenceControl().addInstalledPlugin(
069:                        this );
070:            }
071:
072:            /**
073:             * Uninstall the plugin
074:             *
075:             * Access this functionality through the preference object for this 
076:             * plugin
077:             */
078:            public void uninstallPlugin() {
079:                //if (!uninstallDone)
080:                //    System.out.println("TODO IMplenent uninstallPlugin for "+this.getClass().getName() );
081:                j3dflyContext.getPluginPreferenceControl()
082:                        .removeInstalledPlugin(this );
083:            }
084:
085:            /** 
086:             * Returns the class of the plugin preference used for the Tool wide
087:             * preferences.
088:             *
089:             * Plugins that require more preference information should provide a
090:             * subclass of PluginPrefernece that contains all the extra preference
091:             * data. This class must be Serializable.
092:             */
093:            public abstract Class getPluginPreferenceClass();
094:
095:            /** 
096:             * Return the preference object for this plugin
097:             */
098:            public PluginPreference getPluginPreference() {
099:                return pluginPref;
100:            }
101:
102:            public void setPluginPreference(PluginPreference pluginPref) {
103:                this .pluginPref = pluginPref;
104:            }
105:
106:            /**
107:             * Enable/disable the plugin
108:             *
109:             * Access this functionality through the preference object for this 
110:             * plugin
111:             */
112:            protected void setEnabled(boolean enable) {
113:                if (menu != null)
114:                    menu.setEnabled(enable);
115:            }
116:
117:            /**
118:             * Return true if the plugin is enabled
119:             *
120:             * Access this functionality through the preference object for this 
121:             * plugin
122:             */
123:            protected boolean isEnabled() {
124:                return pluginPref.isEnabled();
125:            }
126:
127:            /**
128:             * Returns the control panel for this plugin, or null if there
129:             * is no control panel
130:             */
131:            public abstract javax.swing.JPanel getControlPanel();
132:
133:            /**
134:             * Show the controls for this plugin in a non-modal dialog
135:             */
136:            protected void showControls() {
137:                /*
138:                if (getControlPanel().getParent()!=null) {
139:                    if (getControlPanel().getParent() instanceof JTabbedPane ) {
140:                        ((JTabbedPane)getControlPanel().getParent()).setSelectedComponent( getControlPanel() );                
141:                    } else
142:                        throw new RuntimeException("Panel already has a parent");
143:                } else {       
144:                 */
145:                java.awt.Container parent = j3dflyContext.getJ3dFly()
146:                        .getContainer();
147:
148:                if (!(parent instanceof  java.awt.Frame))
149:                    parent = null;
150:
151:                final JDialog dialog = new JDialog(j3dflyContext.getJ3dFly()
152:                        .getDialogParent(), pluginPref.getName(), false);
153:                final JPanel p = new JPanel();
154:                dialog.setLocationRelativeTo(j3dflyContext.getJ3dFly()
155:                        .getContainer());
156:                JPanel p2 = new JPanel();
157:                JButton okButton = new JButton("OK");
158:                p2.add(okButton);
159:                okButton.addActionListener(new java.awt.event.ActionListener() {
160:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
161:                        dialog.setVisible(false);
162:                        p.remove(getControlPanel());
163:                        dialog.dispose();
164:                    }
165:                });
166:                p.setLayout(new java.awt.BorderLayout());
167:
168:                p.add(getControlPanel(), java.awt.BorderLayout.CENTER);
169:
170:                p.add(p2, java.awt.BorderLayout.SOUTH);
171:                dialog.getContentPane().add(p);
172:                dialog.pack();
173:                dialog.setVisible(true);
174:            }
175:
176:            /**
177:             * Return the named menu from the J3dFly main Menu bar. If the menu
178:             * does not exist it will be created.
179:             *
180:             * Using this mechanism Plugin's can add menu items to existing Menus
181:             * in the MenuBar. See <TODO> for a list of default menu names
182:             */
183:            protected JMenu getMenu(String menuName) {
184:                JMenu ret = null;
185:
186:                int i = 0;
187:                while (ret == null
188:                        && i < j3dflyContext.getMainMenuBar().getMenuCount()) {
189:                    if (j3dflyContext.getMainMenuBar().getMenu(i).getText()
190:                            .equals(menuName))
191:                        ret = j3dflyContext.getMainMenuBar().getMenu(i);
192:                    i++;
193:                }
194:
195:                if (ret == null) {
196:                    ret = new JMenu(menuName);
197:                    j3dflyContext.getMainMenuBar().add(ret);
198:                }
199:
200:                return ret;
201:            }
202:
203:            /**
204:             * Returns the J3dFlyContext in which this plugin is installed
205:             */
206:            public J3dFlyContext getJ3dFlyContext() {
207:                return j3dflyContext;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.