Source Code Cross Referenced for AddServerInstanceWizard.java in  » IDE-Netbeans » server » org » netbeans » modules » server » ui » wizard » 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 » server » org.netbeans.modules.server.ui.wizard 
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:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 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:
042:        package org.netbeans.modules.server.ui.wizard;
043:
044:        import java.awt.Dialog;
045:        import java.io.IOException;
046:        import java.text.MessageFormat;
047:        import java.util.HashMap;
048:        import java.util.Map;
049:        import java.util.Set;
050:        import java.util.logging.Level;
051:        import java.util.logging.Logger;
052:        import javax.swing.JComponent;
053:        import javax.swing.event.ChangeListener;
054:        import org.netbeans.api.server.ServerInstance;
055:        import org.netbeans.spi.server.ServerWizardProvider;
056:        import org.openide.DialogDisplayer;
057:        import org.openide.WizardDescriptor;
058:        import org.openide.util.NbBundle;
059:
060:        /**
061:         *
062:         * @author Andrei Badea
063:         * @author Petr Hejl
064:         */
065:        public class AddServerInstanceWizard extends WizardDescriptor {
066:
067:            public static final String PROP_DISPLAY_NAME = "ServInstWizard_displayName"; // NOI18N
068:
069:            public static final String PROP_SERVER_INSTANCE_WIZARD = "ServInstWizard_server"; // NOI18N
070:
071:            private static final String PROP_AUTO_WIZARD_STYLE = "WizardPanel_autoWizardStyle"; // NOI18N
072:
073:            private static final String PROP_CONTENT_DISPLAYED = "WizardPanel_contentDisplayed"; // NOI18N
074:
075:            private static final String PROP_CONTENT_NUMBERED = "WizardPanel_contentNumbered"; // NOI18N
076:
077:            private static final String PROP_CONTENT_DATA = "WizardPanel_contentData"; // NOI18N
078:
079:            private static final String PROP_CONTENT_SELECTED_INDEX = "WizardPanel_contentSelectedIndex"; // NOI18N
080:
081:            private static final String PROP_ERROR_MESSAGE = "WizardPanel_errorMessage"; // NOI18N
082:
083:            private AddServerInstanceWizardIterator iterator;
084:
085:            private ServerWizardPanel chooser;
086:
087:            private static final Logger LOGGER = Logger
088:                    .getLogger(AddServerInstanceWizard.class.getName()); // NOI18N
089:
090:            private AddServerInstanceWizard() {
091:                this (new AddServerInstanceWizardIterator());
092:
093:                putProperty(PROP_AUTO_WIZARD_STYLE, Boolean.TRUE);
094:                putProperty(PROP_CONTENT_DISPLAYED, Boolean.TRUE);
095:                putProperty(PROP_CONTENT_NUMBERED, Boolean.TRUE);
096:
097:                setTitle(NbBundle.getMessage(AddServerInstanceWizard.class,
098:                        "LBL_ASIW_Title"));
099:                setTitleFormat(new MessageFormat(NbBundle.getMessage(
100:                        AddServerInstanceWizard.class, "LBL_ASIW_TitleFormat")));
101:
102:                initialize();
103:            }
104:
105:            private AddServerInstanceWizard(
106:                    AddServerInstanceWizardIterator iterator) {
107:                super (iterator);
108:                this .iterator = iterator;
109:            }
110:
111:            public static ServerInstance showAddServerInstanceWizard() {
112:                AddServerInstanceWizard wizard = new AddServerInstanceWizard();
113:
114:                Dialog dialog = DialogDisplayer.getDefault().createDialog(
115:                        wizard);
116:                try {
117:                    dialog.getAccessibleContext().setAccessibleDescription(
118:                            NbBundle.getMessage(AddServerInstanceWizard.class,
119:                                    "ACSD_Add_Server_Instance"));
120:                    dialog.setVisible(true);
121:                } finally {
122:                    dialog.dispose();
123:                }
124:
125:                if (wizard.getValue() == WizardDescriptor.FINISH_OPTION) {
126:                    Set instantiatedObjects = wizard.getInstantiatedObjects();
127:                    if (instantiatedObjects != null
128:                            && instantiatedObjects.size() > 0) {
129:                        Object result = instantiatedObjects.iterator().next();
130:                        if (result instanceof  ServerInstance) {
131:                            return (ServerInstance) result;
132:                        } else {
133:                            LOGGER.log(Level.WARNING, "Some localized warning"); // NOI18N
134:                            return null;
135:                        }
136:                    }
137:                }
138:                // the wizard was cancelled
139:                return null;
140:            }
141:
142:            public void setErrorMessage(String message) {
143:                putProperty(PROP_ERROR_MESSAGE, message);
144:            }
145:
146:            @Override
147:            protected void updateState() {
148:                super .updateState();
149:
150:                String[] contentData = getContentData();
151:                if (contentData != null) {
152:                    putProperty(PROP_CONTENT_DATA, contentData);
153:                    putProperty(PROP_CONTENT_SELECTED_INDEX, Integer
154:                            .valueOf(getContentSelectedIndex()));
155:                }
156:            }
157:
158:            private ServerWizardPanel getChooser() {
159:                if (chooser == null) {
160:                    chooser = new ServerWizardPanel();
161:                }
162:                return chooser;
163:            }
164:
165:            private String[] getContentData() {
166:                JComponent first = (JComponent) getChooser().getComponent();
167:                String[] firstContentData = (String[]) first
168:                        .getClientProperty(PROP_CONTENT_DATA);
169:
170:                if (iterator.current().equals(getChooser())) {
171:                    return firstContentData;
172:                } else {
173:                    JComponent component = (JComponent) iterator.current()
174:                            .getComponent();
175:                    String[] componentContentData = (String[]) component
176:                            .getClientProperty(PROP_CONTENT_DATA);
177:                    if (componentContentData == null) {
178:                        return firstContentData;
179:                    }
180:
181:                    String[] contentData = new String[componentContentData.length + 1];
182:                    contentData[0] = firstContentData[0];
183:                    System.arraycopy(componentContentData, 0, contentData, 1,
184:                            componentContentData.length);
185:                    return contentData;
186:                }
187:            }
188:
189:            private int getContentSelectedIndex() {
190:                if (iterator.current().equals(getChooser())) {
191:                    return 0;
192:                } else {
193:                    JComponent component = (JComponent) iterator.current()
194:                            .getComponent();
195:                    Integer componentIndex = (Integer) component
196:                            .getClientProperty(PROP_CONTENT_SELECTED_INDEX);
197:                    if (componentIndex != null) {
198:                        return componentIndex.intValue() + 1;
199:                    } else {
200:                        return 1;
201:                    }
202:                }
203:            }
204:
205:            private static class AddServerInstanceWizardIterator implements 
206:                    WizardDescriptor.InstantiatingIterator {
207:
208:                private final Map<ServerWizardProvider, InstantiatingIterator> iterators = new HashMap<ServerWizardProvider, InstantiatingIterator>();
209:
210:                private WizardDescriptor.InstantiatingIterator iterator;
211:
212:                private AddServerInstanceWizard wd;
213:
214:                public boolean showingChooser = true;
215:
216:                public AddServerInstanceWizardIterator() {
217:                    super ();
218:                }
219:
220:                public String name() {
221:                    return null;
222:                }
223:
224:                public WizardDescriptor.Panel current() {
225:                    if (showingChooser) {
226:                        return wd.getChooser();
227:                    } else {
228:                        if (iterator != null) {
229:                            return iterator.current();
230:                        } else {
231:                            return null;
232:                        }
233:                    }
234:                }
235:
236:                public boolean hasNext() {
237:                    if (showingChooser) {
238:                        return true;
239:                    } else {
240:                        if (iterator != null) {
241:                            return iterator.hasNext();
242:                        } else {
243:                            return false;
244:                        }
245:                    }
246:                }
247:
248:                public boolean hasPrevious() {
249:                    return !showingChooser;
250:                }
251:
252:                public void nextPanel() {
253:                    if (iterator == null) {
254:                        iterator = getServerIterator();
255:                    } else {
256:                        if (!showingChooser) {
257:                            iterator.nextPanel();
258:                        }
259:                    }
260:                    showingChooser = false;
261:                }
262:
263:                public void previousPanel() {
264:                    if (iterator.hasPrevious()) {
265:                        iterator.previousPanel();
266:                    } else {
267:                        showingChooser = true;
268:                        iterator = null;
269:                    }
270:                }
271:
272:                public void addChangeListener(ChangeListener l) {
273:                }
274:
275:                public void removeChangeListener(ChangeListener l) {
276:                }
277:
278:                public void uninitialize(WizardDescriptor wizard) {
279:                }
280:
281:                public void initialize(WizardDescriptor wizard) {
282:                    wd = (AddServerInstanceWizard) wizard;
283:
284:                    JComponent chooser = (JComponent) wd.getChooser()
285:                            .getComponent();
286:                    chooser.putClientProperty(PROP_CONTENT_DATA, new String[] {
287:                            NbBundle.getMessage(AddServerInstanceWizard.class,
288:                                    "LBL_ASIW_ChooseServer"),
289:                            NbBundle.getMessage(AddServerInstanceWizard.class,
290:                                    "LBL_ASIW_Ellipsis") });
291:                }
292:
293:                public Set instantiate() throws IOException {
294:                    if (iterator != null) {
295:                        return iterator.instantiate();
296:                    } else {
297:                        return null;
298:                    }
299:                }
300:
301:                private WizardDescriptor.InstantiatingIterator getServerIterator() {
302:                    ServerWizardProvider server = getSelectedWizard();
303:                    if (server == null) {
304:                        return null;
305:                    }
306:
307:                    WizardDescriptor.InstantiatingIterator iterator = (WizardDescriptor.InstantiatingIterator) iterators
308:                            .get(server);
309:                    if (iterator != null) {
310:                        return iterator;
311:                    }
312:
313:                    iterator = server.getInstantiatingIterator();
314:                    iterator.initialize(wd);
315:                    iterators.put(server, iterator);
316:                    return iterator;
317:                }
318:
319:                public ServerWizardProvider getSelectedWizard() {
320:                    return (ServerWizardProvider) wd
321:                            .getProperty(PROP_SERVER_INSTANCE_WIZARD);
322:                }
323:            }
324:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.