Source Code Cross Referenced for SimpleTargetChooserPanelGUI.java in  » IDE-Netbeans » compapp » org » netbeans » modules » compapp » projects » wizard » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » compapp » org.netbeans.modules.compapp.projects.wizard 
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:        package org.netbeans.modules.compapp.projects.wizard;
021:
022:        import java.awt.Component;
023:        import java.awt.event.ActionListener;
024:        import java.io.File;
025:        import java.text.MessageFormat;
026:        import java.util.ArrayList;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import javax.swing.DefaultComboBoxModel;
030:        import javax.swing.JLabel;
031:        import javax.swing.JList;
032:        import javax.swing.ListCellRenderer;
033:        import javax.swing.event.ChangeEvent;
034:        import javax.swing.event.ChangeListener;
035:        import javax.swing.event.DocumentListener;
036:        import org.netbeans.api.project.Project;
037:        import org.netbeans.api.project.ProjectUtils;
038:        import org.netbeans.api.project.SourceGroup;
039:        import org.netbeans.api.project.Sources;
040:        import org.netbeans.spi.project.support.GenericSources;
041:        import org.openide.filesystems.FileObject;
042:        import org.openide.filesystems.FileUtil;
043:        import org.openide.loaders.DataObject;
044:        import org.openide.loaders.DataObjectNotFoundException;
045:        import org.openide.util.NbBundle;
046:
047:        /**
048:         *
049:         * @author  Tientien Li
050:         */
051:        public class SimpleTargetChooserPanelGUI extends javax.swing.JPanel
052:                implements  ActionListener, DocumentListener {
053:
054:            /** prefered dimmension of the panels */
055:            private static final java.awt.Dimension PREF_DIM = new java.awt.Dimension(
056:                    500, 340);
057:
058:            private static final String NEW_FILE_PREFIX = NbBundle.getMessage(
059:                    SimpleTargetChooserPanelGUI.class,
060:                    "LBL_SimpleTargetChooserPanelGUI_NewFilePrefix"); // NOI18N
061:
062:            private final ListCellRenderer CELL_RENDERER = new GroupCellRenderer();
063:
064:            private Project project;
065:            private String expectedExtension;
066:            private final List/*<ChangeListener>*/listeners = new ArrayList();
067:            private SourceGroup[] folders;
068:            private boolean isFolder;
069:
070:            private FileObject mFolderRoot = null;
071:            private String mFolderText = "";
072:
073:            /** Creates new form SimpleTargetChooserGUI */
074:            public SimpleTargetChooserPanelGUI(Project project,
075:                    SourceGroup[] folders, Component bottomPanel,
076:                    boolean isFolder) {
077:                this .project = project;
078:                this .folders = folders;
079:                this .isFolder = isFolder;
080:                initComponents();
081:
082:                locationComboBox.setRenderer(CELL_RENDERER);
083:
084:                if (bottomPanel != null) {
085:                    bottomPanelContainer.add(bottomPanel,
086:                            java.awt.BorderLayout.CENTER);
087:                }
088:                initValues(null, null);
089:
090:                browseButton.addActionListener(this );
091:                locationComboBox.addActionListener(this );
092:                documentNameTextField.getDocument().addDocumentListener(this );
093:                folderTextField.getDocument().addDocumentListener(this );
094:
095:                setName(NbBundle.getMessage(SimpleTargetChooserPanelGUI.class,
096:                        "LBL_SimpleTargetChooserPanel_Name")); // NOI18N
097:            }
098:
099:            public void initValues(FileObject template,
100:                    FileObject preselectedFolder) {
101:                assert project != null;
102:
103:                projectTextField.setText(ProjectUtils.getInformation(project)
104:                        .getDisplayName());
105:
106:                Sources sources = ProjectUtils.getSources(project);
107:
108:                folders = sources
109:                        .getSourceGroups(NewFileIterator.SOURCE_TYPE_BIZPRO /* Sources.TYPE_GENERIC */);
110:                if ((folders == null) || (folders.length < 1)) {
111:                    folders = sources.getSourceGroups(Sources.TYPE_GENERIC);
112:                }
113:
114:                if (folders.length < 2) {
115:                    // one source group i.e. hide Location
116:                    locationLabel.setVisible(false);
117:                    locationComboBox.setVisible(false);
118:                } else {
119:                    // more source groups user needs to select location
120:                    locationLabel.setVisible(true);
121:                    locationComboBox.setVisible(true);
122:
123:                }
124:
125:                locationComboBox.setModel(new DefaultComboBoxModel(folders));
126:                // Guess the group we want to create the file in
127:                SourceGroup preselectedGroup = getPreselectedGroup(folders,
128:                        preselectedFolder);
129:                locationComboBox.setSelectedItem(preselectedGroup);
130:                // Create OS dependent relative name
131:                folderTextField.setText(getRelativeNativeName(preselectedGroup
132:                        .getRootFolder(), preselectedFolder));
133:                /*
134:                mFolderRoot = preselectedFolder;
135:                mFolderText = ( getRelativeNativeName( preselectedGroup.getRootFolder(), preselectedFolder ) );
136:                folderTextField.setText("");
137:                 */
138:                String ext = template == null ? "" : template.getExt(); // NOI18N
139:                expectedExtension = ext.length() == 0 ? "" : "." + ext; // NOI18N
140:
141:                String displayName = null;
142:                try {
143:                    if (template != null) {
144:                        DataObject templateDo = DataObject.find(template);
145:                        displayName = templateDo.getNodeDelegate()
146:                                .getDisplayName();
147:                    }
148:                } catch (DataObjectNotFoundException ex) {
149:                    displayName = template.getName();
150:                }
151:                putClientProperty("NewFileWizard_Title", displayName);// NOI18N
152:
153:                if (template != null) {
154:                    documentNameTextField.setText(NEW_FILE_PREFIX
155:                            + template.getName());
156:                    documentNameTextField.selectAll();
157:                }
158:
159:                if (isFolder) {
160:                    jLabel3.setText(NbBundle.getMessage(
161:                            SimpleTargetChooserPanelGUI.class,
162:                            "LBL_TargetChooser_FolderName_Label")); // NOI18N
163:                    jLabel3.setDisplayedMnemonic(NbBundle.getMessage(
164:                            SimpleTargetChooserPanelGUI.class,
165:                            "MNE_TargetChooser_FolderName_Label").charAt(0)); // NOI18N
166:                    jLabel2.setText(NbBundle.getMessage(
167:                            SimpleTargetChooserPanelGUI.class,
168:                            "LBL_TargetChooser_ParentFolder_Label")); // NOI18N
169:                    jLabel2.setDisplayedMnemonic(NbBundle.getMessage(
170:                            SimpleTargetChooserPanelGUI.class,
171:                            "MNE_TargetChooser_ParentFolder_Label").charAt(0)); // NOI18N
172:                    jLabel4.setText(NbBundle.getMessage(
173:                            SimpleTargetChooserPanelGUI.class,
174:                            "LBL_TargetChooser_CreatedFolder_Label")); // NOI18N
175:                    jLabel4.setDisplayedMnemonic(NbBundle.getMessage(
176:                            SimpleTargetChooserPanelGUI.class,
177:                            "MNE_TargetChooser_CreatedFolder_Label").charAt(0)); // NOI18N
178:                } else {
179:                    jLabel3.setText(NbBundle.getMessage(
180:                            SimpleTargetChooserPanelGUI.class,
181:                            "LBL_TargetChooser_FileName_Label")); // NOI18N
182:                    jLabel2.setText(NbBundle.getMessage(
183:                            SimpleTargetChooserPanelGUI.class,
184:                            "LBL_TargetChooser_Folder_Label")); // NOI18N
185:                    jLabel4.setText(NbBundle.getMessage(
186:                            SimpleTargetChooserPanelGUI.class,
187:                            "LBL_TargetChooser_CreatedFile_Label")); // NOI18N
188:                    jLabel3.setDisplayedMnemonic(NbBundle.getMessage(
189:                            SimpleTargetChooserPanelGUI.class,
190:                            "MNE_TargetChooser_FileName_Label").charAt(0)); // NOI18N
191:                    jLabel2.setDisplayedMnemonic(NbBundle.getMessage(
192:                            SimpleTargetChooserPanelGUI.class,
193:                            "MNE_TargetChooser_Folder_Label").charAt(0)); // NOI18N
194:                    jLabel4.setDisplayedMnemonic(NbBundle.getMessage(
195:                            SimpleTargetChooserPanelGUI.class,
196:                            "MNE_TargetChooser_CreatedFile_Label").charAt(0)); // NOI18N
197:                }
198:            }
199:
200:            public SourceGroup getTargetGroup() {
201:                return (SourceGroup) locationComboBox.getSelectedItem();
202:            }
203:
204:            public String getTargetFolder() {
205:                /*
206:                String fName = folderTextField.getText().trim();
207:
208:                String folderName = mFolderText +
209:                            ( fName.startsWith("/") || fName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
210:                            fName; // folderTextField.getText().trim();
211:                 */
212:                String folderName = folderTextField.getText().trim();
213:
214:                if (folderName.length() == 0) {
215:                    return null;
216:                } else {
217:                    return folderName.replace(File.separatorChar, '/'); // NOI18N
218:                }
219:            }
220:
221:            public String getTargetName() {
222:
223:                String text = documentNameTextField.getText().trim();
224:
225:                if (text.length() == 0) {
226:                    return null;
227:                } else {
228:                    return text;
229:                }
230:            }
231:
232:            public java.awt.Dimension getPreferredSize() {
233:                return PREF_DIM;
234:            }
235:
236:            public synchronized void addChangeListener(ChangeListener l) {
237:                listeners.add(l);
238:            }
239:
240:            public synchronized void removeChangeListener(ChangeListener l) {
241:                listeners.remove(l);
242:            }
243:
244:            private void fireChange() {
245:                ChangeEvent e = new ChangeEvent(this );
246:                List templist;
247:                synchronized (this ) {
248:                    templist = new ArrayList(listeners);
249:                }
250:                Iterator it = templist.iterator();
251:                while (it.hasNext()) {
252:                    ((ChangeListener) it.next()).stateChanged(e);
253:                }
254:            }
255:
256:            /** This method is called from within the constructor to
257:             * initialize the form.
258:             * WARNING: Do NOT modify this code. The content of this method is
259:             * always regenerated by the Form Editor.
260:             */
261:            private void initComponents() {//GEN-BEGIN:initComponents
262:                java.awt.GridBagConstraints gridBagConstraints;
263:
264:                jPanel1 = new javax.swing.JPanel();
265:                jLabel3 = new javax.swing.JLabel();
266:                documentNameTextField = new javax.swing.JTextField();
267:                jLabel1 = new javax.swing.JLabel();
268:                projectTextField = new javax.swing.JTextField();
269:                locationLabel = new javax.swing.JLabel();
270:                locationComboBox = new javax.swing.JComboBox();
271:                jLabel2 = new javax.swing.JLabel();
272:                folderTextField = new javax.swing.JTextField();
273:                browseButton = new javax.swing.JButton();
274:                jLabel4 = new javax.swing.JLabel();
275:                fileTextField = new javax.swing.JTextField();
276:                targetSeparator = new javax.swing.JSeparator();
277:                bottomPanelContainer = new javax.swing.JPanel();
278:
279:                setLayout(new java.awt.GridBagLayout());
280:
281:                getAccessibleContext().setAccessibleDescription(
282:                        org.openide.util.NbBundle.getBundle(
283:                                SimpleTargetChooserPanelGUI.class).getString(
284:                                "AD_SimpleTargetChooserPanelGUI"));
285:                jPanel1.setLayout(new java.awt.GridBagLayout());
286:
287:                jLabel3.setDisplayedMnemonic(org.openide.util.NbBundle
288:                        .getMessage(SimpleTargetChooserPanelGUI.class,
289:                                "MNE_TargetChooser_FileName_Label").charAt(0));
290:                jLabel3.setLabelFor(documentNameTextField);
291:                jLabel3.setText(org.openide.util.NbBundle.getMessage(
292:                        SimpleTargetChooserPanelGUI.class,
293:                        "LBL_TargetChooser_FileName_Label"));
294:                gridBagConstraints = new java.awt.GridBagConstraints();
295:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
296:                jPanel1.add(jLabel3, gridBagConstraints);
297:
298:                gridBagConstraints = new java.awt.GridBagConstraints();
299:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
300:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
301:                gridBagConstraints.weightx = 1.0;
302:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
303:                jPanel1.add(documentNameTextField, gridBagConstraints);
304:                documentNameTextField.getAccessibleContext()
305:                        .setAccessibleDescription(
306:                                org.openide.util.NbBundle.getBundle(
307:                                        SimpleTargetChooserPanelGUI.class)
308:                                        .getString("AD_documentNameTextField"));
309:
310:                gridBagConstraints = new java.awt.GridBagConstraints();
311:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
312:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
313:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 24, 0);
314:                add(jPanel1, gridBagConstraints);
315:
316:                jLabel1.setDisplayedMnemonic(org.openide.util.NbBundle
317:                        .getMessage(SimpleTargetChooserPanelGUI.class,
318:                                "MNE_TargetChooser_Project_Label").charAt(0));
319:                jLabel1.setText(org.openide.util.NbBundle.getMessage(
320:                        SimpleTargetChooserPanelGUI.class,
321:                        "LBL_TargetChooser_Project_Label"));
322:                jLabel1.setLabelFor(projectTextField);
323:                gridBagConstraints = new java.awt.GridBagConstraints();
324:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
325:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
326:                add(jLabel1, gridBagConstraints);
327:
328:                projectTextField.setEditable(false);
329:                gridBagConstraints = new java.awt.GridBagConstraints();
330:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
331:                gridBagConstraints.weightx = 1.0;
332:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 6, 0);
333:                add(projectTextField, gridBagConstraints);
334:                projectTextField.getAccessibleContext()
335:                        .setAccessibleDescription(
336:                                org.openide.util.NbBundle.getBundle(
337:                                        SimpleTargetChooserPanelGUI.class)
338:                                        .getString("AD_projectTextField"));
339:
340:                locationLabel.setDisplayedMnemonic(org.openide.util.NbBundle
341:                        .getMessage(SimpleTargetChooserPanelGUI.class,
342:                                "MNE_TargetChooser_Location_Label").charAt(0));
343:                locationLabel.setLabelFor(locationComboBox);
344:                locationLabel.setText(org.openide.util.NbBundle.getMessage(
345:                        SimpleTargetChooserPanelGUI.class,
346:                        "LBL_TargetChooser_Location_Label"));
347:                gridBagConstraints = new java.awt.GridBagConstraints();
348:                gridBagConstraints.gridy = 2;
349:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
350:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
351:                add(locationLabel, gridBagConstraints);
352:
353:                gridBagConstraints = new java.awt.GridBagConstraints();
354:                gridBagConstraints.gridy = 2;
355:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
356:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
357:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 0);
358:                add(locationComboBox, gridBagConstraints);
359:                locationComboBox.getAccessibleContext()
360:                        .setAccessibleDescription(
361:                                org.openide.util.NbBundle.getBundle(
362:                                        SimpleTargetChooserPanelGUI.class)
363:                                        .getString("AD_locationComboBox"));
364:
365:                jLabel2.setDisplayedMnemonic(org.openide.util.NbBundle
366:                        .getMessage(SimpleTargetChooserPanelGUI.class,
367:                                "MNE_TargetChooser_ParentFolder_Label").charAt(
368:                                0));
369:                jLabel2.setLabelFor(folderTextField);
370:                jLabel2.setText(org.openide.util.NbBundle.getMessage(
371:                        SimpleTargetChooserPanelGUI.class,
372:                        "LBL_TargetChooser_Folder_Label"));
373:                gridBagConstraints = new java.awt.GridBagConstraints();
374:                gridBagConstraints.gridx = 0;
375:                gridBagConstraints.gridy = 3;
376:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
377:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
378:                add(jLabel2, gridBagConstraints);
379:
380:                gridBagConstraints = new java.awt.GridBagConstraints();
381:                gridBagConstraints.gridy = 3;
382:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
383:                gridBagConstraints.weightx = 1.0;
384:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
385:                add(folderTextField, gridBagConstraints);
386:                folderTextField.getAccessibleContext()
387:                        .setAccessibleDescription(
388:                                org.openide.util.NbBundle.getBundle(
389:                                        SimpleTargetChooserPanelGUI.class)
390:                                        .getString("AD_folderTextField"));
391:
392:                browseButton.setMnemonic(org.openide.util.NbBundle.getMessage(
393:                        SimpleTargetChooserPanelGUI.class,
394:                        "MNE_TargetChooser_Browse_Button").charAt(0));
395:                browseButton.setText(org.openide.util.NbBundle.getMessage(
396:                        SimpleTargetChooserPanelGUI.class,
397:                        "LBL_TargetChooser_Browse_Button"));
398:                gridBagConstraints = new java.awt.GridBagConstraints();
399:                gridBagConstraints.gridy = 3;
400:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
401:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
402:                add(browseButton, gridBagConstraints);
403:                browseButton.getAccessibleContext().setAccessibleDescription(
404:                        org.openide.util.NbBundle.getBundle(
405:                                SimpleTargetChooserPanelGUI.class).getString(
406:                                "AD_browseButton"));
407:
408:                jLabel4.setDisplayedMnemonic(org.openide.util.NbBundle
409:                        .getMessage(SimpleTargetChooserPanelGUI.class,
410:                                "MNE_TargetChooser_CreatedFile_Label")
411:                        .charAt(0));
412:                jLabel4.setText(org.openide.util.NbBundle.getMessage(
413:                        SimpleTargetChooserPanelGUI.class,
414:                        "LBL_TargetChooser_CreatedFile_Label"));
415:                jLabel4.setLabelFor(fileTextField);
416:                gridBagConstraints = new java.awt.GridBagConstraints();
417:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
418:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
419:                add(jLabel4, gridBagConstraints);
420:
421:                fileTextField.setEditable(false);
422:                gridBagConstraints = new java.awt.GridBagConstraints();
423:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
424:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
425:                gridBagConstraints.weightx = 1.0;
426:                gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 0);
427:                add(fileTextField, gridBagConstraints);
428:                fileTextField.getAccessibleContext().setAccessibleDescription(
429:                        org.openide.util.NbBundle.getBundle(
430:                                SimpleTargetChooserPanelGUI.class).getString(
431:                                "AD_fileTextField"));
432:
433:                gridBagConstraints = new java.awt.GridBagConstraints();
434:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
435:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
436:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
437:                add(targetSeparator, gridBagConstraints);
438:
439:                bottomPanelContainer.setLayout(new java.awt.BorderLayout());
440:
441:                gridBagConstraints = new java.awt.GridBagConstraints();
442:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
443:                gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
444:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
445:                gridBagConstraints.weighty = 1.0;
446:                add(bottomPanelContainer, gridBagConstraints);
447:
448:            }//GEN-END:initComponents
449:
450:            // Variables declaration - do not modify//GEN-BEGIN:variables
451:            private javax.swing.JPanel bottomPanelContainer;
452:            private javax.swing.JButton browseButton;
453:            private javax.swing.JTextField documentNameTextField;
454:            private javax.swing.JTextField fileTextField;
455:            private javax.swing.JTextField folderTextField;
456:            private javax.swing.JLabel jLabel1;
457:            private javax.swing.JLabel jLabel2;
458:            private javax.swing.JLabel jLabel3;
459:            private javax.swing.JLabel jLabel4;
460:            private javax.swing.JPanel jPanel1;
461:            private javax.swing.JComboBox locationComboBox;
462:            private javax.swing.JLabel locationLabel;
463:            private javax.swing.JTextField projectTextField;
464:            private javax.swing.JSeparator targetSeparator;
465:
466:            // End of variables declaration//GEN-END:variables
467:
468:            private SourceGroup getPreselectedGroup(SourceGroup[] groups,
469:                    FileObject folder) {
470:                for (int i = 0; folder != null && i < groups.length; i++) {
471:                    if (FileUtil.isParentOf(groups[i].getRootFolder(), folder)) {
472:                        return groups[i];
473:                    }
474:                }
475:                return groups[0];
476:            }
477:
478:            private String getRelativeNativeName(FileObject root,
479:                    FileObject folder) {
480:                if (root == null) {
481:                    throw new NullPointerException(
482:                            "null root passed to getRelativeNativeName"); // NOI18N
483:                }
484:
485:                String path;
486:
487:                if (folder == null) {
488:                    path = ""; // NOI18N
489:                } else {
490:                    path = FileUtil.getRelativePath(root, folder);
491:                }
492:
493:                return path == null ? "" : path
494:                        .replace('/', File.separatorChar); // NOI18N
495:            }
496:
497:            private void updateCreatedFolder() {
498:
499:                FileObject root = ((SourceGroup) locationComboBox
500:                        .getSelectedItem()).getRootFolder();
501:
502:                String folderName = folderTextField.getText().trim();
503:                String documentName = documentNameTextField.getText().trim();
504:
505:                String createdFileName = FileUtil.getFileDisplayName(root)
506:                        +
507:                        /*
508:                        ( mFolderText.startsWith("/") || mFolderText.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
509:                        mFolderText +
510:                         */
511:                        (folderName.startsWith("/")
512:                                || folderName.startsWith(File.separator) ? ""
513:                                : "/")
514:                        + // NOI18N
515:                        folderName
516:                        + (folderName.endsWith("/")
517:                                || folderName.endsWith(File.separator)
518:                                || folderName.length() == 0 ? "" : "/") + // NOI18N
519:                        documentName + expectedExtension;
520:
521:                fileTextField.setText(createdFileName.replace('/',
522:                        File.separatorChar)); // NOI18N
523:
524:                fireChange();
525:            }
526:
527:            // ActionListener implementation -------------------------------------------
528:
529:            public void actionPerformed(java.awt.event.ActionEvent e) {
530:                if (browseButton == e.getSource()) {
531:                    FileObject fo = null;
532:                    // Show the browse dialog
533:
534:                    SourceGroup group = (SourceGroup) locationComboBox
535:                            .getSelectedItem();
536:
537:                    fo = BrowseFolders.showDialog(new SourceGroup[] { group },
538:                            project, folderTextField.getText().replace(
539:                                    File.separatorChar, '/')); // NOI18N
540:
541:                    if (fo != null && fo.isFolder()) {
542:                        String relPath = FileUtil.getRelativePath(group
543:                                .getRootFolder(), fo);
544:                        folderTextField.setText(relPath.replace('/',
545:                                File.separatorChar)); // NOI18N
546:                    }
547:                } else if (locationComboBox == e.getSource()) {
548:                    updateCreatedFolder();
549:                }
550:            }
551:
552:            // DocumentListener implementation -----------------------------------------
553:
554:            public void changedUpdate(javax.swing.event.DocumentEvent e) {
555:                updateCreatedFolder();
556:            }
557:
558:            public void insertUpdate(javax.swing.event.DocumentEvent e) {
559:                updateCreatedFolder();
560:            }
561:
562:            public void removeUpdate(javax.swing.event.DocumentEvent e) {
563:                updateCreatedFolder();
564:            }
565:
566:            // Rendering of the location combo box -------------------------------------
567:
568:            private class GroupCellRenderer extends JLabel implements 
569:                    ListCellRenderer {
570:
571:                public GroupCellRenderer() {
572:                    setOpaque(true);
573:                }
574:
575:                public Component getListCellRendererComponent(JList list,
576:                        Object value, int index, boolean isSelected,
577:                        boolean cellHasFocus) {
578:                    if (value instanceof  SourceGroup) {
579:                        SourceGroup group = (SourceGroup) value;
580:                        String projectDisplayName = ProjectUtils
581:                                .getInformation(project).getDisplayName();
582:                        String groupDisplayName = group.getDisplayName();
583:                        if (projectDisplayName.equals(groupDisplayName)) {
584:                            setText(groupDisplayName);
585:                        } else {
586:                            /*
587:                            setText( MessageFormat.format( org.netbeans.modules.project.ui.PhysicalView.GroupNode.GROUP_NAME_PATTERN,
588:                                new Object[] { groupDisplayName, projectDisplayName, group.getRootFolder().getName() } ) );
589:                             */
590:                            setText(MessageFormat.format(NbBundle.getMessage(
591:                                    SimpleTargetChooserPanelGUI.class,
592:                                    "FMT_TargetChooser_GroupProjectNameBadge"), // NOI18N
593:                                    new Object[] { groupDisplayName,
594:                                            projectDisplayName }));
595:                        }
596:
597:                        setIcon(group.getIcon(false));
598:                    } else {
599:                        setText(value.toString());
600:                        setIcon(null);
601:                    }
602:                    if (isSelected) {
603:                        setBackground(list.getSelectionBackground());
604:                        setForeground(list.getSelectionForeground());
605:                    } else {
606:                        setBackground(list.getBackground());
607:                        setForeground(list.getForeground());
608:
609:                    }
610:                    return this;
611:                }
612:
613:            }
614:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.