Source Code Cross Referenced for CodeEditorWin.java in  » Report » datavision-1.1.0 » jimm » datavision » gui » 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 » Report » datavision 1.1.0 » jimm.datavision.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui;
002:
003:        import jimm.datavision.Report;
004:        import jimm.datavision.ErrorHandler;
005:        import jimm.datavision.gui.cmd.Command;
006:        import jimm.util.I18N;
007:        import java.awt.Dimension;
008:        import java.awt.BorderLayout;
009:        import java.awt.event.ActionListener;
010:        import java.awt.event.ActionEvent;
011:        import javax.swing.*;
012:
013:        /**
014:         * This is the abstract superclass of windows used for editing paragraphs of
015:         * code such as formulas and where clauses. The text field accepts dragged
016:         * report fields by using a {@link DropListenerTextArea}.
017:         *
018:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
019:         */
020:        public abstract class CodeEditorWin extends JDialog implements 
021:                ActionListener {
022:
023:            protected static final Dimension EDIT_SIZE = new Dimension(400, 225);
024:
025:            protected Designer designer;
026:            protected JTextArea codeField;
027:            protected Command command;
028:            protected String errorSuffix;
029:            protected String errorTitle;
030:
031:            /**
032:             * Constructor.
033:             *
034:             * @param designer the design window to which this dialog belongs
035:             * @param report the report
036:             * @param initialText the initial text to edit
037:             * @param title the window title
038:             * @param errorSuffixKey I18N lookup key for error text suffix; may be
039:             * <code>null</code>
040:             * @param errorTitleKey I18N lookup key for error window title; may be
041:             * <code>null</code>
042:             */
043:            public CodeEditorWin(Designer designer, Report report,
044:                    String initialText, String title, String errorSuffixKey,
045:                    String errorTitleKey) {
046:                super (designer.getFrame(), title);
047:                this .designer = designer;
048:                errorSuffix = errorSuffixKey == null ? null : I18N
049:                        .get(errorSuffixKey);
050:                errorTitle = errorTitleKey == null ? null : I18N
051:                        .get(errorTitleKey);
052:                buildWindow(report, initialText);
053:                pack();
054:                setVisible(true);
055:            }
056:
057:            /**
058:             * Builds the window contents.
059:             *
060:             * @param report the report
061:             * @param initialText initial value of string
062:             */
063:            protected void buildWindow(Report report, String initialText) {
064:                codeField = new DropListenerTextArea(report,
065:                        initialText == null ? "" : initialText);
066:                JScrollPane scroller = new JScrollPane(codeField);
067:                scroller.setPreferredSize(EDIT_SIZE); // Set preferred size for editor
068:
069:                // Add edit panel and Ok/Cancel buttons to window
070:                getContentPane().add(scroller, BorderLayout.CENTER);
071:                getContentPane().add(buildButtonPanel(), BorderLayout.SOUTH);
072:
073:                new FocusSetter(codeField);
074:            }
075:
076:            /**
077:             * Builds and returns a panel containing the OK and Cancel
078:             *
079:             * @return a panel
080:             */
081:            protected JPanel buildButtonPanel() {
082:                JPanel buttonPanel = new JPanel();
083:                JButton button;
084:
085:                buttonPanel.add(button = new JButton(I18N.get("GUI.ok")));
086:                button.addActionListener(this );
087:                button.setDefaultCapable(true);
088:
089:                buttonPanel.add(button = new JButton(I18N.get("GUI.cancel")));
090:                button.addActionListener(this );
091:
092:                return buttonPanel;
093:            }
094:
095:            /**
096:             * Handles the OK and Cancel buttons. If performing the command throws
097:             * an error, we catch it and display it here and do not close this window.
098:             *
099:             * @param e action event
100:             */
101:            public void actionPerformed(ActionEvent e) {
102:                String cmd = e.getActionCommand();
103:                try {
104:                    if (I18N.get("GUI.ok").equals(cmd)) {
105:                        save(codeField.getText());
106:                        if (command != null)
107:                            designer.performCommand(command);
108:                        dispose();
109:                    } else if (I18N.get("GUI.cancel").equals(cmd)) {
110:                        dispose();
111:                    }
112:                } catch (Exception ex) {
113:                    String str = ex.toString();
114:                    if (errorSuffix != null)
115:                        str += "\n" + errorSuffix;
116:                    ErrorHandler.error(str, errorTitle);
117:
118:                    command = null;
119:                }
120:            }
121:
122:            /**
123:             * Implement this to do whatevery you gotta do with the text.
124:             * You'll probably want to set <var>command</var> so it gets sent
125:             * to the design window to be performed.
126:             *
127:             * @param text the text in the edit box
128:             */
129:            public abstract void save(String text);
130:
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.