Source Code Cross Referenced for DocumentEditorView.java in  » IDE-Netbeans » java » DocumentEditor » 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 » java » DocumentEditor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, Sun Microsystems, Inc.
003:         * All rights reserved.
004:         * 
005:         * Redistribution and use in source and binary forms, with or without 
006:         * modification, are permitted provided that the following conditions are met:
007:         * 
008:         *  * Redistributions of source code must retain the above copyright notice, 
009:         *    this list of conditions and the following disclaimer.
010:         *  * Redistributions in binary form must reproduce the above copyright 
011:         *    notice, this list of conditions and the following disclaimer in 
012:         *    the documentation and/or other materials provided with the distribution.
013:         *  * Neither the name of Sun Microsystems, Inc. nor the names of its 
014:         *    contributors may be used to endorse or promote products derived 
015:         *    from this software without specific prior written permission.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
021:         * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
022:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
023:         * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         */
029:
030:        package documenteditor;
031:
032:        import javax.swing.event.DocumentEvent;
033:        import org.jdesktop.application.Action;
034:        import org.jdesktop.application.ResourceMap;
035:        import org.jdesktop.application.SingleFrameApplication;
036:        import org.jdesktop.application.FrameView;
037:        import org.jdesktop.application.TaskMonitor;
038:        import org.jdesktop.application.Task;
039:        import java.awt.event.ActionEvent;
040:        import java.awt.event.ActionListener;
041:        import java.io.File;
042:        import java.util.EventObject;
043:        import java.util.logging.Level;
044:        import java.util.logging.Logger;
045:        import javax.swing.Timer;
046:        import javax.swing.Icon;
047:        import javax.swing.JDialog;
048:        import javax.swing.JFileChooser;
049:        import javax.swing.JFrame;
050:        import javax.swing.JOptionPane;
051:        import javax.swing.event.DocumentListener;
052:        import org.jdesktop.application.Application;
053:        import javax.swing.filechooser.FileFilter;
054:
055:        /**
056:         * This application is a simple text editor. This class displays the main frame
057:         * of the application and provides much of the logic. This class is called by
058:         * the main application class, DocumentEditorApp. For an overview of the
059:         * application see the comments for the DocumentEditorApp class.
060:         */
061:        public class DocumentEditorView extends FrameView {
062:
063:            private File file = new File("untitled.txt");
064:            private boolean modified = false;
065:
066:            public DocumentEditorView(SingleFrameApplication app) {
067:                super (app);
068:
069:                // generated GUI builder code
070:                initComponents();
071:
072:                // status bar initialization - message timeout, idle icon and busy animation, etc
073:                ResourceMap resourceMap = getResourceMap();
074:                int messageTimeout = resourceMap
075:                        .getInteger("StatusBar.messageTimeout");
076:                messageTimer = new Timer(messageTimeout, new ActionListener() {
077:                    public void actionPerformed(ActionEvent e) {
078:                        statusMessageLabel.setText("");
079:                    }
080:                });
081:                messageTimer.setRepeats(false);
082:                int busyAnimationRate = resourceMap
083:                        .getInteger("StatusBar.busyAnimationRate");
084:                for (int i = 0; i < busyIcons.length; i++) {
085:                    busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons["
086:                            + i + "]");
087:                }
088:                busyIconTimer = new Timer(busyAnimationRate,
089:                        new ActionListener() {
090:                            public void actionPerformed(ActionEvent e) {
091:                                busyIconIndex = (busyIconIndex + 1)
092:                                        % busyIcons.length;
093:                                statusAnimationLabel
094:                                        .setIcon(busyIcons[busyIconIndex]);
095:                            }
096:                        });
097:                idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
098:                statusAnimationLabel.setIcon(idleIcon);
099:                progressBar.setVisible(false);
100:
101:                // connect action tasks to status bar via TaskMonitor
102:                TaskMonitor taskMonitor = new TaskMonitor(getApplication()
103:                        .getContext());
104:                taskMonitor
105:                        .addPropertyChangeListener(new java.beans.PropertyChangeListener() {
106:                            public void propertyChange(
107:                                    java.beans.PropertyChangeEvent evt) {
108:                                String propertyName = evt.getPropertyName();
109:                                if ("started".equals(propertyName)) {
110:                                    if (!busyIconTimer.isRunning()) {
111:                                        statusAnimationLabel
112:                                                .setIcon(busyIcons[0]);
113:                                        busyIconIndex = 0;
114:                                        busyIconTimer.start();
115:                                    }
116:                                    progressBar.setVisible(true);
117:                                    progressBar.setIndeterminate(true);
118:                                } else if ("done".equals(propertyName)) {
119:                                    busyIconTimer.stop();
120:                                    statusAnimationLabel.setIcon(idleIcon);
121:                                    progressBar.setVisible(false);
122:                                    progressBar.setValue(0);
123:                                } else if ("message".equals(propertyName)) {
124:                                    String text = (String) (evt.getNewValue());
125:                                    statusMessageLabel
126:                                            .setText((text == null) ? "" : text);
127:                                    messageTimer.restart();
128:                                } else if ("progress".equals(propertyName)) {
129:                                    int value = (Integer) (evt.getNewValue());
130:                                    progressBar.setVisible(true);
131:                                    progressBar.setIndeterminate(false);
132:                                    progressBar.setValue(value);
133:                                }
134:                            }
135:                        });
136:
137:                // if the document is ever edited, assume that it needs to be saved
138:                textArea.getDocument().addDocumentListener(
139:                        new DocumentListener() {
140:                            public void changedUpdate(DocumentEvent e) {
141:                                setModified(true);
142:                            }
143:
144:                            public void insertUpdate(DocumentEvent e) {
145:                                setModified(true);
146:                            }
147:
148:                            public void removeUpdate(DocumentEvent e) {
149:                                setModified(true);
150:                            }
151:                        });
152:
153:                // ask for confirmation on exit
154:                getApplication().addExitListener(new ConfirmExit());
155:            }
156:
157:            /**
158:             * The File currently being edited.  The default value of this
159:             * property is "untitled.txt".
160:             * <p>
161:             * This is a bound read-only property.  It is never null.
162:             * 
163:             * @return the value of the file property.
164:             * @see #isModified
165:             */
166:            public File getFile() {
167:                return file;
168:            }
169:
170:            /* Set the bound file property and update the GUI.
171:             */
172:            private void setFile(File file) {
173:                File oldValue = this .file;
174:                this .file = file;
175:                String appId = getResourceMap().getString("Application.id");
176:                getFrame().setTitle(file.getName() + " - " + appId);
177:                firePropertyChange("file", oldValue, this .file);
178:            }
179:
180:            /**
181:             * True if the file value has been modified but not saved.  The 
182:             * default value of this property is false.
183:             * <p>
184:             * This is a bound read-only property.  
185:             * 
186:             * @return the value of the modified property.
187:             * @see #isModified
188:             */
189:            public boolean isModified() {
190:                return modified;
191:            }
192:
193:            /* Set the bound modified property and update the GUI.
194:             */
195:            private void setModified(boolean modified) {
196:                boolean oldValue = this .modified;
197:                this .modified = modified;
198:                firePropertyChange("modified", oldValue, this .modified);
199:            }
200:
201:            /**
202:             * Prompt the user for a filename and then attempt to load the file.
203:             * <p>
204:             * The file is loaded on a worker thread because we don't want to
205:             * block the EDT while the file system is accessed.  To do that,
206:             * this Action method returns a new LoadFileTask instance, if the
207:             * user confirms selection of a file.  The task is executed when
208:             * the "open" Action's actionPerformed method runs.  The
209:             * LoadFileTask is responsible for updating the GUI after it has
210:             * successfully completed loading the file.
211:             * 
212:             * @return a new LoadFileTask or null
213:             */
214:            @Action
215:            public Task open() {
216:                JFileChooser fc = createFileChooser("openFileChooser");
217:                int option = fc.showOpenDialog(getFrame());
218:                Task task = null;
219:                if (JFileChooser.APPROVE_OPTION == option) {
220:                    task = new LoadFileTask(fc.getSelectedFile());
221:                }
222:                return task;
223:            }
224:
225:            /**
226:             * A Task that loads the contents of a file into a String.  The
227:             * LoadFileTask constructor runs first, on the EDT, then the
228:             * #doInBackground methods runs on a background thread, and finally
229:             * a completion method like #succeeded or #failed runs on the EDT.
230:             * 
231:             * The resources for this class, like the message format strings are 
232:             * loaded from resources/LoadFileTask.properties.
233:             */
234:            private class LoadFileTask extends
235:                    DocumentEditorApp.LoadTextFileTask {
236:                /* Construct the LoadFileTask object.  The constructor
237:                 * will run on the EDT, so we capture a reference to the 
238:                 * File to be loaded here.  To keep things simple, the 
239:                 * resources for this Task are specified to be in the same 
240:                 * ResourceMap as the DocumentEditorView class's resources.
241:                 * They're defined in resources/DocumentEditorView.properties.
242:                 */
243:                LoadFileTask(File file) {
244:                    super (DocumentEditorView.this .getApplication(), file);
245:                }
246:
247:                /* Called on the EDT if doInBackground completes without 
248:                 * error and this Task isn't cancelled.  We update the
249:                 * GUI as well as the file and modified properties here.
250:                 */
251:                @Override
252:                protected void succeeded(String fileContents) {
253:                    setFile(getFile());
254:                    textArea.setText(fileContents);
255:                    setModified(false);
256:                }
257:
258:                /* Called on the EDT if doInBackground fails because
259:                 * an uncaught exception is thrown.  We show an error
260:                 * dialog here.  The dialog is configured with resources
261:                 * loaded from this Tasks's ResourceMap.
262:                 */
263:                @Override
264:                protected void failed(Throwable e) {
265:                    logger.log(Level.WARNING, "couldn't load " + getFile(), e);
266:                    String msg = getResourceMap().getString(
267:                            "loadFailedMessage", getFile());
268:                    String title = getResourceMap()
269:                            .getString("loadFailedTitle");
270:                    int type = JOptionPane.ERROR_MESSAGE;
271:                    JOptionPane.showMessageDialog(getFrame(), msg, title, type);
272:                }
273:            }
274:
275:            /**
276:             * Save the contents of the textArea to the current {@link #getFile file}.
277:             * <p>
278:             * The text is written to the file on a worker thread because we don't want to 
279:             * block the EDT while the file system is accessed.  To do that, this
280:             * Action method returns a new SaveFileTask instance.  The task
281:             * is executed when the "save" Action's actionPerformed method runs.
282:             * The SaveFileTask is responsible for updating the GUI after it
283:             * has successfully completed saving the file.
284:             * 
285:             * @see #getFile
286:             */
287:            @Action(enabledProperty="modified")
288:            public Task save() {
289:                return new SaveFileTask(getFile());
290:            }
291:
292:            /**
293:             * Save the contents of the textArea to the current file.
294:             * <p>
295:             * This action is nearly identical to {@link #open open}.  In
296:             * this case, if the user chooses a file, a {@code SaveFileTask}
297:             * is returned.  Note that the selected file only becomes the
298:             * value of the {@code file} property if the file is saved
299:             * successfully.
300:             */
301:            @Action
302:            public Task saveAs() {
303:                JFileChooser fc = createFileChooser("saveAsFileChooser");
304:                int option = fc.showSaveDialog(getFrame());
305:                Task task = null;
306:                if (JFileChooser.APPROVE_OPTION == option) {
307:                    task = new SaveFileTask(fc.getSelectedFile());
308:                }
309:                return task;
310:            }
311:
312:            /**
313:             * A Task that saves the contents of the textArea to the current file.
314:             * This class is very similar to LoadFileTask, please refer to that
315:             * class for more information.  
316:             */
317:            private class SaveFileTask extends
318:                    DocumentEditorApp.SaveTextFileTask {
319:                SaveFileTask(File file) {
320:                    super (DocumentEditorView.this .getApplication(), file,
321:                            textArea.getText());
322:                }
323:
324:                @Override
325:                protected void succeeded(Void ignored) {
326:                    setFile(getFile());
327:                    setModified(false);
328:                }
329:
330:                @Override
331:                protected void failed(Throwable e) {
332:                    logger.log(Level.WARNING, "couldn't save " + getFile(), e);
333:                    String msg = getResourceMap().getString(
334:                            "saveFailedMessage", getFile());
335:                    String title = getResourceMap()
336:                            .getString("saveFailedTitle");
337:                    int type = JOptionPane.ERROR_MESSAGE;
338:                    JOptionPane.showMessageDialog(getFrame(), msg, title, type);
339:                }
340:            }
341:
342:            @Action
343:            public void showAboutBox() {
344:                if (aboutBox == null) {
345:                    JFrame mainFrame = DocumentEditorApp.getApplication()
346:                            .getMainFrame();
347:                    aboutBox = new DocumentEditorAboutBox(mainFrame);
348:                    aboutBox.setLocationRelativeTo(mainFrame);
349:                }
350:                DocumentEditorApp.getApplication().show(aboutBox);
351:            }
352:
353:            private JFileChooser createFileChooser(String name) {
354:                JFileChooser fc = new JFileChooser();
355:                fc.setDialogTitle(getResourceMap().getString(
356:                        name + ".dialogTitle"));
357:                String textFilesDesc = getResourceMap().getString(
358:                        "txtFileExtensionDescription");
359:                fc.setFileFilter(new TextFileFilter(textFilesDesc));
360:                return fc;
361:            }
362:
363:            /** This is a substitute for FileNameExtensionFilter, which is
364:             * only available on Java SE 6.
365:             */
366:            private static class TextFileFilter extends FileFilter {
367:
368:                private final String description;
369:
370:                TextFileFilter(String description) {
371:                    this .description = description;
372:                }
373:
374:                @Override
375:                public boolean accept(File f) {
376:                    if (f.isDirectory()) {
377:                        return true;
378:                    }
379:                    String fileName = f.getName();
380:                    int i = fileName.lastIndexOf('.');
381:                    if ((i > 0) && (i < (fileName.length() - 1))) {
382:                        String fileExt = fileName.substring(i + 1);
383:                        if ("txt".equalsIgnoreCase(fileExt)) {
384:                            return true;
385:                        }
386:                    }
387:                    return false;
388:                }
389:
390:                @Override
391:                public String getDescription() {
392:                    return description;
393:                }
394:            }
395:
396:            private class ConfirmExit implements  Application.ExitListener {
397:                public boolean canExit(EventObject e) {
398:                    if (isModified()) {
399:                        String confirmExitText = getResourceMap().getString(
400:                                "confirmTextExit", getFile());
401:                        int option = JOptionPane.showConfirmDialog(getFrame(),
402:                                confirmExitText);
403:                        return option == JOptionPane.YES_OPTION;
404:                        // TODO: also offer saving
405:                    } else {
406:                        return true;
407:                    }
408:                }
409:
410:                public void willExit(EventObject e) {
411:                }
412:            }
413:
414:            /** This method is called from within the constructor to
415:             * initialize the form.
416:             * WARNING: Do NOT modify this code. The content of this method is
417:             * always regenerated by the Form Editor.
418:             */
419:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
420:            private void initComponents() {
421:
422:                mainPanel = new javax.swing.JPanel();
423:                scrollPane = new javax.swing.JScrollPane();
424:                textArea = new javax.swing.JTextArea();
425:                menuBar = new javax.swing.JMenuBar();
426:                javax.swing.JMenu fileMenu = new javax.swing.JMenu();
427:                javax.swing.JMenuItem openMenuItem = new javax.swing.JMenuItem();
428:                javax.swing.JMenuItem saveMenuItem = new javax.swing.JMenuItem();
429:                javax.swing.JMenuItem saveAsMenuItem = new javax.swing.JMenuItem();
430:                javax.swing.JSeparator fileMenuSeparator = new javax.swing.JSeparator();
431:                javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
432:                javax.swing.JMenu editMenu = new javax.swing.JMenu();
433:                javax.swing.JMenuItem cutMenuItem = new javax.swing.JMenuItem();
434:                javax.swing.JMenuItem copyMenuItem = new javax.swing.JMenuItem();
435:                javax.swing.JMenuItem pasteMenuItem = new javax.swing.JMenuItem();
436:                javax.swing.JMenu helpMenu = new javax.swing.JMenu();
437:                javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
438:                statusPanel = new javax.swing.JPanel();
439:                javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
440:                statusMessageLabel = new javax.swing.JLabel();
441:                statusAnimationLabel = new javax.swing.JLabel();
442:                progressBar = new javax.swing.JProgressBar();
443:                toolBar = new javax.swing.JToolBar();
444:                openToolBarButton = new javax.swing.JButton();
445:                saveToolBarButton = new javax.swing.JButton();
446:                cutToolBarButton = new javax.swing.JButton();
447:                copyToolBarButton = new javax.swing.JButton();
448:                pasteToolBarButton = new javax.swing.JButton();
449:
450:                mainPanel.setName("mainPanel"); // NOI18N
451:
452:                scrollPane.setName("scrollPane"); // NOI18N
453:
454:                textArea.setColumns(20);
455:                textArea.setRows(5);
456:                textArea.setName("textArea"); // NOI18N
457:                scrollPane.setViewportView(textArea);
458:
459:                org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(
460:                        mainPanel);
461:                mainPanel.setLayout(mainPanelLayout);
462:                mainPanelLayout.setHorizontalGroup(mainPanelLayout
463:                        .createParallelGroup(
464:                                org.jdesktop.layout.GroupLayout.LEADING).add(
465:                                scrollPane,
466:                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
467:                                500, Short.MAX_VALUE));
468:                mainPanelLayout.setVerticalGroup(mainPanelLayout
469:                        .createParallelGroup(
470:                                org.jdesktop.layout.GroupLayout.LEADING).add(
471:                                scrollPane,
472:                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
473:                                358, Short.MAX_VALUE));
474:                org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
475:                        .getInstance(documenteditor.DocumentEditorApp.class)
476:                        .getContext().getResourceMap(DocumentEditorView.class);
477:                resourceMap.injectComponents(mainPanel);
478:
479:                menuBar.setName("menuBar"); // NOI18N
480:
481:                fileMenu.setName("fileMenu"); // NOI18N
482:
483:                javax.swing.ActionMap actionMap = org.jdesktop.application.Application
484:                        .getInstance(documenteditor.DocumentEditorApp.class)
485:                        .getContext().getActionMap(DocumentEditorView.class,
486:                                this );
487:                openMenuItem.setAction(actionMap.get("open")); // NOI18N
488:                openMenuItem.setName("openMenuItem"); // NOI18N
489:                fileMenu.add(openMenuItem);
490:
491:                saveMenuItem.setAction(actionMap.get("save")); // NOI18N
492:                saveMenuItem.setName("saveMenuItem"); // NOI18N
493:                fileMenu.add(saveMenuItem);
494:
495:                saveAsMenuItem.setAction(actionMap.get("saveAs")); // NOI18N
496:                saveAsMenuItem.setName("saveAsMenuItem"); // NOI18N
497:                fileMenu.add(saveAsMenuItem);
498:
499:                fileMenuSeparator.setName("fileMenuSeparator"); // NOI18N
500:                fileMenu.add(fileMenuSeparator);
501:
502:                exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
503:                exitMenuItem.setName("exitMenuItem"); // NOI18N
504:                fileMenu.add(exitMenuItem);
505:
506:                menuBar.add(fileMenu);
507:
508:                editMenu.setName("editMenu"); // NOI18N
509:
510:                cutMenuItem.setAction(actionMap.get("cut"));
511:                cutMenuItem.setName("cutMenuItem"); // NOI18N
512:                editMenu.add(cutMenuItem);
513:
514:                copyMenuItem.setAction(actionMap.get("copy"));
515:                copyMenuItem.setName("copyMenuItem"); // NOI18N
516:                editMenu.add(copyMenuItem);
517:
518:                pasteMenuItem.setAction(actionMap.get("paste"));
519:                pasteMenuItem.setName("pasteMenuItem"); // NOI18N
520:                editMenu.add(pasteMenuItem);
521:
522:                menuBar.add(editMenu);
523:
524:                helpMenu.setName("helpMenu"); // NOI18N
525:
526:                aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
527:                aboutMenuItem.setName("aboutMenuItem"); // NOI18N
528:                helpMenu.add(aboutMenuItem);
529:
530:                menuBar.add(helpMenu);
531:                resourceMap.injectComponents(menuBar);
532:
533:                statusPanel.setName("statusPanel"); // NOI18N
534:
535:                statusMessageLabel.setName("statusMessageLabel"); // NOI18N
536:
537:                statusAnimationLabel
538:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
539:                statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
540:
541:                progressBar.setName("progressBar"); // NOI18N
542:
543:                org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(
544:                        statusPanel);
545:                statusPanel.setLayout(statusPanelLayout);
546:                statusPanelLayout
547:                        .setHorizontalGroup(statusPanelLayout
548:                                .createParallelGroup(
549:                                        org.jdesktop.layout.GroupLayout.LEADING)
550:                                .add(
551:                                        statusPanelSeparator,
552:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
553:                                        500, Short.MAX_VALUE)
554:                                .add(
555:                                        statusPanelLayout
556:                                                .createSequentialGroup()
557:                                                .addContainerGap()
558:                                                .add(statusMessageLabel)
559:                                                .addPreferredGap(
560:                                                        org.jdesktop.layout.LayoutStyle.RELATED,
561:                                                        326, Short.MAX_VALUE)
562:                                                .add(
563:                                                        progressBar,
564:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
565:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
566:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
567:                                                .addPreferredGap(
568:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
569:                                                .add(statusAnimationLabel)
570:                                                .addContainerGap()));
571:                statusPanelLayout
572:                        .setVerticalGroup(statusPanelLayout
573:                                .createParallelGroup(
574:                                        org.jdesktop.layout.GroupLayout.LEADING)
575:                                .add(
576:                                        statusPanelLayout
577:                                                .createSequentialGroup()
578:                                                .add(
579:                                                        statusPanelSeparator,
580:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
581:                                                        2,
582:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
583:                                                .addPreferredGap(
584:                                                        org.jdesktop.layout.LayoutStyle.RELATED,
585:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
586:                                                        Short.MAX_VALUE)
587:                                                .add(
588:                                                        statusPanelLayout
589:                                                                .createParallelGroup(
590:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
591:                                                                .add(
592:                                                                        statusMessageLabel)
593:                                                                .add(
594:                                                                        statusAnimationLabel)
595:                                                                .add(
596:                                                                        progressBar,
597:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
598:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
599:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
600:                                                .add(3, 3, 3)));
601:                resourceMap.injectComponents(statusPanel);
602:
603:                toolBar.setFloatable(false);
604:                toolBar.setRollover(true);
605:                toolBar.setName("toolBar"); // NOI18N
606:
607:                openToolBarButton.setAction(actionMap.get("open")); // NOI18N
608:                openToolBarButton.setFocusable(false);
609:                openToolBarButton
610:                        .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
611:                openToolBarButton.setName("openToolBarButton"); // NOI18N
612:                openToolBarButton
613:                        .setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
614:                toolBar.add(openToolBarButton);
615:
616:                saveToolBarButton.setAction(actionMap.get("save")); // NOI18N
617:                saveToolBarButton.setFocusable(false);
618:                saveToolBarButton
619:                        .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
620:                saveToolBarButton.setName("saveToolBarButton"); // NOI18N
621:                saveToolBarButton
622:                        .setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
623:                toolBar.add(saveToolBarButton);
624:
625:                cutToolBarButton.setAction(actionMap.get("cut"));
626:                cutToolBarButton.setFocusable(false);
627:                cutToolBarButton
628:                        .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
629:                cutToolBarButton.setName("cutToolBarButton"); // NOI18N
630:                cutToolBarButton
631:                        .setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
632:                toolBar.add(cutToolBarButton);
633:
634:                copyToolBarButton.setAction(actionMap.get("copy"));
635:                copyToolBarButton.setFocusable(false);
636:                copyToolBarButton
637:                        .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
638:                copyToolBarButton.setName("copyToolBarButton"); // NOI18N
639:                copyToolBarButton
640:                        .setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
641:                toolBar.add(copyToolBarButton);
642:
643:                pasteToolBarButton.setAction(actionMap.get("paste"));
644:                pasteToolBarButton.setFocusable(false);
645:                pasteToolBarButton
646:                        .setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
647:                pasteToolBarButton.setName("pasteToolBarButton"); // NOI18N
648:                pasteToolBarButton
649:                        .setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
650:                toolBar.add(pasteToolBarButton);
651:                resourceMap.injectComponents(toolBar);
652:
653:                setComponent(mainPanel);
654:                setMenuBar(menuBar);
655:                setStatusBar(statusPanel);
656:                setToolBar(toolBar);
657:            }// </editor-fold>//GEN-END:initComponents
658:
659:            // Variables declaration - do not modify//GEN-BEGIN:variables
660:            private javax.swing.JButton copyToolBarButton;
661:            private javax.swing.JButton cutToolBarButton;
662:            private javax.swing.JPanel mainPanel;
663:            private javax.swing.JMenuBar menuBar;
664:            private javax.swing.JButton openToolBarButton;
665:            private javax.swing.JButton pasteToolBarButton;
666:            private javax.swing.JProgressBar progressBar;
667:            private javax.swing.JButton saveToolBarButton;
668:            private javax.swing.JScrollPane scrollPane;
669:            private javax.swing.JLabel statusAnimationLabel;
670:            private javax.swing.JLabel statusMessageLabel;
671:            private javax.swing.JPanel statusPanel;
672:            private javax.swing.JTextArea textArea;
673:            private javax.swing.JToolBar toolBar;
674:            // End of variables declaration//GEN-END:variables
675:
676:            private final Timer messageTimer;
677:            private final Timer busyIconTimer;
678:            private final Icon idleIcon;
679:            private final Icon[] busyIcons = new Icon[15];
680:            private int busyIconIndex = 0;
681:
682:            private JDialog aboutBox;
683:
684:            private static final Logger logger = Logger
685:                    .getLogger(DocumentEditorView.class.getName());
686:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.