Source Code Cross Referenced for TargetChooserPanelGUI.java in  » IDE-Netbeans » library » org » apache » jmeter » module » 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 » library » org.apache.jmeter.module.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.apache.jmeter.module.wizards;
043:
044:        import java.awt.Color;
045:        import java.awt.TextField;
046:        import java.io.File;
047:        import java.io.IOException;
048:        import javax.swing.BorderFactory;
049:        import javax.swing.JTextField;
050:        import javax.swing.border.Border;
051:        import javax.swing.border.CompoundBorder;
052:        import javax.swing.event.DocumentEvent;
053:        import javax.swing.event.DocumentListener;
054:        import org.netbeans.api.project.Project;
055:        import org.netbeans.api.project.ProjectUtils;
056:        import org.netbeans.api.project.Sources;
057:        import org.netbeans.spi.project.ui.templates.support.Templates;
058:        import org.openide.filesystems.FileObject;
059:        import org.openide.filesystems.FileUtil;
060:        import org.openide.util.Exceptions;
061:        import org.openide.util.NbBundle;
062:
063:        /**
064:         *
065:         * @author  Jaroslav Bachorik
066:         */
067:        public class TargetChooserPanelGUI extends javax.swing.JPanel implements 
068:                DocumentListener {
069:
070:            public void changedUpdate(DocumentEvent e) {
071:                updateTargetFile();
072:            }
073:
074:            public void insertUpdate(DocumentEvent e) {
075:                updateTargetFile();
076:            }
077:
078:            public void removeUpdate(DocumentEvent e) {
079:                updateTargetFile();
080:            }
081:
082:            private static final String JMETER_SCRIPTS_FOLDER = "jmeter";
083:
084:            private Project project;
085:            private TargetChooserPanel wizardPanel;
086:            private FileObject scriptsDir = null;
087:            private String expectedExtension;
088:
089:            /** Creates new form TargetChooserPanelGUI */
090:            public TargetChooserPanelGUI(final TargetChooserPanel wizardPanel,
091:                    Project project) {
092:                try {
093:                    this .wizardPanel = wizardPanel;
094:                    this .project = project;
095:
096:                    initComponents();
097:                    setName(NbBundle.getMessage(TargetChooserPanelGUI.class,
098:                            "TITLE_name_location"));
099:
100:                    scriptsDir = FileUtil.createFolder(project
101:                            .getProjectDirectory(), JMETER_SCRIPTS_FOLDER);
102:                } catch (IOException ex) {
103:                    Exceptions.printStackTrace(ex);
104:                }
105:            }
106:
107:            /** This method is called from within the constructor to
108:             * initialize the form.
109:             * WARNING: Do NOT modify this code. The content of this method is
110:             * always regenerated by the Form Editor.
111:             */
112:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
113:            private void initComponents() {
114:
115:                nameLabel = new javax.swing.JLabel();
116:                documentNameTextField = new javax.swing.JTextField();
117:                projectLabel = new javax.swing.JLabel();
118:                projectTextField = new javax.swing.JTextField();
119:                folderLabel = new javax.swing.JLabel();
120:                folderTextField = new javax.swing.JTextField();
121:                folderTextField.getDocument().addDocumentListener(this );
122:                browseButton = new javax.swing.JButton();
123:                pathLabel = new javax.swing.JLabel();
124:                targetSeparator = new javax.swing.JSeparator();
125:                fileTextField = new javax.swing.JTextField();
126:                documentNameTextField.getDocument().addDocumentListener(this );
127:                fillerPanel = new javax.swing.JPanel();
128:
129:                nameLabel.setText(org.openide.util.NbBundle.getMessage(
130:                        TargetChooserPanelGUI.class,
131:                        "TargetChooserPanelGUI.nameLabel.text")); // NOI18N
132:
133:                projectLabel.setText(org.openide.util.NbBundle.getMessage(
134:                        TargetChooserPanelGUI.class,
135:                        "TargetChooserPanelGUI.projectLabel.text")); // NOI18N
136:
137:                projectTextField.setEditable(false);
138:
139:                folderLabel.setText(org.openide.util.NbBundle.getMessage(
140:                        TargetChooserPanelGUI.class,
141:                        "TargetChooserPanelGUI.folderLabel.text")); // NOI18N
142:
143:                browseButton.setText(org.openide.util.NbBundle.getMessage(
144:                        TargetChooserPanelGUI.class,
145:                        "TargetChooserPanelGUI.browseButton.text")); // NOI18N
146:                browseButton
147:                        .addActionListener(new java.awt.event.ActionListener() {
148:                            public void actionPerformed(
149:                                    java.awt.event.ActionEvent evt) {
150:                                browseForFolders(evt);
151:                            }
152:                        });
153:
154:                pathLabel.setText(org.openide.util.NbBundle.getMessage(
155:                        TargetChooserPanelGUI.class,
156:                        "TargetChooserPanelGUI.pathLabel.text")); // NOI18N
157:
158:                fileTextField.setEditable(false);
159:
160:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
161:                        this );
162:                this .setLayout(layout);
163:                layout
164:                        .setHorizontalGroup(layout
165:                                .createParallelGroup(
166:                                        org.jdesktop.layout.GroupLayout.LEADING)
167:                                .add(
168:                                        targetSeparator,
169:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
170:                                        441, Short.MAX_VALUE)
171:                                .add(
172:                                        layout
173:                                                .createSequentialGroup()
174:                                                .add(
175:                                                        layout
176:                                                                .createParallelGroup(
177:                                                                        org.jdesktop.layout.GroupLayout.TRAILING)
178:                                                                .add(
179:                                                                        org.jdesktop.layout.GroupLayout.LEADING,
180:                                                                        layout
181:                                                                                .createSequentialGroup()
182:                                                                                .add(
183:                                                                                        layout
184:                                                                                                .createParallelGroup(
185:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
186:                                                                                                .add(
187:                                                                                                        nameLabel,
188:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
189:                                                                                                        88,
190:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
191:                                                                                                .add(
192:                                                                                                        folderLabel,
193:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
194:                                                                                                        76,
195:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
196:                                                                                                .add(
197:                                                                                                        pathLabel,
198:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
199:                                                                                                        102,
200:                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
201:                                                                                .addPreferredGap(
202:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
203:                                                                                .add(
204:                                                                                        layout
205:                                                                                                .createParallelGroup(
206:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
207:                                                                                                .add(
208:                                                                                                        fileTextField,
209:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
210:                                                                                                        327,
211:                                                                                                        Short.MAX_VALUE)
212:                                                                                                .add(
213:                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
214:                                                                                                        layout
215:                                                                                                                .createSequentialGroup()
216:                                                                                                                .add(
217:                                                                                                                        layout
218:                                                                                                                                .createParallelGroup(
219:                                                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING)
220:                                                                                                                                .add(
221:                                                                                                                                        org.jdesktop.layout.GroupLayout.LEADING,
222:                                                                                                                                        documentNameTextField,
223:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
224:                                                                                                                                        207,
225:                                                                                                                                        Short.MAX_VALUE)
226:                                                                                                                                .add(
227:                                                                                                                                        org.jdesktop.layout.GroupLayout.LEADING,
228:                                                                                                                                        projectTextField,
229:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
230:                                                                                                                                        207,
231:                                                                                                                                        Short.MAX_VALUE)
232:                                                                                                                                .add(
233:                                                                                                                                        folderTextField,
234:                                                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
235:                                                                                                                                        207,
236:                                                                                                                                        Short.MAX_VALUE))
237:                                                                                                                .addPreferredGap(
238:                                                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
239:                                                                                                                .add(
240:                                                                                                                        browseButton,
241:                                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
242:                                                                                                                        114,
243:                                                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
244:                                                                .add(
245:                                                                        org.jdesktop.layout.GroupLayout.LEADING,
246:                                                                        projectLabel,
247:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
248:                                                                        79,
249:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
250:                                                .add(0, 0, 0))
251:                                .add(
252:                                        fillerPanel,
253:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
254:                                        441, Short.MAX_VALUE));
255:                layout
256:                        .setVerticalGroup(layout
257:                                .createParallelGroup(
258:                                        org.jdesktop.layout.GroupLayout.LEADING)
259:                                .add(
260:                                        layout
261:                                                .createSequentialGroup()
262:                                                .add(
263:                                                        layout
264:                                                                .createParallelGroup(
265:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
266:                                                                .add(nameLabel)
267:                                                                .add(
268:                                                                        documentNameTextField,
269:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
270:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
271:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
272:                                                .addPreferredGap(
273:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
274:                                                .add(
275:                                                        layout
276:                                                                .createParallelGroup(
277:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
278:                                                                .add(
279:                                                                        projectLabel)
280:                                                                .add(
281:                                                                        projectTextField,
282:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
283:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
284:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
285:                                                .addPreferredGap(
286:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
287:                                                .add(
288:                                                        layout
289:                                                                .createParallelGroup(
290:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
291:                                                                .add(
292:                                                                        folderLabel)
293:                                                                .add(
294:                                                                        folderTextField,
295:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
296:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
297:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
298:                                                                .add(
299:                                                                        browseButton))
300:                                                .addPreferredGap(
301:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
302:                                                .add(
303:                                                        layout
304:                                                                .createParallelGroup(
305:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
306:                                                                .add(pathLabel)
307:                                                                .add(
308:                                                                        fileTextField,
309:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
310:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
311:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
312:                                                .addPreferredGap(
313:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
314:                                                .add(
315:                                                        targetSeparator,
316:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
317:                                                        2,
318:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
319:                                                .addPreferredGap(
320:                                                        org.jdesktop.layout.LayoutStyle.UNRELATED)
321:                                                .add(
322:                                                        fillerPanel,
323:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
324:                                                        147, Short.MAX_VALUE)));
325:            }// </editor-fold>//GEN-END:initComponents
326:
327:            private void browseForFolders(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseForFolders
328:                browseFolders();
329:            }//GEN-LAST:event_browseForFolders
330:
331:            // Variables declaration - do not modify//GEN-BEGIN:variables
332:            private javax.swing.JButton browseButton;
333:            private javax.swing.JTextField documentNameTextField;
334:            private javax.swing.JTextField fileTextField;
335:            private javax.swing.JPanel fillerPanel;
336:            private javax.swing.JLabel folderLabel;
337:            private javax.swing.JTextField folderTextField;
338:            private javax.swing.JLabel nameLabel;
339:            private javax.swing.JLabel pathLabel;
340:            private javax.swing.JLabel projectLabel;
341:            private javax.swing.JTextField projectTextField;
342:            private javax.swing.JSeparator targetSeparator;
343:
344:            // End of variables declaration//GEN-END:variables
345:
346:            private String getRelativeSourcesFolder() {
347:                return JMETER_SCRIPTS_FOLDER;
348:            }
349:
350:            public FileObject getLocationRoot() {
351:                return project.getProjectDirectory();
352:            }
353:
354:            public String getTargetName() {
355:
356:                String text = documentNameTextField.getText().trim();
357:
358:                if (text.length() == 0) {
359:                    return null;
360:                } else {
361:                    return text;
362:                }
363:            }
364:
365:            public File getTargetFile() {
366:                String text = getNormalizedFolder();
367:
368:                if (text.length() == 0) {
369:                    return FileUtil.toFile(project.getProjectDirectory());
370:                } else {
371:                    return new File(FileUtil.toFile(
372:                            project.getProjectDirectory()).getAbsolutePath(),
373:                            text);
374:                }
375:            }
376:
377:            public String getRelativeTargetFolder() {
378:                return getRelativeSourcesFolder() + getNormalizedFolder();
379:            }
380:
381:            public String getNormalizedFolder() {
382:                String norm = folderTextField.getText().trim();
383:                if (norm.length() == 0) {
384:                    return "";
385:                }
386:                norm = norm.replace('\\', '/');
387:                // removing leading slashes
388:                int i = 0;
389:                while (i < norm.length() && norm.charAt(i) == '/') {
390:                    i++;
391:                }
392:                if (i == norm.length()) {
393:                    return ""; //only slashes
394:                }
395:                norm = norm.substring(i);
396:
397:                // removing multiple slashes
398:                java.util.StringTokenizer tokens = new java.util.StringTokenizer(
399:                        norm, "/");
400:                java.util.List list = new java.util.ArrayList();
401:                StringBuffer buf = new StringBuffer(tokens.nextToken());
402:                while (tokens.hasMoreTokens()) {
403:                    String token = tokens.nextToken();
404:                    if (token.length() > 0) {
405:                        buf.append("/" + token);
406:                    }
407:                }
408:                return buf.toString();
409:            }
410:
411:            public String getTargetFolder() {
412:                return getTargetFile().getPath();
413:            }
414:
415:            public String getCreatedFilePath() {
416:                return fileTextField.getText();
417:            }
418:
419:            public void initValues(Project p, FileObject template,
420:                    FileObject preselectedFolder) {
421:                projectTextField.setText(ProjectUtils.getInformation(p)
422:                        .getDisplayName());
423:
424:                // filling the folder field
425:                String target = null;
426:                FileObject docBase = getLocationRoot();
427:                if (preselectedFolder != null
428:                        && FileUtil.isParentOf(docBase, preselectedFolder)) {
429:                    target = FileUtil.getRelativePath(docBase,
430:                            preselectedFolder);
431:                }
432:
433:                if (target == null) {
434:                    target = JMETER_SCRIPTS_FOLDER;
435:                }
436:
437:                folderTextField.setText(target == null ? "" : target); // NOI18N
438:                String ext = template == null ? "" : template.getExt(); // NOI18N
439:                expectedExtension = ext.length() == 0 ? "" : "." + ext; // NOI18N
440:            }
441:
442:            public boolean isPanelValid() {
443:                return true;
444:            }
445:
446:            String getErrorMessage() {
447:                // check for errors and return appropriate message
448:                return null;
449:            }
450:
451:            private void browseFolders() {
452:                org.openide.filesystems.FileObject fo = null;
453:                // Show the browse dialog
454:                Sources sources = ProjectUtils.getSources(project);
455:                fo = BrowseFolders.showDialog(sources
456:                        .getSourceGroups(Sources.TYPE_GENERIC),
457:                        org.openide.loaders.DataFolder.class, getTargetFolder()
458:                                .replace(File.separatorChar, '/'));
459:
460:                if (fo != null) {
461:                    folderTextField.setText(FileUtil.getRelativePath(project
462:                            .getProjectDirectory(), fo));
463:                }
464:                wizardPanel.fireChange();
465:                //    }
466:            }
467:
468:            private void updateTargetFile() {
469:                if (documentNameTextField.getText().length() > 0) {
470:                    fileTextField.setText(getTargetFolder()
471:                            + File.separatorChar
472:                            + documentNameTextField.getText()
473:                            + expectedExtension);
474:                } else {
475:                    fileTextField.setText("");
476:                }
477:                wizardPanel.fireChange();
478:            }
479:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.