Source Code Cross Referenced for SimpleTargetChooserPanelGUI.java in  » IDE-Netbeans » sql.project » org » netbeans » modules » jdbcwizard » wizards » 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 » sql.project » org.netbeans.modules.jdbcwizard.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        /*
021:         * 
022:         * Copyright 2005 Sun Microsystems, Inc.
023:         * 
024:         * Licensed under the Apache License, Version 2.0 (the "License");
025:         * you may not use this file except in compliance with the License.
026:         * You may obtain a copy of the License at
027:         * 
028:         * 	http://www.apache.org/licenses/LICENSE-2.0
029:         * 
030:         * Unless required by applicable law or agreed to in writing, software
031:         * distributed under the License is distributed on an "AS IS" BASIS,
032:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
033:         * See the License for the specific language governing permissions and
034:         * limitations under the License.
035:         * 
036:         */
037:        package org.netbeans.modules.jdbcwizard.wizards;
038:
039:        import org.netbeans.api.project.Project;
040:        import org.netbeans.api.project.ProjectUtils;
041:        import org.netbeans.api.project.SourceGroup;
042:        import org.netbeans.api.project.Sources;
043:
044:        import org.openide.filesystems.FileObject;
045:        import org.openide.filesystems.FileUtil;
046:
047:        import org.openide.loaders.DataObject;
048:        import org.openide.loaders.DataObjectNotFoundException;
049:
050:        import org.openide.util.NbBundle;
051:
052:        import java.awt.Component;
053:        import java.awt.event.ActionListener;
054:
055:        import java.io.File;
056:
057:        import java.text.MessageFormat;
058:
059:        import java.util.ArrayList;
060:        import java.util.Iterator;
061:        import java.util.List;
062:
063:        import javax.swing.DefaultComboBoxModel;
064:        import javax.swing.JLabel;
065:        import javax.swing.JList;
066:        import javax.swing.ListCellRenderer;
067:        import javax.swing.event.ChangeEvent;
068:        import javax.swing.event.ChangeListener;
069:        import javax.swing.event.DocumentListener;
070:        import org.openide.WizardDescriptor;
071:
072:        /**
073:         * DOCUMENT ME!
074:         * 
075:         * @author
076:         */
077:        public class SimpleTargetChooserPanelGUI extends javax.swing.JPanel
078:                implements  ActionListener, DocumentListener {
079:            /**
080:             * 
081:             */
082:            private static final long serialVersionUID = 1L;
083:
084:            /** prefered dimmension of the panels */
085:            private static final java.awt.Dimension PREF_DIM = new java.awt.Dimension(
086:                    500, 340);
087:
088:            private static final String NEW_FILE_PREFIX = NbBundle.getMessage(
089:                    SimpleTargetChooserPanelGUI.class,
090:                    "LBL_SimpleTargetChooserPanelGUI_NewFilePrefix"); // NOI18N
091:
092:            private final ListCellRenderer CELL_RENDERER = new GroupCellRenderer();
093:
094:            private Project project;
095:
096:            private String expectedExtension;
097:
098:            private final List /* <ChangeListener> */listeners = new ArrayList();
099:
100:            private SourceGroup[] folders;
101:
102:            private boolean isFolder;
103:
104:            private FileObject mFolderRoot = null;
105:
106:            private static final String mFolderText = "";
107:
108:            // Variables declaration - do not modify
109:            private javax.swing.JPanel bottomPanelContainer;
110:
111:            private javax.swing.JButton browseButton;
112:
113:            private javax.swing.JTextField documentNameTextField;
114:
115:            private javax.swing.JTextField fileTextField;
116:
117:            private javax.swing.JTextField folderTextField;
118:
119:            private javax.swing.JLabel jLabel1;
120:
121:            private javax.swing.JLabel jLabel2;
122:
123:            private javax.swing.JLabel jLabel3;
124:
125:            private javax.swing.JLabel jLabel4;
126:
127:            private javax.swing.JPanel jPanel1;
128:
129:            private javax.swing.JComboBox locationComboBox;
130:
131:            private javax.swing.JLabel locationLabel;
132:
133:            private javax.swing.JTextField projectTextField;
134:
135:            private javax.swing.JSeparator targetSeparator;
136:
137:            /**
138:             * Creates new form SimpleTargetChooserGUI
139:             * 
140:             * @param project DOCUMENT ME!
141:             * @param folders DOCUMENT ME!
142:             * @param bottomPanel DOCUMENT ME!
143:             * @param isFolder DOCUMENT ME!
144:             */
145:            public SimpleTargetChooserPanelGUI(Project project,
146:                    SourceGroup[] folders, Component bottomPanel,
147:                    boolean isFolder) {
148:                this .project = project;
149:                this .folders = folders;
150:                this .isFolder = isFolder;
151:                this .initComponents();
152:
153:                this .locationComboBox.setRenderer(this .CELL_RENDERER);
154:
155:                if (bottomPanel != null) {
156:                    this .bottomPanelContainer.add(bottomPanel,
157:                            java.awt.BorderLayout.CENTER);
158:                }
159:
160:                initValues(null, null);
161:
162:                this .browseButton.addActionListener(this );
163:                this .locationComboBox.addActionListener(this );
164:                this .documentNameTextField.getDocument().addDocumentListener(
165:                        this );
166:                this .folderTextField.getDocument().addDocumentListener(this );
167:
168:                this .setName(NbBundle.getMessage(
169:                        SimpleTargetChooserPanelGUI.class,
170:                        "LBL_SimpleTargetChooserPanel_Name")); // NOI18N
171:            }
172:
173:            /**
174:             * DOCUMENT ME!
175:             * 
176:             * @param template DOCUMENT ME!
177:             * @param preselectedFolder DOCUMENT ME!
178:             */
179:            public void initValues(FileObject template,
180:                    FileObject preselectedFolder) {
181:                assert project != null;
182:
183:                projectTextField.setText(ProjectUtils.getInformation(project)
184:                        .getDisplayName());
185:
186:                Sources sources = ProjectUtils.getSources(project);
187:
188:                folders = sources.getSourceGroups(Sources.TYPE_GENERIC);
189:
190:                if ((folders == null) || (folders.length < 1)) {
191:                    folders = sources.getSourceGroups(Sources.TYPE_GENERIC);
192:                }
193:
194:                if (folders.length < 2) {
195:                    // one source group i.e. hide Location
196:                    locationLabel.setVisible(false);
197:                    locationComboBox.setVisible(false);
198:                } else {
199:                    // more source groups user needs to select location
200:                    locationLabel.setVisible(true);
201:                    locationComboBox.setVisible(true);
202:                }
203:
204:                locationComboBox.setModel(new DefaultComboBoxModel(folders));
205:
206:                // Guess the group we want to create the file in
207:                SourceGroup preselectedGroup = getPreselectedGroup(folders,
208:                        preselectedFolder);
209:                locationComboBox.setSelectedItem(preselectedGroup);
210:
211:                // Create OS dependent relative name
212:                folderTextField.setText(getRelativeNativeName(preselectedGroup
213:                        .getRootFolder(), preselectedFolder));
214:
215:                mFolderRoot = preselectedFolder;
216:                /*
217:                 * mFolderText = ( getRelativeNativeName( preselectedGroup.getRootFolder(),
218:                 * preselectedFolder ) ); folderTextField.setText("");
219:                 */
220:                String ext = (template == null) ? "" : template.getExt(); // NOI18N
221:                expectedExtension = (ext.length() == 0) ? "" : ("." + ext); // NOI18N
222:
223:                String displayName = null;
224:
225:                try {
226:                    if (template != null) {
227:                        DataObject templateDo = DataObject.find(template);
228:                        displayName = templateDo.getNodeDelegate()
229:                                .getDisplayName();
230:                    }
231:                } catch (DataObjectNotFoundException ex) {
232:                    displayName = template.getName();
233:                }
234:
235:                putClientProperty("NewDtelWizard_Title", displayName); // NOI18N
236:
237:                if (template != null) {
238:                    documentNameTextField.setText(NEW_FILE_PREFIX
239:                            + template.getName());
240:                    documentNameTextField.selectAll();
241:                }
242:
243:                if (isFolder) {
244:                    jLabel3.setText(NbBundle.getMessage(
245:                            SimpleTargetChooserPanelGUI.class,
246:                            "LBL_TargetChooser_FolderName_Label")); // NOI18N
247:                    jLabel3.setDisplayedMnemonic(NbBundle.getMessage(
248:                            SimpleTargetChooserPanelGUI.class,
249:                            "MNE_TargetChooser_FolderName_Label").charAt(0)); // NOI18N
250:                    jLabel2.setText(NbBundle.getMessage(
251:                            SimpleTargetChooserPanelGUI.class,
252:                            "LBL_TargetChooser_ParentFolder_Label")); // NOI18N
253:                    jLabel2.setDisplayedMnemonic(NbBundle.getMessage(
254:                            SimpleTargetChooserPanelGUI.class,
255:                            "MNE_TargetChooser_ParentFolder_Label").charAt(0)); // NOI18N
256:                    jLabel4.setText(NbBundle.getMessage(
257:                            SimpleTargetChooserPanelGUI.class,
258:                            "LBL_TargetChooser_CreatedFolder_Label")); // NOI18N
259:                    jLabel4.setDisplayedMnemonic(NbBundle.getMessage(
260:                            SimpleTargetChooserPanelGUI.class,
261:                            "MNE_TargetChooser_CreatedFolder_Label").charAt(0)); // NOI18N
262:                } else {
263:                    jLabel3.setText(NbBundle.getMessage(
264:                            SimpleTargetChooserPanelGUI.class,
265:                            "LBL_TargetChooser_FileName_Label")); // NOI18N
266:                    jLabel2.setText(NbBundle.getMessage(
267:                            SimpleTargetChooserPanelGUI.class,
268:                            "LBL_TargetChooser_Folder_Label")); // NOI18N
269:                    jLabel4.setText(NbBundle.getMessage(
270:                            SimpleTargetChooserPanelGUI.class,
271:                            "LBL_TargetChooser_CreatedFile_Label")); // NOI18N
272:                    jLabel3.setDisplayedMnemonic(NbBundle.getMessage(
273:                            SimpleTargetChooserPanelGUI.class,
274:                            "MNE_TargetChooser_FileName_Label").charAt(0)); // NOI18N
275:                    jLabel2.setDisplayedMnemonic(NbBundle.getMessage(
276:                            SimpleTargetChooserPanelGUI.class,
277:                            "MNE_TargetChooser_Folder_Label").charAt(0)); // NOI18N
278:                    jLabel4.setDisplayedMnemonic(NbBundle.getMessage(
279:                            SimpleTargetChooserPanelGUI.class,
280:                            "MNE_TargetChooser_CreatedFile_Label").charAt(0)); // NOI18N
281:                }
282:            }
283:
284:            /**
285:             * DOCUMENT ME!
286:             * 
287:             * @return DOCUMENT ME!
288:             */
289:            public SourceGroup getTargetGroup() {
290:                return (SourceGroup) this .locationComboBox.getSelectedItem();
291:            }
292:
293:            /**
294:             * DOCUMENT ME!
295:             * 
296:             * @return DOCUMENT ME!
297:             */
298:            public String getTargetFolder() {
299:                /*
300:                 * String fName = folderTextField.getText().trim(); String folderName = mFolderText + (
301:                 * fName.startsWith("/") || fName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
302:                 * fName; // folderTextField.getText().trim();
303:                 */
304:                final String folderName = this .folderTextField.getText().trim();
305:
306:                if (folderName.length() == 0) {
307:                    return null;
308:                } else {
309:                    return folderName.replace(File.separatorChar, '/'); // NOI18N
310:                }
311:            }
312:
313:            /**
314:             * DOCUMENT ME!
315:             * 
316:             * @return DOCUMENT ME!
317:             */
318:            public String getTargetName() {
319:                final String text = this .documentNameTextField.getText().trim();
320:
321:                if (text.length() == 0) {
322:                    return null;
323:                } else {
324:                    return text;
325:                }
326:            }
327:
328:            /**
329:             * DOCUMENT ME!
330:             * 
331:             * @return DOCUMENT ME!
332:             */
333:            public java.awt.Dimension getPreferredSize() {
334:                return SimpleTargetChooserPanelGUI.PREF_DIM;
335:            }
336:
337:            /**
338:             * DOCUMENT ME!
339:             * 
340:             * @param l DOCUMENT ME!
341:             */
342:            public synchronized void addChangeListener(final ChangeListener l) {
343:                this .listeners.add(l);
344:            }
345:
346:            /**
347:             * DOCUMENT ME!
348:             * 
349:             * @param l DOCUMENT ME!
350:             */
351:            public synchronized void removeChangeListener(final ChangeListener l) {
352:                this .listeners.remove(l);
353:            }
354:
355:            private void fireChange() {
356:                final ChangeEvent e = new ChangeEvent(this );
357:                List templist;
358:
359:                synchronized (this ) {
360:                    templist = new ArrayList(this .listeners);
361:                }
362:
363:                final Iterator it = templist.iterator();
364:
365:                while (it.hasNext()) {
366:                    ((ChangeListener) it.next()).stateChanged(e);
367:                }
368:            }
369:
370:            /**
371:             * This method is called from within the constructor to initialize the form. WARNING: Do NOT
372:             * modify this code. The content of this method is always regenerated by the Form Editor.
373:             */
374:            private void initComponents() {// GEN-BEGIN:initComponents
375:
376:                java.awt.GridBagConstraints gridBagConstraints;
377:
378:                this .jPanel1 = new javax.swing.JPanel();
379:                this .jLabel3 = new javax.swing.JLabel();
380:                this .documentNameTextField = new javax.swing.JTextField();
381:                this .jLabel1 = new javax.swing.JLabel();
382:                this .projectTextField = new javax.swing.JTextField();
383:                this .locationLabel = new javax.swing.JLabel();
384:                this .locationComboBox = new javax.swing.JComboBox();
385:                this .jLabel2 = new javax.swing.JLabel();
386:                this .folderTextField = new javax.swing.JTextField();
387:                this .browseButton = new javax.swing.JButton();
388:                this .jLabel4 = new javax.swing.JLabel();
389:                this .fileTextField = new javax.swing.JTextField();
390:                this .targetSeparator = new javax.swing.JSeparator();
391:                this .bottomPanelContainer = new javax.swing.JPanel();
392:
393:                this .setLayout(new java.awt.GridBagLayout());
394:
395:                this .getAccessibleContext().setAccessibleDescription(
396:                        org.openide.util.NbBundle.getBundle(
397:                                SimpleTargetChooserPanelGUI.class).getString(
398:                                "AD_SimpleTargetChooserPanelGUI"));
399:                this .jPanel1.setLayout(new java.awt.GridBagLayout());
400:
401:                this .jLabel3.setDisplayedMnemonic(org.openide.util.NbBundle
402:                        .getMessage(SimpleTargetChooserPanelGUI.class,
403:                                "MNE_TargetChooser_FileName_Label").charAt(0));
404:                this .jLabel3.setLabelFor(this .documentNameTextField);
405:                this .jLabel3.setText(org.openide.util.NbBundle.getMessage(
406:                        SimpleTargetChooserPanelGUI.class,
407:                        "LBL_TargetChooser_FileName_Label"));
408:                gridBagConstraints = new java.awt.GridBagConstraints();
409:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
410:                this .jPanel1.add(this .jLabel3, gridBagConstraints);
411:
412:                gridBagConstraints = new java.awt.GridBagConstraints();
413:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
414:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
415:                gridBagConstraints.weightx = 1.0;
416:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
417:                this .jPanel1
418:                        .add(this .documentNameTextField, gridBagConstraints);
419:                this .documentNameTextField.getAccessibleContext()
420:                        .setAccessibleDescription(
421:                                org.openide.util.NbBundle.getBundle(
422:                                        SimpleTargetChooserPanelGUI.class)
423:                                        .getString("AD_documentNameTextField"));
424:
425:                gridBagConstraints = new java.awt.GridBagConstraints();
426:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
427:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
428:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 24, 0);
429:                this .add(this .jPanel1, gridBagConstraints);
430:
431:                this .jLabel1.setDisplayedMnemonic(org.openide.util.NbBundle
432:                        .getMessage(SimpleTargetChooserPanelGUI.class,
433:                                "MNE_TargetChooser_Project_Label").charAt(0));
434:                this .jLabel1.setText(org.openide.util.NbBundle.getMessage(
435:                        SimpleTargetChooserPanelGUI.class,
436:                        "LBL_TargetChooser_Project_Label"));
437:                this .jLabel1.setLabelFor(this .projectTextField);
438:                gridBagConstraints = new java.awt.GridBagConstraints();
439:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
440:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
441:                this .add(this .jLabel1, gridBagConstraints);
442:
443:                this .projectTextField.setEditable(false);
444:                gridBagConstraints = new java.awt.GridBagConstraints();
445:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
446:                gridBagConstraints.weightx = 1.0;
447:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 0);
448:                this .add(this .projectTextField, gridBagConstraints);
449:                this .projectTextField.getAccessibleContext()
450:                        .setAccessibleDescription(
451:                                org.openide.util.NbBundle.getBundle(
452:                                        SimpleTargetChooserPanelGUI.class)
453:                                        .getString("AD_projectTextField"));
454:
455:                this .locationLabel
456:                        .setDisplayedMnemonic(org.openide.util.NbBundle
457:                                .getMessage(SimpleTargetChooserPanelGUI.class,
458:                                        "MNE_TargetChooser_Location_Label")
459:                                .charAt(0));
460:                this .locationLabel.setLabelFor(this .locationComboBox);
461:                this .locationLabel.setText(org.openide.util.NbBundle
462:                        .getMessage(SimpleTargetChooserPanelGUI.class,
463:                                "LBL_TargetChooser_Location_Label"));
464:                gridBagConstraints = new java.awt.GridBagConstraints();
465:                gridBagConstraints.gridy = 2;
466:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
467:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
468:                this .add(this .locationLabel, gridBagConstraints);
469:
470:                gridBagConstraints = new java.awt.GridBagConstraints();
471:                gridBagConstraints.gridy = 2;
472:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
473:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
474:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
475:                this .add(this .locationComboBox, gridBagConstraints);
476:                this .locationComboBox.getAccessibleContext()
477:                        .setAccessibleDescription(
478:                                org.openide.util.NbBundle.getBundle(
479:                                        SimpleTargetChooserPanelGUI.class)
480:                                        .getString("AD_locationComboBox"));
481:
482:                this .jLabel2.setDisplayedMnemonic(org.openide.util.NbBundle
483:                        .getMessage(SimpleTargetChooserPanelGUI.class,
484:                                "MNE_TargetChooser_ParentFolder_Label").charAt(
485:                                0));
486:                this .jLabel2.setLabelFor(this .folderTextField);
487:                this .jLabel2.setText(org.openide.util.NbBundle.getMessage(
488:                        SimpleTargetChooserPanelGUI.class,
489:                        "LBL_TargetChooser_Folder_Label"));
490:                gridBagConstraints = new java.awt.GridBagConstraints();
491:                gridBagConstraints.gridx = 0;
492:                gridBagConstraints.gridy = 3;
493:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
494:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
495:                this .add(this .jLabel2, gridBagConstraints);
496:
497:                gridBagConstraints = new java.awt.GridBagConstraints();
498:                gridBagConstraints.gridy = 3;
499:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
500:                gridBagConstraints.weightx = 1.0;
501:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
502:                this .add(this .folderTextField, gridBagConstraints);
503:                this .folderTextField.getAccessibleContext()
504:                        .setAccessibleDescription(
505:                                org.openide.util.NbBundle.getBundle(
506:                                        SimpleTargetChooserPanelGUI.class)
507:                                        .getString("AD_folderTextField"));
508:
509:                this .browseButton.setMnemonic(org.openide.util.NbBundle
510:                        .getMessage(SimpleTargetChooserPanelGUI.class,
511:                                "MNE_TargetChooser_Browse_Button").charAt(0));
512:                this .browseButton.setText(org.openide.util.NbBundle.getMessage(
513:                        SimpleTargetChooserPanelGUI.class,
514:                        "LBL_TargetChooser_Browse_Button"));
515:                gridBagConstraints = new java.awt.GridBagConstraints();
516:                gridBagConstraints.gridy = 3;
517:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
518:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
519:                this .add(this .browseButton, gridBagConstraints);
520:                this .browseButton.getAccessibleContext()
521:                        .setAccessibleDescription(
522:                                org.openide.util.NbBundle.getBundle(
523:                                        SimpleTargetChooserPanelGUI.class)
524:                                        .getString("AD_browseButton"));
525:
526:                this .jLabel4.setDisplayedMnemonic(org.openide.util.NbBundle
527:                        .getMessage(SimpleTargetChooserPanelGUI.class,
528:                                "MNE_TargetChooser_CreatedFile_Label")
529:                        .charAt(0));
530:                this .jLabel4.setText(org.openide.util.NbBundle.getMessage(
531:                        SimpleTargetChooserPanelGUI.class,
532:                        "LBL_TargetChooser_CreatedFile_Label"));
533:                this .jLabel4.setLabelFor(this .fileTextField);
534:                gridBagConstraints = new java.awt.GridBagConstraints();
535:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
536:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
537:                this .add(this .jLabel4, gridBagConstraints);
538:
539:                this .fileTextField.setEditable(false);
540:                gridBagConstraints = new java.awt.GridBagConstraints();
541:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
542:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
543:                gridBagConstraints.weightx = 1.0;
544:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
545:                this .add(this .fileTextField, gridBagConstraints);
546:                this .fileTextField.getAccessibleContext()
547:                        .setAccessibleDescription(
548:                                org.openide.util.NbBundle.getBundle(
549:                                        SimpleTargetChooserPanelGUI.class)
550:                                        .getString("AD_fileTextField"));
551:
552:                gridBagConstraints = new java.awt.GridBagConstraints();
553:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
554:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
555:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
556:                this .add(this .targetSeparator, gridBagConstraints);
557:
558:                this .bottomPanelContainer
559:                        .setLayout(new java.awt.BorderLayout());
560:
561:                gridBagConstraints = new java.awt.GridBagConstraints();
562:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
563:                gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
564:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
565:                gridBagConstraints.weighty = 1.0;
566:                this .add(this .bottomPanelContainer, gridBagConstraints);
567:            }// GEN-END:initComponents
568:
569:            // End of variables declaration
570:            private SourceGroup getPreselectedGroup(SourceGroup[] groups,
571:                    FileObject folder) {
572:                for (int i = 0; folder != null && i < groups.length; i++) {
573:                    if (FileUtil.isParentOf(groups[i].getRootFolder(), folder)) {
574:                        return groups[i];
575:                    }
576:                }
577:
578:                return groups[0];
579:            }
580:
581:            private String getRelativeNativeName(FileObject root,
582:                    FileObject folder) {
583:                if (root == null) {
584:                    throw new IllegalArgumentException(
585:                            "null root passed to getRelativeNativeName"); // NOI18N
586:                }
587:
588:                String path;
589:
590:                if (folder == null) {
591:                    path = ""; // NOI18N
592:                } else {
593:                    path = FileUtil.getRelativePath(root, folder);
594:                }
595:
596:                return path == null ? "" : path
597:                        .replace('/', File.separatorChar); // NOI18N
598:            }
599:
600:            private void updateCreatedFolder() {
601:                FileObject root = ((SourceGroup) this .locationComboBox
602:                        .getSelectedItem()).getRootFolder();
603:
604:                final String folderName = this .folderTextField.getText().trim();
605:                final String documentName = this .documentNameTextField
606:                        .getText().trim();
607:
608:                final String createdFileName = FileUtil
609:                        .getFileDisplayName(root)
610:                        +
611:                        /*
612:                         * ( mFolderText.startsWith("/") || mFolderText.startsWith( File.separator ) ? "" : "/" ) + //
613:                         * NOI18N mFolderText +
614:                         */
615:                        (folderName.startsWith("/")
616:                                || folderName.startsWith(File.separator) ? ""
617:                                : "/")
618:                        + // NOI18N
619:                        folderName
620:                        + (folderName.endsWith("/")
621:                                || folderName.endsWith(File.separator)
622:                                || folderName.length() == 0 ? "" : "/") + // NOI18N
623:                        documentName + this .expectedExtension;
624:
625:                this .fileTextField.setText(createdFileName.replace('/',
626:                        File.separatorChar)); // NOI18N
627:
628:                this .fireChange();
629:            }
630:
631:            // ActionListener implementation -------------------------------------------
632:            public void actionPerformed(final java.awt.event.ActionEvent e) {
633:                if (this .browseButton == e.getSource()) {
634:                    FileObject fo = null;
635:
636:                    // Show the browse dialog
637:                    SourceGroup group = (SourceGroup) this .locationComboBox
638:                            .getSelectedItem();
639:
640:                    fo = BrowseFolders.showDialog(new SourceGroup[] { group },
641:                            project, this .folderTextField.getText().replace(
642:                                    File.separatorChar, '/')); // NOI18N
643:
644:                    if (fo != null && fo.isFolder()) {
645:                        final String relPath = FileUtil.getRelativePath(group
646:                                .getRootFolder(), fo);
647:                        this .folderTextField.setText(relPath.replace('/',
648:                                File.separatorChar)); // NOI18N
649:                    }
650:                } else if (this .locationComboBox == e.getSource()) {
651:                    this .updateCreatedFolder();
652:                }
653:            }
654:
655:            // DocumentListener implementation -----------------------------------------
656:            public void changedUpdate(final javax.swing.event.DocumentEvent e) {
657:                this .updateCreatedFolder();
658:            }
659:
660:            /**
661:             * DOCUMENT ME!
662:             * 
663:             * @param e DOCUMENT ME!
664:             */
665:            public void insertUpdate(final javax.swing.event.DocumentEvent e) {
666:                this .updateCreatedFolder();
667:            }
668:
669:            /**
670:             * DOCUMENT ME!
671:             * 
672:             * @param e DOCUMENT ME!
673:             */
674:            public void removeUpdate(final javax.swing.event.DocumentEvent e) {
675:                this .updateCreatedFolder();
676:            }
677:
678:            // Rendering of the location combo box -------------------------------------
679:            private class GroupCellRenderer extends JLabel implements 
680:                    ListCellRenderer {
681:                /**
682:                 * 
683:                 */
684:                private static final long serialVersionUID = 1L;
685:
686:                /**
687:                 * Creates a new GroupCellRenderer object.
688:                 */
689:                public GroupCellRenderer() {
690:                    this .setOpaque(true);
691:                }
692:
693:                /**
694:                 * DOCUMENT ME!
695:                 * 
696:                 * @param list DOCUMENT ME!
697:                 * @param value DOCUMENT ME!
698:                 * @param index DOCUMENT ME!
699:                 * @param isSelected DOCUMENT ME!
700:                 * @param cellHasFocus DOCUMENT ME!
701:                 * @return DOCUMENT ME!
702:                 */
703:                public Component getListCellRendererComponent(final JList list,
704:                        final Object value, final int index,
705:                        final boolean isSelected, final boolean cellHasFocus) {
706:                    if (value instanceof  SourceGroup) {
707:                        SourceGroup group = (SourceGroup) value;
708:                        final String projectDisplayName = ProjectUtils
709:                                .getInformation(project).getDisplayName();
710:                        final String groupDisplayName = group.getDisplayName();
711:
712:                        if (projectDisplayName.equals(groupDisplayName)) {
713:                            this .setText(groupDisplayName);
714:                        } else {
715:                            /*
716:                             * setText( MessageFormat.format(
717:                             * org.netbeans.modules.project.ui.PhysicalView.GroupNode.GROUP_NAME_PATTERN,
718:                             * new Object[] { groupDisplayName, projectDisplayName,
719:                             * group.getRootFolder().getName() } ) );
720:                             */
721:                            this 
722:                                    .setText(MessageFormat
723:                                            .format(
724:                                                    NbBundle
725:                                                            .getMessage(
726:                                                                    SimpleTargetChooserPanelGUI.class,
727:                                                                    "FMT_TargetChooser_GroupProjectNameBadge"), // NOI18N
728:                                                    new Object[] {
729:                                                            groupDisplayName,
730:                                                            projectDisplayName }));
731:                        }
732:
733:                        this .setIcon(group.getIcon(false));
734:                    } else {
735:                        this.setText(value.toString());
736:                        this.setIcon(null);
737:                    }
738:
739:                    if (isSelected) {
740:                        this.setBackground(list.getSelectionBackground());
741:                        this.setForeground(list.getSelectionForeground());
742:                    } else {
743:                        this.setBackground(list.getBackground());
744:                        this.setForeground(list.getForeground());
745:                    }
746:
747:                    return this;
748:                }
749:            }
750:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.