Source Code Cross Referenced for MBeanIterator.java in  » IDE-Netbeans » jmx » org » netbeans » modules » jmx » mbeanwizard » 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 » IDE Netbeans » jmx » org.netbeans.modules.jmx.mbeanwizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Code is Sun Microsystems, Inc. Portions Copyright 2004-2005 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.jmx.mbeanwizard;
042:
043:        import java.awt.Component;
044:        import java.util.Collections;
045:        import java.util.HashSet;
046:        import java.util.Iterator;
047:        import java.util.Set;
048:        import java.util.ResourceBundle;
049:        import javax.swing.JComponent;
050:        import javax.swing.event.ChangeEvent;
051:        import javax.swing.event.ChangeListener;
052:        import org.netbeans.api.java.source.JavaSource;
053:        import org.netbeans.api.project.SourceGroup;
054:        import org.netbeans.api.project.Project;
055:        import org.netbeans.spi.project.ui.templates.support.Templates;
056:        import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates;
057:        import org.openide.loaders.TemplateWizard;
058:        import org.openide.WizardDescriptor;
059:        import org.openide.util.NbBundle;
060:        import org.netbeans.modules.jmx.WizardConstants;
061:        import org.netbeans.modules.jmx.WizardHelpers;
062:        import org.netbeans.modules.jmx.FinishableDelegatedWizardPanel;
063:        import org.netbeans.modules.jmx.WizardPanelWithoutReadSettings;
064:        import org.netbeans.modules.jmx.mbeanwizard.generator.GeneratorControler;
065:
066:        /**
067:         *
068:         * Main Wizard class for MXBean and Standard MBean
069:         *
070:         */
071:        public abstract class MBeanIterator implements  TemplateWizard.Iterator {
072:            private static final long serialVersionUID = 1L;
073:
074:            /** private variables */
075:            private transient TemplateWizard wiz;
076:
077:            private transient MBeanPanel.MBeanPanelWizardPanel mbeanTemplatePanel;
078:            private transient FinishableDelegatedWizardPanel mbeanPanel;
079:            private transient WizardDescriptor.Panel currentPanel;
080:            private String[] steps;
081:            private transient ResourceBundle bundle;
082:            private Project lastSelectedProject = null;
083:
084:            //****************************************************************
085:            // Called with the menu new->file->Standard MBean
086:            //****************************************************************
087:
088:            //****************************************************************
089:            // default constructor :
090:            //*************************************JMXMBeanIterator_1***********
091:            /**
092:             * The default constructor
093:             */
094:            protected MBeanIterator() {
095:                bundle = NbBundle.getBundle(MBeanIterator.class);
096:            }
097:
098:            //*********************************************************************
099:            // Called to really start the wizard in
100:            // case of a direct call from the menu
101:            //*********************************************************************
102:
103:            /**
104:             * Initializing method, called to really start the wizard
105:             * @param wiz a TemplateWizard
106:             */
107:            public void initialize(TemplateWizard wiz) {
108:                // kludge to work around a netbeans bug :
109:
110:                // create step description array
111:                //String[] steps = initializeSteps(wiz);
112:
113:                this .wiz = wiz;
114:
115:                steps = new String[2];
116:                steps[0] = new String("Choose File Type"); // NOI18N // should be added by netbeans
117:                steps[1] = bundle.getString("LBL_Standard_Panel");// NOI18N
118:
119:                // end of work around
120:
121:                // Don't set the generated project as the new Netbeans "main project" !!
122:                //
123:                // cf ../projects/projectui/src/org/netbeans/modules/project/ui/actions/NewProject.java
124:                //
125:                //wiz.putProperty("setAsMain", false); // NOI18N
126:
127:                try {
128:
129:                    // setup project location for the current project
130:                    WizardHelpers.setProjectValues(wiz);
131:                    // initialize each panel
132:                    initializeComponents(steps, 0);
133:
134:                } catch (Exception ex) {
135:                    ex.printStackTrace();
136:                    WizardHelpers.logErrorMessage("initialize", ex);// NOI18N
137:                }
138:            }
139:
140:            //*********************************************************************
141:            // WizardIntegration method :
142:            //
143:            // Called when integrating this wizard within a higher level wizard.
144:            //
145:            //*********************************************************************
146:
147:            /**
148:             * Method which defines the different steps of our wizard;
149:             * Called when integrating this wizard within a higher level
150:             * wizard
151:             * @param wiz a WizardDescriptor
152:             * @return <CODE>String[]</CODE> step names
153:             */
154:
155:            public String[] initializeSteps(WizardDescriptor wiz) {
156:                this .wiz = (TemplateWizard) wiz;
157:
158:                steps = new String[1];
159:                steps[0] = bundle.getString("LBL_Standard_Panel");// NOI18N
160:                return steps;
161:            }
162:
163:            //*********************************************************************
164:            // WizardIntegration method :
165:            //
166:            // Called when integrating this wizard within a higher level wizard.
167:            //
168:            // Parameters :
169:            //
170:            // Steps       : Panels list to use
171:            // panelOffset : number of the first panel of this wizard
172:            //
173:            //*********************************************************************
174:
175:            protected abstract String getGeneratedMBeanType();
176:
177:            /**
178:             * Method which initialises the different components
179:             * Called when integrating this wizard within a higher level wizard
180:             * @param steps Panels list to use
181:             * @param panelOffset number of the first panel of this wizard
182:             */
183:
184:            public void initializeComponents(String[] steps, int panelOffset) {
185:                mbeanTemplatePanel = new MBeanPanel.MBeanPanelWizardPanel(
186:                        getGeneratedMBeanType());
187:                initializeComponent(steps, panelOffset + 0,
188:                        (JComponent) mbeanTemplatePanel.getComponent());
189:
190:                Project project = Templates.getProject(wiz);
191:                SourceGroup[] mbeanSrcGroups = WizardHelpers
192:                        .getSourceGroups(project);
193:                WizardDescriptor.Panel delegateMBeanPanel = JavaTemplates
194:                        .createPackageChooser(project, mbeanSrcGroups,
195:                                mbeanTemplatePanel);
196:                mbeanPanel = new WizardPanelWithoutReadSettings(
197:                        delegateMBeanPanel, mbeanTemplatePanel);
198:                mbeanPanel.getComponent().setName(
199:                        bundle.getString("LBL_Standard_Panel"));// NOI18N
200:                initializeComponent(steps, panelOffset + 0,
201:                        (JComponent) mbeanPanel.getComponent());
202:                ((MBeanPanel.MBeanPanelWizardPanel) mbeanTemplatePanel)
203:                        .setListenerEnabled(delegateMBeanPanel,
204:                                mbeanTemplatePanel, wiz);
205:                mbeanPanel.readAllSettings(wiz);
206:
207:                currentPanel = mbeanPanel;
208:            }
209:
210:            private void initializeComponent(String[] steps, int panelOffset,
211:                    JComponent jc) {
212:                jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
213:                jc.putClientProperty("WizardPanel_contentSelectedIndex",
214:                        panelOffset);// NOI18N
215:            }
216:
217:            /**
218:             * Method which releases the wizard
219:             * @param wiz a TemplateWizard
220:             */
221:            public void uninitialize(TemplateWizard wiz) {
222:                this .wiz = null;
223:            }
224:
225:            //*********************************************************************
226:            // real code / file generation
227:            //*********************************************************************
228:
229:            /**
230:             * Method which recalls the stored data and generates the mbean
231:             * @return <CODE>Set</CODE> set of generated files to open
232:             * @param wizard the wizard which contains all the data
233:             * @throws java.io.IOException <CODE>IOException</CODE>
234:             */
235:            public java.util.Set/*<FileObject>*/instantiate(
236:                    TemplateWizard wizard) throws java.io.IOException {
237:                mbeanPanel.storeAllSettings(wizard);
238:
239:                // mbean generation
240:                try {
241:
242:                    return GeneratorControler.generate(wizard);
243:
244:                } catch (Exception ex) {
245:                    WizardHelpers.logErrorMessage("MBean generation ", ex);// NOI18N
246:                    return Collections.EMPTY_SET;
247:                }
248:            }
249:
250:            /**
251:             * Method returning the name of a component contained in the current panel
252:             * @return name the name of the component
253:             */
254:            public String name() {
255:                Component c = currentPanel.getComponent();
256:
257:                if (c != null)
258:                    return c.getName();
259:
260:                return null;
261:            }
262:
263:            /**
264:             * Method returning the current panel
265:             * @return currentPanel the current panel
266:             */
267:            public org.openide.WizardDescriptor.Panel current() {
268:                return currentPanel;
269:            }
270:
271:            /**
272:             * Method returning if the current panel has a next panel or not
273:             * Enables the next button
274:             * @return next true if the current panel has a next one
275:             */
276:            public boolean hasNext() {
277:
278:                if (currentPanel == mbeanPanel) {
279:                    return false;
280:                } else
281:                    return true;
282:
283:            }
284:
285:            /**
286:             * Method returning if the current panel has a previous panel or not
287:             * Enables the back button
288:             * @return next true if the current panel has a previous one
289:             */
290:            public boolean hasPrevious() {
291:                return false;
292:            }
293:
294:            /**
295:             * Method reaffecting the current panel variable to the next panel
296:             */
297:            public void nextPanel() {
298:            }
299:
300:            /**
301:             * Method reaffecting the current panel variable to the previous panel
302:             */
303:            public void previousPanel() {
304:            }
305:
306:            private transient Set listeners = new HashSet(1); // Set<ChangeListener>
307:
308:            public final void addChangeListener(ChangeListener l) {
309:                synchronized (listeners) {
310:                    listeners.add(l);
311:                }
312:            }
313:
314:            public final void removeChangeListener(ChangeListener l) {
315:                synchronized (listeners) {
316:                    listeners.remove(l);
317:                }
318:            }
319:
320:            /**
321:             * Fire a change event.
322:             */
323:            protected final void fireChangeEvent() {
324:                Iterator it;
325:                synchronized (listeners) {
326:                    it = new HashSet(listeners).iterator();
327:                }
328:                ChangeEvent ev = new ChangeEvent(this );
329:                while (it.hasNext()) {
330:                    ((ChangeListener) it.next()).stateChanged(ev);
331:                }
332:            }
333:
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.