Source Code Cross Referenced for WizardPatternSelection.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.infrastructure.ICollaboration;
062:        import org.netbeans.modules.uml.core.metamodel.structure.IProject;
063:        import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
064:        import org.netbeans.modules.uml.core.support.umlutils.ETList;
065:        import org.netbeans.modules.uml.ui.support.wizard.IWizardSheet;
066:        import org.netbeans.modules.uml.ui.support.wizard.WizardInteriorPage;
067:
068:        public class WizardPatternSelection extends WizardInteriorPage {
069:
070:            private static final String PG_CAPTION = DefaultDesignPatternResource
071:                    .getString("IDS_WIZARDCAPTION");
072:            private static final String PG_TITLE = DefaultDesignPatternResource
073:                    .getString("IDS_PATTERNSELECTION");
074:            private static final String PG_SUBTITLE = DefaultDesignPatternResource
075:                    .getString("IDS_PATTERNSELECTIONHELP");
076:
077:            private Wizard m_Wizard = null;
078:            private ICollaboration m_Pattern = null;
079:            private IProject m_Project = null;
080:
081:            private JComboBox m_ProjectList = new JComboBox();
082:            private JLabel jLabel1 = new JLabel();
083:            private JComboBox m_PatternList = new JComboBox();
084:            private JLabel jLabel2 = new JLabel();
085:            private JTextArea helpCaption = new JTextArea();
086:
087:            public WizardPatternSelection(IWizardSheet parent, String caption,
088:                    String headerTitle, String headerSubTitle) {
089:                super (parent, caption, headerTitle, headerSubTitle);
090:                createUI();
091:            }
092:
093:            public WizardPatternSelection(IWizardSheet parent) {
094:                this (parent, PG_CAPTION, PG_TITLE, PG_SUBTITLE);
095:            }
096:
097:            protected void createUI() {
098:                super .createUI();
099:
100:                jLabel1.setText(DefaultDesignPatternResource
101:                        .determineText(DefaultDesignPatternResource
102:                                .getString("IDS_PROJECT")));
103:                DefaultDesignPatternResource.setMnemonic(jLabel1,
104:                        DefaultDesignPatternResource.getString("IDS_PROJECT"));
105:                jLabel1.setLabelFor(m_ProjectList);
106:                DefaultDesignPatternResource.setFocusAccelerator(m_ProjectList,
107:                        DefaultDesignPatternResource.getString("IDS_PROJECT"));
108:                jLabel1.setBorder(new javax.swing.border.EmptyBorder(
109:                        new java.awt.Insets(0, 0, 3, 0)));
110:                jLabel1.getAccessibleContext().setAccessibleDescription(
111:                        DefaultDesignPatternResource
112:                                .getString("ACSD_PROJECT_COMBOBOX"));
113:
114:                jLabel2.setText(DefaultDesignPatternResource
115:                        .determineText(DefaultDesignPatternResource
116:                                .getString("IDS_DESIGNPATTERN")));
117:                DefaultDesignPatternResource.setMnemonic(jLabel2,
118:                        DefaultDesignPatternResource
119:                                .getString("IDS_DESIGNPATTERN"));
120:                jLabel2.setLabelFor(m_PatternList);
121:                DefaultDesignPatternResource.setFocusAccelerator(m_PatternList,
122:                        DefaultDesignPatternResource
123:                                .getString("IDS_DESIGNPATTERN"));
124:                jLabel2.setBorder(new javax.swing.border.EmptyBorder(
125:                        new java.awt.Insets(0, 0, 3, 0)));
126:                jLabel2.getAccessibleContext().setAccessibleDescription(
127:                        DefaultDesignPatternResource
128:                                .getString("ACSD_DESIGNPATTERN_COMBOBOX"));
129:
130:                helpCaption.setLineWrap(true);
131:                helpCaption.setOpaque(false);
132:                helpCaption.setPreferredSize(new Dimension(300, 30));
133:                helpCaption.setMinimumSize(new Dimension(300, 30));
134:                helpCaption.setFont(new java.awt.Font("SansSerif", 0, 10));
135:                helpCaption.setEditable(false);
136:                helpCaption.setFocusable(false);
137:                helpCaption.getAccessibleContext()
138:                        .setAccessibleName(
139:                                DefaultDesignPatternResource
140:                                        .getString("ACSN_TEXTAREA"));
141:                helpCaption.getAccessibleContext()
142:                        .setAccessibleDescription(
143:                                DefaultDesignPatternResource
144:                                        .getString("ACSD_TEXTAREA"));
145:
146:                pnlContents.setLayout(new GridBagLayout());
147:
148:                pnlContents.add(jLabel1, new GridBagConstraints(0, 0, 1, 1,
149:                        0.0, 0.0, GridBagConstraints.WEST,
150:                        GridBagConstraints.NONE, new Insets(20, 10, 0, 205),
151:                        32, 0));
152:                pnlContents.add(m_ProjectList, new GridBagConstraints(0, 1, 1,
153:                        1, 1.0, 0.0, GridBagConstraints.WEST,
154:                        GridBagConstraints.HORIZONTAL,
155:                        new Insets(0, 10, 0, 10), 284, 0));
156:                pnlContents.add(jLabel2, new GridBagConstraints(0, 2, 1, 1,
157:                        0.0, 0.0, GridBagConstraints.WEST,
158:                        GridBagConstraints.NONE, new Insets(20, 10, 0, 205),
159:                        32, 0));
160:                pnlContents.add(m_PatternList, new GridBagConstraints(0, 3, 1,
161:                        1, 1.0, 0.0, GridBagConstraints.WEST,
162:                        GridBagConstraints.HORIZONTAL,
163:                        new Insets(0, 10, 0, 10), 284, 0));
164:                pnlContents.add(helpCaption, new GridBagConstraints(0, 4, 1, 1,
165:                        1.0, 1.0, GridBagConstraints.WEST,
166:                        GridBagConstraints.BOTH, new Insets(5, 20, 200, 20),
167:                        47, 1));
168:
169:                m_ProjectList.setEditable(false);
170:                m_PatternList.setEditable(false);
171:
172:                pnlContents.setBorder(new javax.swing.border.EmptyBorder(
173:                        new java.awt.Insets(5, 5, 5, 5)));
174:
175:                this .addActionListeners();
176:                this .onInitDialog();
177:            }
178:
179:            private void addActionListeners() {
180:                m_ProjectList
181:                        .addActionListener(new java.awt.event.ActionListener() {
182:                            public void actionPerformed(ActionEvent e) {
183:                                m_ProjectList_actionPerformed(e);
184:                            }
185:                        });
186:                m_PatternList
187:                        .addActionListener(new java.awt.event.ActionListener() {
188:                            public void actionPerformed(ActionEvent e) {
189:                                m_PatternList_actionPerformed(e);
190:                            }
191:                        });
192:
193:            }
194:
195:            private void m_ProjectList_actionPerformed(ActionEvent e) {
196:                onSelChangeProjectList();
197:            }
198:
199:            private void m_PatternList_actionPerformed(ActionEvent e) {
200:                onSelChangePatternList();
201:            }
202:
203:            /**
204:             * Called when dialog is initialized
205:             *
206:             *
207:             *
208:             * @return BOOL
209:             *
210:             */
211:            protected boolean onInitDialog() {
212:                super .onInitDialog();
213:
214:                IWizardSheet parent = getParentSheet();
215:                m_Wizard = (Wizard) parent;
216:                if (m_Wizard != null) {
217:                    IDesignPatternDetails pDetails = m_Wizard.getDetails();
218:                    if (pDetails != null) {
219:                        m_Pattern = pDetails.getCollaboration();
220:                    }
221:                }
222:                if (m_Pattern != null) {
223:                    m_ProjectList.setEnabled(false);
224:                    m_PatternList.setEnabled(false);
225:                } else {
226:                    m_ProjectList.setEnabled(true);
227:                    m_PatternList.setEnabled(true);
228:                }
229:
230:                return true; // return TRUE unless you set the focus to a control
231:            }
232:
233:            /**
234:             * Called when the page becomes active
235:             *
236:             *
237:             *
238:             * @return BOOL
239:             */
240:            public void onSetActive() {
241:                populateProjectList();
242:                populateProject();
243:                populatePattern();
244:                super .onSetActive();
245:            }
246:
247:            /**
248:             * Called when the user clicks back
249:             *
250:             *
251:             *
252:             * @return LRESULT		Whether or not to continue to the next page
253:             *
254:             */
255:            public void onWizardBack() {
256:
257:                if (m_Wizard != null) {
258:                    m_Wizard.m_RefreshPages = false;
259:                }
260:                super .onWizardBack();
261:            }
262:
263:            /**
264:             * Called when the user clicks next
265:             *
266:             *
267:             *
268:             * @return LRESULT		Whether or not to continue to the next page
269:             *
270:             */
271:            public void onWizardNext() {
272:                // validate the page information
273:                ETList<String> errorList = validatePage();
274:                if (errorList != null && errorList.size() == 0) {
275:                    String patName = (String) m_PatternList.getSelectedItem();
276:                    IDesignPatternManager pManager = m_Wizard.getManager();
277:                    if (pManager != null) {
278:                        ETList<IElement> pTemp = pManager
279:                                .getPatternsInProject(m_Project);
280:                        if (pTemp != null) {
281:                            int eleCount = pTemp.size();
282:                            for (int y = 0; y < eleCount; y++) {
283:                                IElement pEle = pTemp.get(y);
284:                                if (pEle != null) {
285:                                    if (pEle instanceof  ICollaboration) {
286:                                        ICollaboration pNamed = (ICollaboration) pEle;
287:                                        String name = pNamed.getQualifiedName();
288:                                        if (name != null
289:                                                && name.equals(patName)) {
290:                                            m_Pattern = pNamed;
291:                                            IDesignPatternDetails pDetails = m_Wizard
292:                                                    .getDetails();
293:                                            if (pDetails != null) {
294:                                                pDetails
295:                                                        .setCollaboration(m_Pattern);
296:                                                pDetails.setRoles(null);
297:                                                pDetails
298:                                                        .clearParticipantNames();
299:                                                pManager.buildPatternDetails(
300:                                                        m_Pattern, pDetails);
301:                                                break;
302:                                            }
303:                                        }
304:                                    }
305:                                }
306:                            }
307:                        }
308:                    }
309:                    super .onWizardNext();
310:                } else if (errorList != null && errorList.size() > 0) {
311:                    // display the errors
312:                    String msg = DesignPatternUtilities
313:                            .formatErrorMessage(errorList);
314:                    DesignPatternUtilities.displayErrorMessage(m_Wizard, msg);
315:                }
316:            }
317:
318:            /**
319:             * Fills in the project list box.
320:             *
321:             * @return HRESULT
322:             */
323:            private void populateProjectList() {
324:                if (m_ProjectList.getItemCount() == 0) {
325:                    DesignPatternUtilities
326:                            .populateProjectListWithDesignCenterProjects(
327:                                    m_ProjectList, false);
328:                }
329:            }
330:
331:            /**
332:             * Fills in the project list box default.
333:             *
334:             * @return HRESULT
335:             */
336:            private void populateProject() {
337:                if (m_Pattern != null) {
338:                    IProject pProj = m_Pattern.getProject();
339:                    if (pProj != null) {
340:                        DesignPatternUtilities
341:                                .populateProjectListWithUserProjects(
342:                                        m_ProjectList, false);
343:                        String name = pProj.getName();
344:                        m_ProjectList.setSelectedItem(name);
345:                    }
346:                }
347:                onSelChangeProjectList();
348:            }
349:
350:            /**
351:             * Fills in the pattern list default.
352:             *
353:             * @return HRESULT
354:             */
355:            private void populatePattern() {
356:                if (m_Pattern != null) {
357:                    String name = m_Pattern.getQualifiedName();
358:                    m_PatternList.setSelectedItem(name);
359:                }
360:            }
361:
362:            /**
363:             * Event called when an entry in the project list box changes
364:             *
365:             * @return HRESULT
366:             */
367:            private void onSelChangeProjectList() {
368:                // get the new list entry
369:                m_Project = null;
370:                String selText = (String) m_ProjectList.getSelectedItem();
371:                if (selText != null && selText.length() > 0) {
372:                    IProject pProject = DesignPatternUtilities
373:                            .onSelChangeProjectList(selText, m_Wizard);
374:                    if (pProject != null) {
375:                        m_Project = pProject;
376:                        DesignPatternUtilities.populatePatternList(
377:                                m_PatternList, pProject);
378:                        m_Wizard.m_RefreshPages = true;
379:                    }
380:                }
381:            }
382:
383:            /**
384:             * Performs page validations -
385:             *
386:             *
387:             * @param errList[out]		An array of errors that occurred on the page
388:             *
389:             * @return HRESULT
390:             *
391:             */
392:            private ETList<String> validatePage() {
393:                ETList<String> tempList = new ETArrayList<String>();
394:                if (m_Pattern != null) {
395:                } else {
396:                    if (m_ProjectList.getSelectedIndex() == -1) {
397:                        String err = DesignPatternUtilities
398:                                .translateString("IDS_SCOPE_NOSELECT");
399:                        tempList.add(err);
400:                    }
401:                    if (m_PatternList.getSelectedIndex() == -1) {
402:                        String err = DesignPatternUtilities
403:                                .translateString("IDS_SCOPE_SELECT");
404:                        tempList.add(err);
405:                    }
406:                }
407:                return tempList;
408:            }
409:
410:            private void onSelChangePatternList() {
411:                // get the new list entry
412:                //m_Pattern = null;
413:                m_Wizard.m_RefreshPages = true;
414:            }
415:
416:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.