Source Code Cross Referenced for ScriptingWin.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.Scripting;
004:        import jimm.datavision.gui.cmd.ScriptingCommand;
005:        import jimm.util.I18N;
006:        import java.util.*;
007:        import java.awt.BorderLayout;
008:        import java.awt.event.*;
009:        import javax.swing.*;
010:        import javax.swing.event.DocumentListener;
011:        import javax.swing.event.DocumentEvent;
012:
013:        /**
014:         * Editor dialog for a report's scripting language list and default language.
015:         *
016:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
017:         */
018:        public class ScriptingWin extends EditWin implements  ItemListener,
019:                ActionListener, DocumentListener {
020:
021:            protected static final int LANG_NAME_COLS = 16;
022:            protected static final int CLASS_NAME_COLS = 40;
023:
024:            protected Scripting scripting;
025:            protected JComboBox defaultLangMenu;
026:            protected JTextField langName;
027:            protected JTextField langClass;
028:            protected JButton addLangButton;
029:            protected JButton testLangButton;
030:            protected String defaultLang;
031:            protected Map languages;
032:
033:            /**
034:             * Constructor.
035:             *
036:             * @param designer the window to which this dialog belongs
037:             * @param scripting the scripting language information container
038:             */
039:            public ScriptingWin(Designer designer, Scripting scripting) {
040:                super (designer, I18N.get("ScriptingWin.title"),
041:                        "ScriptingCommand.name");
042:
043:                this .scripting = scripting;
044:                defaultLang = scripting.getDefaultLanguage();
045:                languages = new HashMap(scripting.getLanguages()); // Make a copy
046:
047:                buildWindow();
048:                pack();
049:                setVisible(true);
050:            }
051:
052:            /**
053:             * Builds the window contents.
054:             */
055:            protected void buildWindow() {
056:                // All edit fields
057:                JPanel editorPanel = buildEditor();
058:
059:                // OK, Apply, Revert, and Cancel Buttons
060:                JPanel buttonPanel = closeButtonPanel();
061:
062:                // Add values and buttons to window
063:                getContentPane().add(editorPanel, BorderLayout.CENTER);
064:                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
065:
066:                fillEditFields();
067:            }
068:
069:            protected JPanel buildEditor() {
070:                EditFieldLayout efl = new EditFieldLayout();
071:
072:                defaultLangMenu = efl.addComboBox(I18N
073:                        .get("ScriptingWin.default_lang"), langChoices());
074:                defaultLangMenu.addItemListener(this );
075:
076:                efl.skipRow();
077:                langName = efl.addTextField(I18N.get("ScriptingWin.add_name"),
078:                        "", LANG_NAME_COLS);
079:                langClass = efl
080:                        .addTextField(I18N.get("ScriptingWin.add_class"), "",
081:                                CLASS_NAME_COLS);
082:
083:                langName.getDocument().addDocumentListener(this );
084:                langClass.getDocument().addDocumentListener(this );
085:
086:                JPanel buttonPanel = new JPanel();
087:                addLangButton = new JButton(I18N.get("ScriptingWin.add_button"));
088:                testLangButton = new JButton(I18N
089:                        .get("ScriptingWin.test_button"));
090:
091:                buttonPanel.add(addLangButton);
092:                buttonPanel.add(testLangButton);
093:                efl.add("", buttonPanel);
094:
095:                addLangButton.addActionListener(this );
096:                testLangButton.addActionListener(this );
097:
098:                return efl.getPanel();
099:            }
100:
101:            protected Object[] langChoices() {
102:                return languages.keySet().toArray();
103:            }
104:
105:            /** Fill with initial values. */
106:            protected void fillEditFields() {
107:                fillEditFields(defaultLang);
108:            }
109:
110:            /** Fill drop-down menu and text fields based on <var>lang</var>. */
111:            protected void fillEditFields(String lang) {
112:                defaultLangMenu.setSelectedItem(lang);
113:                langName.setText(lang);
114:                langClass.setText((String) languages.get(lang));
115:                enableButtons();
116:            }
117:
118:            /** When language selected from popup, populate name and class fields. */
119:            public void itemStateChanged(ItemEvent e) {
120:                fillEditFields(e.getItem().toString());
121:            }
122:
123:            public void actionPerformed(ActionEvent e) {
124:                String cmd = e.getActionCommand();
125:                if (I18N.get("ScriptingWin.add_button").equals(cmd))
126:                    addLanguage();
127:                else if (I18N.get("ScriptingWin.test_button").equals(cmd))
128:                    testLanguage();
129:                else
130:                    super .actionPerformed(e);
131:            }
132:
133:            protected void addLanguage() {
134:                String name = langName.getText().trim();
135:                String klass = langClass.getText().trim();
136:
137:                if (languages.get(name) == null) // Only add to menu if new
138:                    defaultLangMenu.addItem(name);
139:                languages.put(name, klass); // Add or replace
140:                fillEditFields();
141:            }
142:
143:            protected void testLanguage() {
144:                String klass = langClass.getText().trim();
145:
146:                String msg = null;
147:                int type;
148:                if (scripting.canFind(klass)) {
149:                    msg = I18N.get("ScriptingWin.lang_ok");
150:                    type = JOptionPane.INFORMATION_MESSAGE;
151:                } else {
152:                    msg = I18N.get("ScriptingWin.lang_err");
153:                    type = JOptionPane.ERROR_MESSAGE;
154:                }
155:                JOptionPane.showMessageDialog(null, msg, I18N
156:                        .get("ScriptingWin.title"), type);
157:            }
158:
159:            public void changedUpdate(DocumentEvent e) {
160:                enableButtons();
161:            }
162:
163:            public void insertUpdate(DocumentEvent e) {
164:                enableButtons();
165:            }
166:
167:            public void removeUpdate(DocumentEvent e) {
168:                enableButtons();
169:            }
170:
171:            protected void enableButtons() {
172:                boolean enable = langName.getText().trim().length() > 0
173:                        && langClass.getText().trim().length() > 0;
174:                addLangButton.setEnabled(enable);
175:                testLangButton.setEnabled(enable);
176:            }
177:
178:            protected void doSave() {
179:                defaultLang = (String) defaultLangMenu.getSelectedItem();
180:                ScriptingCommand cmd = new ScriptingCommand(scripting,
181:                        defaultLang, languages);
182:                cmd.perform();
183:                commands.add(cmd);
184:            }
185:
186:            protected void doRevert() {
187:                fillEditFields();
188:            }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.