Source Code Cross Referenced for ConvertPanel.java in  » IDE-Netbeans » vmd.analyzer » org » netbeans » modules » vmd » midp » converter » 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 » vmd.analyzer » org.netbeans.modules.vmd.midp.converter.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */package org.netbeans.modules.vmd.midp.converter.wizard;
041:
042:        import org.openide.DialogDescriptor;
043:        import org.openide.filesystems.FileObject;
044:        import org.openide.util.Exceptions;
045:        import org.openide.util.NbBundle;
046:        import org.openide.util.RequestProcessor;
047:        import org.openide.util.Utilities;
048:
049:        import javax.swing.*;
050:        import javax.swing.event.DocumentListener;
051:        import javax.swing.event.DocumentEvent;
052:        import java.awt.event.ActionEvent;
053:        import java.awt.event.ActionListener;
054:        import java.util.ArrayList;
055:
056:        /**
057:         * @author David Kaspar
058:         */
059:        public final class ConvertPanel extends javax.swing.JPanel implements 
060:                ActionListener, Runnable, DocumentListener {
061:
062:            private DialogDescriptor descriptor = new DialogDescriptor(this ,
063:                    NbBundle.getMessage(ConvertPanel.class,
064:                            "TITLE_ConvertPanel")); // NOI18N
065:            private JButton startButton = new JButton(NbBundle.getMessage(
066:                    ConvertPanel.class, "DISP_Start")); // NOI18N
067:            private JButton finishButton = new JButton(NbBundle.getMessage(
068:                    ConvertPanel.class, "DISP_Close")); // NOI18N
069:            private FileObject inputPrimaryFile;
070:            private FileObject inputSecondaryFile;
071:            private FileObject outputDirectory;
072:
073:            /** Creates new form ConvertPanel */
074:            public ConvertPanel() {
075:                initComponents();
076:                ImageIcon warningMessage = new ImageIcon(
077:                        Utilities
078:                                .loadImage("org/netbeans/modules/vmd/midp/resources/warning.gif"));
079:                finishIcon.setIcon(warningMessage); // NOI18N
080:                message.setIcon(warningMessage); // NOI18N
081:                startButton.setDefaultCapable(true);
082:                startButton.addActionListener(this );
083:                finishButton.setDefaultCapable(true);
084:                descriptor.setClosingOptions(new Object[] { finishButton,
085:                        DialogDescriptor.CANCEL_OPTION });
086:            }
087:
088:            public DialogDescriptor getDialogDescriptor() {
089:                return descriptor;
090:            }
091:
092:            public void switchToShown(FileObject inputPrimaryFile,
093:                    FileObject inputSecondaryFile, FileObject outputDirectory) {
094:                this .inputPrimaryFile = inputPrimaryFile;
095:                this .inputSecondaryFile = inputSecondaryFile;
096:                this .outputDirectory = outputDirectory;
097:                this .inputFileName.setText(inputPrimaryFile.getName());
098:                progress.setIndeterminate(false);
099:                progress.setValue(100);
100:                finishIcon.setVisible(false);
101:                finishMessage.setText(NbBundle.getMessage(ConvertPanel.class,
102:                        "MSG_ShownMessage")); // NOI18N
103:                startButton.setEnabled(true);
104:                descriptor.setOptions(new Object[] { startButton,
105:                        DialogDescriptor.CANCEL_OPTION });
106:
107:                outputFileName.getDocument().removeDocumentListener(this );
108:                outputFileName.getDocument().addDocumentListener(this );
109:                outputFileName
110:                        .setText("Converted" + inputPrimaryFile.getName()); // NOI18N
111:                outputFileName.setEditable(true);
112:                outputFileName.selectAll();
113:                outputFileName.requestFocus();
114:            }
115:
116:            public void switchToStarted() {
117:                outputFileName.getDocument().removeDocumentListener(this );
118:                outputFileName.setEditable(false);
119:
120:                progress.setIndeterminate(true);
121:                finishMessage.setText(NbBundle.getMessage(ConvertPanel.class,
122:                        "MSG_StartMessage")); // NOI18N
123:                startButton.setEnabled(false);
124:                descriptor.setOptions(new Object[0]);
125:            }
126:
127:            public void switchToFinished() {
128:                progress.setIndeterminate(false);
129:                progress.setValue(100);
130:                finishIcon.setVisible(true);
131:                finishMessage.setText(NbBundle.getMessage(ConvertPanel.class,
132:                        "MSG_FinishMessage")); // NOI18N
133:                descriptor.setOptions(new Object[] { finishButton });
134:            }
135:
136:            public void switchToErrors(ArrayList<String> errors) {
137:                progress.setIndeterminate(false);
138:                progress.setValue(100);
139:                finishIcon.setVisible(true);
140:                StringBuffer str = new StringBuffer();
141:                for (String string : errors) {
142:                    str.append(string);
143:                    str.append('\n'); // NOI18N
144:                }
145:                finishMessage.setText(str.toString());
146:                descriptor.setOptions(new Object[] { finishButton });
147:            }
148:
149:            public void insertUpdate(DocumentEvent e) {
150:                checkErrors();
151:            }
152:
153:            public void removeUpdate(DocumentEvent e) {
154:                checkErrors();
155:            }
156:
157:            public void changedUpdate(DocumentEvent e) {
158:                checkErrors();
159:            }
160:
161:            private void checkErrors() {
162:                boolean exists = outputDirectory.getFileObject(outputFileName
163:                        .getText(), "java") != null // NOI18N
164:                        || outputDirectory.getFileObject(outputFileName
165:                                .getText(), "vmd") != null; // NOI18N
166:                message.setVisible(exists);
167:                startButton.setEnabled(!exists);
168:            }
169:
170:            /** This method is called from within the constructor to
171:             * initialize the form.
172:             * WARNING: Do NOT modify this code. The content of this method is
173:             * always regenerated by the Form Editor.
174:             */
175:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
176:            private void initComponents() {
177:
178:                jLabel2 = new javax.swing.JLabel();
179:                inputFileName = new javax.swing.JTextField();
180:                jLabel1 = new javax.swing.JLabel();
181:                outputFileName = new javax.swing.JTextField();
182:                javax.swing.JSeparator jSeparator1 = new javax.swing.JSeparator();
183:                progress = new javax.swing.JProgressBar();
184:                finishMessage = new javax.swing.JLabel();
185:                finishIcon = new javax.swing.JLabel();
186:                message = new javax.swing.JLabel();
187:
188:                setPreferredSize(new java.awt.Dimension(500, 400));
189:
190:                jLabel2
191:                        .setDisplayedMnemonic(java.util.ResourceBundle
192:                                .getBundle(
193:                                        "org/netbeans/modules/vmd/midp/converter/wizard/Bundle")
194:                                .getString("ConvertPanel.jLabel1.mnemonic")
195:                                .charAt(0));
196:                jLabel2.setLabelFor(inputFileName);
197:                jLabel2.setText(org.openide.util.NbBundle.getMessage(
198:                        ConvertPanel.class, "ConvertPanel.jLabel2.text")); // NOI18N
199:
200:                inputFileName.setEditable(false);
201:                inputFileName.setText(org.openide.util.NbBundle.getMessage(
202:                        ConvertPanel.class, "ConvertPanel.inputFileName.text")); // NOI18N
203:
204:                jLabel1
205:                        .setDisplayedMnemonic(java.util.ResourceBundle
206:                                .getBundle(
207:                                        "org/netbeans/modules/vmd/midp/converter/wizard/Bundle")
208:                                .getString("ConvertPanel.jLabel2.mnemonic")
209:                                .charAt(0));
210:                jLabel1.setLabelFor(outputFileName);
211:                jLabel1.setText(org.openide.util.NbBundle.getMessage(
212:                        ConvertPanel.class, "ConvertPanel.jLabel1.text")); // NOI18N
213:
214:                outputFileName
215:                        .setText(org.openide.util.NbBundle.getMessage(
216:                                ConvertPanel.class,
217:                                "ConvertPanel.outputFileName.text")); // NOI18N
218:
219:                finishMessage
220:                        .setVerticalAlignment(javax.swing.SwingConstants.TOP);
221:
222:                finishIcon.setText(org.openide.util.NbBundle.getMessage(
223:                        ConvertPanel.class, "ConvertPanel.finishIcon.text")); // NOI18N
224:                finishIcon.setPreferredSize(new java.awt.Dimension(16, 16));
225:
226:                message.setText(org.openide.util.NbBundle.getMessage(
227:                        ConvertPanel.class, "ConvertPanel.message.text")); // NOI18N
228:
229:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
230:                        this );
231:                this .setLayout(layout);
232:                layout
233:                        .setHorizontalGroup(layout
234:                                .createParallelGroup(
235:                                        org.jdesktop.layout.GroupLayout.LEADING)
236:                                .add(
237:                                        layout
238:                                                .createSequentialGroup()
239:                                                .add(
240:                                                        layout
241:                                                                .createParallelGroup(
242:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
243:                                                                .add(
244:                                                                        layout
245:                                                                                .createSequentialGroup()
246:                                                                                .addContainerGap()
247:                                                                                .add(
248:                                                                                        finishIcon,
249:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
250:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
251:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
252:                                                                                .addPreferredGap(
253:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
254:                                                                                .add(
255:                                                                                        finishMessage,
256:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
257:                                                                                        460,
258:                                                                                        Short.MAX_VALUE))
259:                                                                .add(
260:                                                                        layout
261:                                                                                .createSequentialGroup()
262:                                                                                .add(
263:                                                                                        12,
264:                                                                                        12,
265:                                                                                        12)
266:                                                                                .add(
267:                                                                                        layout
268:                                                                                                .createParallelGroup(
269:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING,
270:                                                                                                        false)
271:                                                                                                .add(
272:                                                                                                        jLabel2,
273:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
274:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
275:                                                                                                        Short.MAX_VALUE)
276:                                                                                                .add(
277:                                                                                                        jLabel1,
278:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
279:                                                                                                        127,
280:                                                                                                        Short.MAX_VALUE))
281:                                                                                .addPreferredGap(
282:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
283:                                                                                .add(
284:                                                                                        layout
285:                                                                                                .createParallelGroup(
286:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
287:                                                                                                .add(
288:                                                                                                        outputFileName,
289:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
290:                                                                                                        349,
291:                                                                                                        Short.MAX_VALUE)
292:                                                                                                .add(
293:                                                                                                        inputFileName,
294:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
295:                                                                                                        349,
296:                                                                                                        Short.MAX_VALUE)))
297:                                                                .add(
298:                                                                        layout
299:                                                                                .createSequentialGroup()
300:                                                                                .add(
301:                                                                                        12,
302:                                                                                        12,
303:                                                                                        12)
304:                                                                                .add(
305:                                                                                        jSeparator1,
306:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
307:                                                                                        480,
308:                                                                                        Short.MAX_VALUE))
309:                                                                .add(
310:                                                                        layout
311:                                                                                .createSequentialGroup()
312:                                                                                .add(
313:                                                                                        12,
314:                                                                                        12,
315:                                                                                        12)
316:                                                                                .add(
317:                                                                                        progress,
318:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
319:                                                                                        480,
320:                                                                                        Short.MAX_VALUE))
321:                                                                .add(
322:                                                                        layout
323:                                                                                .createSequentialGroup()
324:                                                                                .add(
325:                                                                                        12,
326:                                                                                        12,
327:                                                                                        12)
328:                                                                                .add(
329:                                                                                        message,
330:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
331:                                                                                        480,
332:                                                                                        Short.MAX_VALUE)))
333:                                                .addContainerGap()));
334:                layout
335:                        .setVerticalGroup(layout
336:                                .createParallelGroup(
337:                                        org.jdesktop.layout.GroupLayout.LEADING)
338:                                .add(
339:                                        layout
340:                                                .createSequentialGroup()
341:                                                .addContainerGap()
342:                                                .add(
343:                                                        layout
344:                                                                .createParallelGroup(
345:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
346:                                                                .add(jLabel2)
347:                                                                .add(
348:                                                                        inputFileName,
349:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
350:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
351:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
352:                                                .addPreferredGap(
353:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
354:                                                .add(
355:                                                        layout
356:                                                                .createParallelGroup(
357:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
358:                                                                .add(jLabel1)
359:                                                                .add(
360:                                                                        outputFileName,
361:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
362:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
363:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
364:                                                .addPreferredGap(
365:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
366:                                                .add(
367:                                                        jSeparator1,
368:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
369:                                                        10,
370:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
371:                                                .addPreferredGap(
372:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
373:                                                .add(
374:                                                        progress,
375:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
376:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
377:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
378:                                                .addPreferredGap(
379:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
380:                                                .add(
381:                                                        layout
382:                                                                .createParallelGroup(
383:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
384:                                                                .add(
385:                                                                        finishIcon,
386:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
387:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
388:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
389:                                                                .add(
390:                                                                        finishMessage,
391:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
392:                                                                        265,
393:                                                                        Short.MAX_VALUE))
394:                                                .addPreferredGap(
395:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
396:                                                .add(message).addContainerGap()));
397:
398:                jLabel2
399:                        .getAccessibleContext()
400:                        .setAccessibleDescription(
401:                                org.openide.util.NbBundle
402:                                        .getMessage(ConvertPanel.class,
403:                                                "ConvertPanel.jLabel2.AccessibleContext.accessibleDescription")); // NOI18N
404:                jLabel1
405:                        .getAccessibleContext()
406:                        .setAccessibleDescription(
407:                                org.openide.util.NbBundle
408:                                        .getMessage(ConvertPanel.class,
409:                                                "ConvertPanel.jLabel1.AccessibleContext.accessibleDescription")); // NOI18N
410:
411:                getAccessibleContext().setAccessibleName(
412:                        org.openide.util.NbBundle.getMessage(
413:                                ConvertPanel.class, "ACC_NAME_ConvertPanel")); // NOI18N
414:                getAccessibleContext().setAccessibleDescription(
415:                        org.openide.util.NbBundle.getMessage(
416:                                ConvertPanel.class, "ACC_DESC_ConvertPanel")); // NOI18N
417:            }// </editor-fold>//GEN-END:initComponents
418:
419:            // Variables declaration - do not modify//GEN-BEGIN:variables
420:            private javax.swing.JLabel finishIcon;
421:            private javax.swing.JLabel finishMessage;
422:            private javax.swing.JTextField inputFileName;
423:            private javax.swing.JLabel jLabel1;
424:            private javax.swing.JLabel jLabel2;
425:            private javax.swing.JLabel message;
426:            private javax.swing.JTextField outputFileName;
427:            private javax.swing.JProgressBar progress;
428:
429:            // End of variables declaration//GEN-END:variables
430:
431:            public void actionPerformed(ActionEvent e) {
432:                switchToStarted();
433:                RequestProcessor.getDefault().post(this );
434:            }
435:
436:            public void run() {
437:                final ArrayList<String> errors = new ArrayList<String>();
438:                try {
439:                    ArrayList<String> _errors = Converter.convert(
440:                            inputPrimaryFile, inputSecondaryFile,
441:                            outputFileName.getText());
442:                    if (!_errors.isEmpty()) {
443:                        errors.addAll(_errors);
444:                    }
445:                } catch (Exception e) {
446:                    Exceptions.printStackTrace(e);
447:                }
448:                SwingUtilities.invokeLater(new Runnable() {
449:                    public void run() {
450:                        if (errors.isEmpty()) {
451:                            switchToFinished();
452:                        } else {
453:                            switchToErrors(errors);
454:                        }
455:                    }
456:                });
457:            }
458:
459:        }
w__ww.j__a_va__2__s.___c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.