Source Code Cross Referenced for NameAndLocationPanel.java in  » IDE-Netbeans » api » org » netbeans » modules » apisupport » project » ui » wizard » winsys » 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 » api » org.netbeans.modules.apisupport.project.ui.wizard.winsys 
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.apisupport.project.ui.wizard.winsys;
043:
044:        import java.io.File;
045:        import javax.swing.JFileChooser;
046:        import javax.swing.JTextField;
047:        import javax.swing.event.DocumentEvent;
048:        import javax.swing.event.DocumentListener;
049:        import org.netbeans.api.project.ProjectUtils;
050:        import org.netbeans.modules.apisupport.project.ui.UIUtil;
051:        import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator;
052:        import org.openide.WizardDescriptor;
053:        import org.openide.util.HelpCtx;
054:        import org.openide.util.NbBundle;
055:        import org.openide.util.Utilities;
056:
057:        /**
058:         * the second panel in topcomponent wizard.
059:         *
060:         * @author Milos Kleint
061:         */
062:        final class NameAndLocationPanel extends BasicWizardIterator.Panel {
063:
064:            private NewTCIterator.DataModel data;
065:
066:            /** Creates new NameAndLocationPanel */
067:            public NameAndLocationPanel(final WizardDescriptor setting,
068:                    final NewTCIterator.DataModel data) {
069:                super (setting);
070:                this .data = data;
071:                initComponents();
072:                initAccessibility();
073:                putClientProperty("NewFileWizard_Title",
074:                        getMessage("LBL_TCWizardTitle"));
075:
076:                DocumentListener dListener = new UIUtil.DocumentAdapter() {
077:                    public void insertUpdate(DocumentEvent e) {
078:                        if (checkValidity()) {
079:                            updateData();
080:                        }
081:                    }
082:                };
083:                txtPrefix.getDocument().addDocumentListener(dListener);
084:                txtIcon.getDocument().addDocumentListener(dListener);
085:
086:                if (comPackageName.getEditor().getEditorComponent() instanceof  JTextField) {
087:                    JTextField txt = (JTextField) comPackageName.getEditor()
088:                            .getEditorComponent();
089:                    txt.getDocument().addDocumentListener(dListener);
090:                }
091:            }
092:
093:            protected void storeToDataModel() {
094:                updateData();
095:            }
096:
097:            private void updateData() {
098:                data.setPackageName(comPackageName.getEditor().getItem()
099:                        .toString());
100:                String icon = txtIcon.getText().trim();
101:                data.setIcon(icon.length() == 0 ? (String) null : icon);
102:                data.setName(txtPrefix.getText().trim());
103:                NewTCIterator.generateFileChanges(data);
104:                createdFilesValue.setText(UIUtil.generateTextAreaContent(data
105:                        .getCreatedModifiedFiles().getCreatedPaths()));
106:                modifiedFilesValue.setText(UIUtil.generateTextAreaContent(data
107:                        .getCreatedModifiedFiles().getModifiedPaths()));
108:                //#68294 check if the paths for newly created files are valid or not..
109:                String[] invalid = data.getCreatedModifiedFiles()
110:                        .getInvalidPaths();
111:                if (invalid.length > 0) {
112:                    setError(NbBundle.getMessage(NameAndLocationPanel.class,
113:                            "ERR_ToBeCreateFileExists", invalid[0]));
114:                }
115:
116:            }
117:
118:            protected void readFromDataModel() {
119:                txtPrefix.setText(data.getName());
120:                txtIcon.setText(data.getIcon());
121:                if (data.getPackageName() != null) {
122:                    comPackageName.setSelectedItem(data.getPackageName());
123:                }
124:                checkValidity();
125:            }
126:
127:            protected String getPanelName() {
128:                return getMessage("LBL_NameLocation_Title");
129:            }
130:
131:            private boolean checkValidity() {
132:                if (txtPrefix.getText().trim().length() == 0) {
133:                    setError(getMessage("ERR_Name_Prefix_Empty"));
134:                    return false;
135:                }
136:                if (!Utilities.isJavaIdentifier(txtPrefix.getText().trim())) {
137:                    setError(getMessage("ERR_Name_Prefix_Invalid"));
138:                    return false;
139:                }
140:                String path = txtIcon.getText().trim();
141:                if (path.length() != 0) {
142:                    File fil = new File(path);
143:                    if (!fil.exists()) {
144:                        setError(NbBundle.getMessage(getClass(),
145:                                "ERR_Icon_Invalid"));
146:                        return false;
147:                    }
148:                }
149:                String packageName = comPackageName.getEditor().getItem()
150:                        .toString().trim();
151:                if (packageName.length() == 0
152:                        || !UIUtil.isValidPackageName(packageName)) {
153:                    setError(NbBundle.getMessage(getClass(),
154:                            "ERR_Package_Invalid"));
155:                    return false;
156:                }
157:
158:                markValid();
159:                return true;
160:            }
161:
162:            protected HelpCtx getHelp() {
163:                return new HelpCtx(NameAndLocationPanel.class);
164:            }
165:
166:            private static String getMessage(String key) {
167:                return NbBundle.getMessage(NameAndLocationPanel.class, key);
168:            }
169:
170:            /** This method is called from within the constructor to
171:             * initialize the form.
172:             * WARNING: Do NOT modify this code. The content of this method is
173:             * always regenerated by the Form Editor.
174:             */
175:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
176:            private void initComponents() {
177:                java.awt.GridBagConstraints gridBagConstraints;
178:
179:                lblPrefix = new javax.swing.JLabel();
180:                txtPrefix = new javax.swing.JTextField();
181:                lblIcon = new javax.swing.JLabel();
182:                txtIcon = new javax.swing.JTextField();
183:                btnIcon = new javax.swing.JButton();
184:                lblProjectName = new javax.swing.JLabel();
185:                txtProjectName = new JTextField(ProjectUtils.getInformation(
186:                        this .data.getProject()).getDisplayName());
187:                lblPackageName = new javax.swing.JLabel();
188:                comPackageName = UIUtil.createPackageComboBox(data
189:                        .getSourceRootGroup());
190:                createdFiles = new javax.swing.JLabel();
191:                modifiedFiles = new javax.swing.JLabel();
192:                filler = new javax.swing.JLabel();
193:                createdFilesValue = new javax.swing.JTextArea();
194:                modifiedFilesValue = new javax.swing.JTextArea();
195:
196:                setLayout(new java.awt.GridBagLayout());
197:
198:                lblPrefix.setLabelFor(txtPrefix);
199:                org.openide.awt.Mnemonics.setLocalizedText(lblPrefix,
200:                        org.openide.util.NbBundle.getMessage(
201:                                NameAndLocationPanel.class, "LBL_Prefix"));
202:                gridBagConstraints = new java.awt.GridBagConstraints();
203:                gridBagConstraints.gridx = 0;
204:                gridBagConstraints.gridy = 0;
205:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
206:                gridBagConstraints.insets = new java.awt.Insets(1, 0, 6, 12);
207:                add(lblPrefix, gridBagConstraints);
208:
209:                gridBagConstraints = new java.awt.GridBagConstraints();
210:                gridBagConstraints.gridx = 1;
211:                gridBagConstraints.gridy = 0;
212:                gridBagConstraints.gridwidth = 2;
213:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
214:                gridBagConstraints.weightx = 1.0;
215:                gridBagConstraints.insets = new java.awt.Insets(1, 0, 6, 0);
216:                add(txtPrefix, gridBagConstraints);
217:
218:                lblIcon.setLabelFor(txtIcon);
219:                org.openide.awt.Mnemonics.setLocalizedText(lblIcon,
220:                        org.openide.util.NbBundle.getMessage(
221:                                NameAndLocationPanel.class, "LBL_Icon"));
222:                gridBagConstraints = new java.awt.GridBagConstraints();
223:                gridBagConstraints.gridx = 0;
224:                gridBagConstraints.gridy = 1;
225:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
226:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
227:                add(lblIcon, gridBagConstraints);
228:
229:                gridBagConstraints = new java.awt.GridBagConstraints();
230:                gridBagConstraints.gridx = 1;
231:                gridBagConstraints.gridy = 1;
232:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
233:                gridBagConstraints.weightx = 1.0;
234:                add(txtIcon, gridBagConstraints);
235:
236:                org.openide.awt.Mnemonics.setLocalizedText(btnIcon,
237:                        org.openide.util.NbBundle.getMessage(
238:                                NameAndLocationPanel.class, "LBL_Icon_Browse"));
239:                btnIcon.addActionListener(new java.awt.event.ActionListener() {
240:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
241:                        btnIconActionPerformed(evt);
242:                    }
243:                });
244:
245:                gridBagConstraints = new java.awt.GridBagConstraints();
246:                gridBagConstraints.gridx = 2;
247:                gridBagConstraints.gridy = 1;
248:                gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
249:                add(btnIcon, gridBagConstraints);
250:
251:                lblProjectName.setLabelFor(txtProjectName);
252:                org.openide.awt.Mnemonics
253:                        .setLocalizedText(
254:                                lblProjectName,
255:                                java.util.ResourceBundle
256:                                        .getBundle(
257:                                                "org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/Bundle")
258:                                        .getString("LBL_ProjectName"));
259:                gridBagConstraints = new java.awt.GridBagConstraints();
260:                gridBagConstraints.gridx = 0;
261:                gridBagConstraints.gridy = 2;
262:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
263:                gridBagConstraints.insets = new java.awt.Insets(18, 0, 6, 12);
264:                add(lblProjectName, gridBagConstraints);
265:
266:                txtProjectName.setEditable(false);
267:                gridBagConstraints = new java.awt.GridBagConstraints();
268:                gridBagConstraints.gridx = 1;
269:                gridBagConstraints.gridy = 2;
270:                gridBagConstraints.gridwidth = 2;
271:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
272:                gridBagConstraints.weightx = 1.0;
273:                gridBagConstraints.insets = new java.awt.Insets(18, 0, 6, 0);
274:                add(txtProjectName, gridBagConstraints);
275:
276:                lblPackageName.setLabelFor(comPackageName);
277:                org.openide.awt.Mnemonics
278:                        .setLocalizedText(
279:                                lblPackageName,
280:                                java.util.ResourceBundle
281:                                        .getBundle(
282:                                                "org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/Bundle")
283:                                        .getString("LBL_PackageName"));
284:                gridBagConstraints = new java.awt.GridBagConstraints();
285:                gridBagConstraints.gridx = 0;
286:                gridBagConstraints.gridy = 3;
287:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
288:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
289:                add(lblPackageName, gridBagConstraints);
290:
291:                comPackageName.setEditable(true);
292:                gridBagConstraints = new java.awt.GridBagConstraints();
293:                gridBagConstraints.gridx = 1;
294:                gridBagConstraints.gridy = 3;
295:                gridBagConstraints.gridwidth = 2;
296:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
297:                gridBagConstraints.weightx = 1.0;
298:                add(comPackageName, gridBagConstraints);
299:
300:                createdFiles.setLabelFor(createdFilesValue);
301:                org.openide.awt.Mnemonics
302:                        .setLocalizedText(
303:                                createdFiles,
304:                                java.util.ResourceBundle
305:                                        .getBundle(
306:                                                "org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/Bundle")
307:                                        .getString("LBL_CreatedFiles"));
308:                gridBagConstraints = new java.awt.GridBagConstraints();
309:                gridBagConstraints.gridx = 0;
310:                gridBagConstraints.gridy = 4;
311:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
312:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
313:                gridBagConstraints.insets = new java.awt.Insets(36, 0, 6, 12);
314:                add(createdFiles, gridBagConstraints);
315:
316:                modifiedFiles.setLabelFor(modifiedFilesValue);
317:                org.openide.awt.Mnemonics
318:                        .setLocalizedText(
319:                                modifiedFiles,
320:                                java.util.ResourceBundle
321:                                        .getBundle(
322:                                                "org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/Bundle")
323:                                        .getString("LBL_ModifiedFiles"));
324:                gridBagConstraints = new java.awt.GridBagConstraints();
325:                gridBagConstraints.gridx = 0;
326:                gridBagConstraints.gridy = 5;
327:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
328:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
329:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
330:                add(modifiedFiles, gridBagConstraints);
331:
332:                gridBagConstraints = new java.awt.GridBagConstraints();
333:                gridBagConstraints.gridx = 0;
334:                gridBagConstraints.gridy = 6;
335:                gridBagConstraints.gridwidth = 3;
336:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
337:                gridBagConstraints.weightx = 1.0;
338:                gridBagConstraints.weighty = 1.0;
339:                add(filler, gridBagConstraints);
340:
341:                createdFilesValue.setBackground(javax.swing.UIManager
342:                        .getDefaults().getColor("Label.background"));
343:                createdFilesValue.setColumns(20);
344:                createdFilesValue.setEditable(false);
345:                createdFilesValue.setRows(5);
346:                createdFilesValue.setBorder(null);
347:                gridBagConstraints = new java.awt.GridBagConstraints();
348:                gridBagConstraints.gridx = 1;
349:                gridBagConstraints.gridy = 4;
350:                gridBagConstraints.gridwidth = 2;
351:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
352:                gridBagConstraints.weightx = 1.0;
353:                gridBagConstraints.insets = new java.awt.Insets(36, 0, 6, 0);
354:                add(createdFilesValue, gridBagConstraints);
355:
356:                modifiedFilesValue.setBackground(javax.swing.UIManager
357:                        .getDefaults().getColor("Label.background"));
358:                modifiedFilesValue.setColumns(20);
359:                modifiedFilesValue.setEditable(false);
360:                modifiedFilesValue.setRows(5);
361:                modifiedFilesValue.setToolTipText("modifiedFilesValue");
362:                modifiedFilesValue.setBorder(null);
363:                gridBagConstraints = new java.awt.GridBagConstraints();
364:                gridBagConstraints.gridx = 1;
365:                gridBagConstraints.gridy = 5;
366:                gridBagConstraints.gridwidth = 2;
367:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
368:                gridBagConstraints.weightx = 1.0;
369:                add(modifiedFilesValue, gridBagConstraints);
370:
371:            }
372:
373:            // </editor-fold>//GEN-END:initComponents
374:
375:            private void initAccessibility() {
376:                this .getAccessibleContext().setAccessibleDescription(
377:                        getMessage("ACS_NameAndLocationPanel"));
378:                comPackageName.getAccessibleContext().setAccessibleDescription(
379:                        getMessage("ACS_CTL_PackageName"));
380:                txtIcon.getAccessibleContext().setAccessibleDescription(
381:                        getMessage("ACS_CTL_Icon"));
382:                txtPrefix.getAccessibleContext().setAccessibleDescription(
383:                        getMessage("ACS_CTL_Prefix"));
384:                btnIcon.getAccessibleContext().setAccessibleDescription(
385:                        getMessage("ACS_CTL_IconButton"));
386:                txtProjectName.getAccessibleContext().setAccessibleDescription(
387:                        getMessage("ACS_CTL_ProjectName"));
388:                createdFilesValue.getAccessibleContext()
389:                        .setAccessibleDescription(
390:                                getMessage("ACS_CTL_CreatedFilesValue"));
391:                modifiedFilesValue.getAccessibleContext()
392:                        .setAccessibleDescription(
393:                                getMessage("ACS_CTL_ModifiedFilesValue"));
394:            }
395:
396:            private void btnIconActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIconActionPerformed
397:                JFileChooser chooser = UIUtil.getIconFileChooser(txtIcon
398:                        .getText());
399:                int ret = chooser.showDialog(this , getMessage("LBL_Select")); // NOI18N
400:                if (ret == JFileChooser.APPROVE_OPTION) {
401:                    File file = chooser.getSelectedFile();
402:                    txtIcon.setText(file.getAbsolutePath());
403:                }
404:            }//GEN-LAST:event_btnIconActionPerformed
405:
406:            // Variables declaration - do not modify//GEN-BEGIN:variables
407:            private javax.swing.JButton btnIcon;
408:            private javax.swing.JComboBox comPackageName;
409:            private javax.swing.JLabel createdFiles;
410:            private javax.swing.JTextArea createdFilesValue;
411:            private javax.swing.JLabel filler;
412:            private javax.swing.JLabel lblIcon;
413:            private javax.swing.JLabel lblPackageName;
414:            private javax.swing.JLabel lblPrefix;
415:            private javax.swing.JLabel lblProjectName;
416:            private javax.swing.JLabel modifiedFiles;
417:            private javax.swing.JTextArea modifiedFilesValue;
418:            private javax.swing.JTextField txtIcon;
419:            private javax.swing.JTextField txtPrefix;
420:            private javax.swing.JTextField txtProjectName;
421:            // End of variables declaration//GEN-END:variables
422:
423:        }
w___w___w___.__j___a__va__2___s._c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.