Source Code Cross Referenced for WizardTarget.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » designpattern » 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 » uml » org.netbeans.modules.uml.designpattern 
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-2007 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.uml.designpattern;
043:
044:        import java.awt.Dimension;
045:        import java.awt.GridBagConstraints;
046:        import java.awt.GridBagLayout;
047:        import java.awt.Insets;
048:        import java.awt.SystemColor;
049:        import java.awt.event.ActionEvent;
050:        import java.io.File;
051:
052:        import javax.swing.JButton;
053:        import javax.swing.JComboBox;
054:        import javax.swing.JFileChooser;
055:        import javax.swing.JLabel;
056:        import javax.swing.JTextArea;
057:        import javax.swing.JTextField;
058:
059:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
060:        import org.netbeans.modules.uml.core.metamodel.core.foundation.INamedElement;
061:        import org.netbeans.modules.uml.core.metamodel.core.foundation.INamespace;
062:        import org.netbeans.modules.uml.core.metamodel.infrastructure.ICollaboration;
063:        import org.netbeans.modules.uml.core.metamodel.structure.IProject;
064:        import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
065:        import org.netbeans.modules.uml.core.support.umlutils.ETList;
066:        import org.netbeans.modules.uml.ui.support.ProductHelper;
067:        import org.netbeans.modules.uml.ui.support.applicationmanager.IProduct;
068:        import org.netbeans.modules.uml.ui.support.applicationmanager.IProductProjectManager;
069:        import org.netbeans.modules.uml.ui.support.wizard.IWizardSheet;
070:        import org.netbeans.modules.uml.ui.support.wizard.WizardInteriorPage;
071:
072:        public class WizardTarget extends WizardInteriorPage {
073:
074:            private static final String PG_CAPTION = DefaultDesignPatternResource
075:                    .getString("IDS_WIZARDCAPTION");
076:            private static final String PG_TITLE = DefaultDesignPatternResource
077:                    .getString("IDS_TARGETSCOPE");
078:            private static final String PG_SUBTITLE = DefaultDesignPatternResource
079:                    .getString("IDS_TARGETSCOPEHELP");
080:
081:            private Wizard m_Wizard = null;
082:            private IProject m_Project = null;
083:
084:            private JComboBox m_ProjectList = new JComboBox();
085:            private JLabel jLabel1 = new JLabel();
086:            private JComboBox m_NamespaceList = new JComboBox();
087:            private JLabel jLabel2 = new JLabel();
088:            private JTextArea helpCaption = new JTextArea();
089:
090:            public WizardTarget(IWizardSheet parent, String caption,
091:                    String headerTitle, String headerSubTitle) {
092:                super (parent, caption, headerTitle, headerSubTitle);
093:                createUI();
094:            }
095:
096:            public WizardTarget(IWizardSheet parent) {
097:                this (parent, PG_CAPTION, PG_TITLE, PG_SUBTITLE);
098:            }
099:
100:            protected void createUI() {
101:                super .createUI();
102:
103:                jLabel1.setText(DefaultDesignPatternResource
104:                        .determineText(DefaultDesignPatternResource
105:                                .getString("IDS_PROJECT")));
106:                DefaultDesignPatternResource.setMnemonic(jLabel1,
107:                        DefaultDesignPatternResource.getString("IDS_PROJECT"));
108:                jLabel1.setLabelFor(m_ProjectList);
109:                DefaultDesignPatternResource.setFocusAccelerator(m_ProjectList,
110:                        DefaultDesignPatternResource.getString("IDS_PROJECT"));
111:                jLabel1.setBorder(new javax.swing.border.EmptyBorder(
112:                        new java.awt.Insets(0, 0, 3, 0)));
113:                jLabel1.getAccessibleContext().setAccessibleDescription(
114:                        DefaultDesignPatternResource
115:                                .getString("ACSD_PROJECT_COMBOBOX"));
116:
117:                jLabel2.setText(DefaultDesignPatternResource
118:                        .determineText(DefaultDesignPatternResource
119:                                .getString("IDS_NAMESPACE")));
120:                DefaultDesignPatternResource
121:                        .setMnemonic(jLabel2, DefaultDesignPatternResource
122:                                .getString("IDS_NAMESPACE"));
123:                jLabel2.setLabelFor(m_NamespaceList);
124:                DefaultDesignPatternResource.setFocusAccelerator(
125:                        m_NamespaceList, DefaultDesignPatternResource
126:                                .getString("IDS_NAMESPACE"));
127:                jLabel2.setBorder(new javax.swing.border.EmptyBorder(
128:                        new java.awt.Insets(0, 0, 3, 0)));
129:                jLabel2.getAccessibleContext().setAccessibleDescription(
130:                        DefaultDesignPatternResource
131:                                .getString("ACSD_NAMESPACE"));
132:
133:                helpCaption.setLineWrap(true);
134:                helpCaption.setOpaque(false);
135:                helpCaption.setPreferredSize(new Dimension(300, 30));
136:                helpCaption.setMinimumSize(new Dimension(300, 30));
137:                helpCaption.setFont(new java.awt.Font("SansSerif", 0, 10));
138:                helpCaption.setEditable(false);
139:                helpCaption.setFocusable(false);
140:                helpCaption.getAccessibleContext()
141:                        .setAccessibleName(
142:                                DefaultDesignPatternResource
143:                                        .getString("ACSN_TEXTAREA"));
144:                helpCaption.getAccessibleContext()
145:                        .setAccessibleDescription(
146:                                DefaultDesignPatternResource
147:                                        .getString("ACSD_TEXTAREA"));
148:
149:                pnlContents.setLayout(new GridBagLayout());
150:
151:                pnlContents.add(jLabel1, new GridBagConstraints(0, 0, 1, 1,
152:                        0.0, 0.0, GridBagConstraints.WEST,
153:                        GridBagConstraints.NONE, new Insets(20, 10, 0, 205),
154:                        32, 0));
155:                pnlContents.add(m_ProjectList, new GridBagConstraints(0, 1, 1,
156:                        1, 1.0, 0.0, GridBagConstraints.WEST,
157:                        GridBagConstraints.HORIZONTAL,
158:                        new Insets(0, 10, 0, 10), 284, 0));
159:                pnlContents.add(jLabel2, new GridBagConstraints(0, 2, 1, 1,
160:                        0.0, 0.0, GridBagConstraints.WEST,
161:                        GridBagConstraints.NONE, new Insets(20, 10, 0, 205),
162:                        32, 0));
163:                pnlContents.add(m_NamespaceList, new GridBagConstraints(0, 3,
164:                        1, 1, 1.0, 0.0, GridBagConstraints.WEST,
165:                        GridBagConstraints.HORIZONTAL,
166:                        new Insets(0, 10, 0, 10), 284, 0));
167:                pnlContents.add(helpCaption, new GridBagConstraints(0, 4, 1, 1,
168:                        1.0, 1.0, GridBagConstraints.WEST,
169:                        GridBagConstraints.BOTH, new Insets(5, 20, 200, 20),
170:                        47, 1));
171:
172:                m_ProjectList.setEditable(false);
173:                m_ProjectList.setEnabled(false);
174:                m_NamespaceList.setEditable(false);
175:
176:                pnlContents.setBorder(new javax.swing.border.EmptyBorder(
177:                        new java.awt.Insets(5, 5, 5, 5)));
178:
179:                this .addActionListeners();
180:                this .onInitDialog();
181:            }
182:
183:            private void addActionListeners() {
184:                m_ProjectList
185:                        .addActionListener(new java.awt.event.ActionListener() {
186:                            public void actionPerformed(ActionEvent e) {
187:                                m_ProjectList_actionPerformed(e);
188:                            }
189:                        });
190:            }
191:
192:            private void m_ProjectList_actionPerformed(ActionEvent e) {
193:                onSelChangeProjectList();
194:            }
195:
196:            /**
197:             * Called when dialog is initialized
198:             *
199:             *
200:             *
201:             * @return BOOL
202:             *
203:             */
204:            protected boolean onInitDialog() {
205:                super .onInitDialog();
206:
207:                IWizardSheet parent = getParentSheet();
208:                m_Wizard = (Wizard) parent;
209:
210:                return true; // return TRUE unless you set the focus to a control
211:            }
212:
213:            /**
214:             * Called when the page becomes active
215:             *
216:             *
217:             *
218:             * @return BOOL
219:             */
220:            public void onSetActive() {
221:                if (m_Wizard != null) {
222:                    populateProjectList();
223:                    populateProject();
224:                }
225:                super .onSetActive();
226:            }
227:
228:            /**
229:             * Called when the user clicks back
230:             *
231:             *
232:             *
233:             * @return LRESULT		Whether or not to continue to the next page
234:             *
235:             */
236:            public void onWizardBack() {
237:
238:                if (m_Wizard != null) {
239:                    m_Wizard.m_RefreshPages = false;
240:                }
241:                super .onWizardBack();
242:            }
243:
244:            /**
245:             * Called when the user clicks next
246:             *
247:             *
248:             *
249:             * @return LRESULT		Whether or not to continue to the next page
250:             *
251:             */
252:            public void onWizardNext() {
253:                // validate the page information
254:                ETList<String> errorList = validatePage();
255:                if (errorList != null && errorList.size() == 0) {
256:                    IDesignPatternDetails pDetails = m_Wizard.getDetails();
257:                    if (pDetails != null) {
258:                        pDetails.setProject(m_Project);
259:                        INamespace pNamespace = DesignPatternUtilities
260:                                .getSelectedNamespace(m_NamespaceList,
261:                                        m_Project);
262:                        if (pNamespace != null) {
263:                            pDetails.setNamespace(pNamespace);
264:                        } else {
265:                            pDetails.setNamespace(null);
266:                        }
267:                        super .onWizardNext();
268:                    }
269:                } else if (errorList != null && errorList.size() > 0) {
270:                    // display the errors
271:                    String msg = DesignPatternUtilities
272:                            .formatErrorMessage(errorList);
273:                    DesignPatternUtilities.displayErrorMessage(m_Wizard, msg);
274:                }
275:            }
276:
277:            /**
278:             * Fills in the project list box.
279:             *
280:             * @return HRESULT
281:             */
282:            private void populateProjectList() {
283:                if (m_ProjectList.getItemCount() == 0) {
284:                    DesignPatternUtilities.populateProjectListWithUserProjects(
285:                            m_ProjectList, true);
286:                }
287:            }
288:
289:            /**
290:             * Fills in the project list box default.
291:             *
292:             * @return HRESULT
293:             */
294:            private void populateProject() {
295:                // default the list box to the current project
296:                // In c++, we were doing the commented out code, but it doesn't make sense to do it
297:                // jUML because we only have one project.  In c++, if the user adds a user defined project
298:                // to the design center, it does in fact become the current project, but the list box
299:                // setSelectedItem fails to set, and the user has a drop down combo of the projects in the
300:                // project tree.
301:                // In jUML, we disabled the combo box (because there is only one project).  But going into
302:                // this code, would get the new current project (the newly added user defined pattern project)
303:                // and not set the selected to anything.  Not allowing the user to continue in the wizard.
304:                // So, always set the value in the disabled combo box to the first (and only) project
305:                IProduct pProduct = ProductHelper.getProduct();
306:                if (pProduct != null) {
307:                    IProductProjectManager pManager = pProduct
308:                            .getProjectManager();
309:                    if (pManager != null) {
310:                        IProject theProject = pManager.getCurrentProject();
311:                        if (theProject != null) {
312:                            String name = theProject.getName();
313:                            if (name != null && name.length() > 0) {
314:                                m_ProjectList.setSelectedItem(name);
315:                                onSelChangeProjectList();
316:                            }
317:                        }
318:                    }
319:                }
320:                //		if (m_ProjectList.getItemCount() > 0)
321:                //		{
322:                //			m_ProjectList.setSelectedIndex(0);
323:                //			onSelChangeProjectList();
324:                //		}
325:            }
326:
327:            /**
328:             * Event called when an entry in the project list box changes
329:             *
330:             * @return HRESULT
331:             */
332:            private void onSelChangeProjectList() {
333:                // get the new list entry
334:                m_Project = null;
335:                String selText = (String) m_ProjectList.getSelectedItem();
336:                if (selText != null && selText.length() > 0) {
337:                    IProject pProject = DesignPatternUtilities
338:                            .onSelChangeProjectList(selText, m_Wizard);
339:                    if (pProject != null) {
340:                        m_Project = pProject;
341:                        String oldSel = (String) m_NamespaceList
342:                                .getSelectedItem();
343:                        DesignPatternUtilities.populateNamespaceList(
344:                                m_NamespaceList, pProject);
345:                        m_NamespaceList.setSelectedItem(oldSel);
346:                    }
347:                }
348:            }
349:
350:            /**
351:             * Performs page validations -
352:             *
353:             *
354:             * @param errList[out]		An array of errors that occurred on the page
355:             *
356:             * @return HRESULT
357:             *
358:             */
359:            private ETList<String> validatePage() {
360:                ETList<String> tempList = new ETArrayList<String>();
361:                if (m_ProjectList.getSelectedIndex() == -1) {
362:                    String err = DesignPatternUtilities
363:                            .translateString("IDS_SCOPE_NOSELECT");
364:                    tempList.add(err);
365:                }
366:                return tempList;
367:            }
368:
369:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.