Source Code Cross Referenced for StarterEditor.java in  » Testing » jacareto » jacareto » editor » 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 » Testing » jacareto » jacareto.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.editor;
025:
026:        import jacareto.starter.Starter;
027:        import jacareto.struct.StructureElement;
028:        import jacareto.system.Environment;
029:        import jacareto.system.Language;
030:        import jacareto.toolkit.event.TextValueListener;
031:        import jacareto.toolkit.swing.LongTextField;
032:
033:        import java.awt.Component;
034:        import java.awt.GridBagConstraints;
035:        import java.awt.GridBagLayout;
036:        import java.awt.Insets;
037:        import java.awt.event.ActionEvent;
038:        import java.awt.event.ActionListener;
039:
040:        import javax.swing.JCheckBox;
041:        import javax.swing.JLabel;
042:        import javax.swing.JPanel;
043:        import javax.swing.JTextField;
044:        import javax.swing.event.DocumentEvent;
045:
046:        /**
047:         * <p>
048:         * An editor for starters. Because the class <code>Starter</code> is abstract, this class should be
049:         * extended for the specific structure elements which inherit from <code>Starter</code>.
050:         * </p>
051:         * 
052:         * <p>
053:         * If a subclass overwrites the method {@link #setElement(StructureElement)}, it should call the
054:         * method of its superclass first.
055:         * </p>
056:         *
057:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
058:         * @version 1.03
059:         */
060:        public class StarterEditor extends Editor {
061:            /** The editor's component. */
062:            protected JPanel editorPanel;
063:
064:            /** The grid bag constraints. */
065:            protected GridBagConstraints c;
066:
067:            /** The structure element to edit. */
068:            private StructureElement element;
069:
070:            /** The text field for the name. */
071:            private JTextField nameField;
072:
073:            /** The text field for the classname. */
074:            private JTextField classnameField;
075:
076:            /** The text field for the classpath extension. */
077:            private JTextField classpathExtField;
078:
079:            /** The text field for the initializer classname. */
080:            private JTextField initClassnameField;
081:
082:            /** The text field for the start up duration. */
083:            private LongTextField durationField;
084:
085:            /** The checkbox for the detect duration attribute. */
086:            private JCheckBox detectDurationCheckbox;
087:
088:            /**
089:             * Create a new starter editor.
090:             *
091:             * @param env the environment
092:             */
093:            public StarterEditor(Environment env) {
094:                super (env);
095:
096:                Language language = getLanguage();
097:
098:                editorPanel = new JPanel();
099:                editorPanel.setLayout(new GridBagLayout());
100:
101:                // The name field label
102:                c = new GridBagConstraints();
103:                c.gridx = 0;
104:                c.gridy = 0;
105:                c.weightx = 30;
106:
107:                //c.ipady = 3;
108:                //c.ipadx = 5;
109:                c.insets = new Insets(5, 5, 5, 5);
110:                c.anchor = GridBagConstraints.WEST;
111:
112:                JLabel nameFieldLabel = new JLabel(language
113:                        .getString("Starters.Starter.Attributes.Name")
114:                        + ":");
115:                editorPanel.add(nameFieldLabel, c);
116:
117:                // The name field
118:                c.gridx = 1;
119:                c.weightx = 60;
120:                nameField = new JTextField(20);
121:                nameField.getDocument().addDocumentListener(
122:                        new TextValueListener() {
123:                            public void textValueChanged(DocumentEvent e) {
124:                                if (isUpdateOnChange && (getElement() != null)) {
125:                                    ((Starter) getElement()).setName(nameField
126:                                            .getText());
127:                                }
128:                            }
129:                        });
130:                editorPanel.add(nameField, c);
131:                nameFieldLabel.setLabelFor(nameField);
132:
133:                // The classname field label
134:                c.gridx = 0;
135:                c.gridy = 1;
136:
137:                JLabel classnameFieldLabel = new JLabel(language
138:                        .getString("Starters.Starter.Attributes.Classname")
139:                        + ":");
140:                editorPanel.add(classnameFieldLabel, c);
141:
142:                // The classname field
143:                c.gridx = 1;
144:                classnameField = new JTextField(20);
145:                classnameField.getDocument().addDocumentListener(
146:                        new TextValueListener() {
147:                            public void textValueChanged(DocumentEvent e) {
148:                                if (isUpdateOnChange && (getElement() != null)) {
149:                                    ((Starter) getElement())
150:                                            .setClassname(classnameField
151:                                                    .getText());
152:                                }
153:                            }
154:                        });
155:                editorPanel.add(classnameField, c);
156:                classnameFieldLabel.setLabelFor(classnameField);
157:
158:                // The classpath extension field label
159:                c.gridx = 0;
160:                c.gridy = 2;
161:
162:                JLabel classpathExtFieldLabel = new JLabel(
163:                        language
164:                                .getString("Starters.Starter.Attributes.ClassPathExtension")
165:                                + ":");
166:                editorPanel.add(classpathExtFieldLabel, c);
167:
168:                // The classpath ext field
169:                c.gridx = 1;
170:                classpathExtField = new JTextField(20);
171:                classpathExtField.getDocument().addDocumentListener(
172:                        new TextValueListener() {
173:                            public void textValueChanged(DocumentEvent e) {
174:                                if (isUpdateOnChange && (getElement() != null)) {
175:                                    ((Starter) getElement())
176:                                            .setClassPathExtension(classpathExtField
177:                                                    .getText());
178:                                }
179:                            }
180:                        });
181:                editorPanel.add(classpathExtField, c);
182:                classpathExtFieldLabel.setLabelFor(classpathExtField);
183:
184:                // The initializer classname field label
185:                c.gridx = 0;
186:                c.gridy = 3;
187:
188:                JLabel initClassnameFieldLabel = new JLabel(language
189:                        .getString("Starters.Starter.Attributes.InitClassname")
190:                        + ":");
191:                editorPanel.add(initClassnameFieldLabel, c);
192:
193:                // The initializer classname field
194:                c.gridx = 1;
195:                initClassnameField = new JTextField(20);
196:                initClassnameField.getDocument().addDocumentListener(
197:                        new TextValueListener() {
198:                            public void textValueChanged(DocumentEvent e) {
199:                                if (isUpdateOnChange && (getElement() != null)) {
200:                                    ((Starter) getElement())
201:                                            .setInitClassname(initClassnameField
202:                                                    .getText());
203:                                }
204:                            }
205:                        });
206:                editorPanel.add(initClassnameField, c);
207:                initClassnameFieldLabel.setLabelFor(initClassnameField);
208:
209:                // The duration field label
210:                c.gridx = 0;
211:                c.gridy = 4;
212:
213:                JLabel durationFieldLabel = new JLabel(language
214:                        .getString("Starters.Starter.Attributes.Duration")
215:                        + ":");
216:                editorPanel.add(durationFieldLabel, c);
217:
218:                // The duration field
219:                c.gridx = 1;
220:                durationField = new LongTextField(5);
221:                durationField.getDocument().addDocumentListener(
222:                        new TextValueListener() {
223:                            public void textValueChanged(DocumentEvent e) {
224:                                if (isUpdateOnChange && (getElement() != null)) {
225:                                    ((Starter) getElement())
226:                                            .setDuration(durationField
227:                                                    .getValue());
228:                                }
229:                            }
230:                        });
231:                editorPanel.add(durationField, c);
232:                durationFieldLabel.setLabelFor(durationField);
233:
234:                // The detect duration field label (empty)
235:                c.gridx = 0;
236:                c.gridy = 5;
237:
238:                JLabel detectDurationFieldLabel = new JLabel("");
239:                editorPanel.add(detectDurationFieldLabel, c);
240:
241:                // The duration field
242:                c.gridx = 1;
243:                detectDurationCheckbox = new JCheckBox(
244:                        language
245:                                .getString("Starters.Starter.Attributes.DetectStartupDuration"));
246:                detectDurationCheckbox.addActionListener(new ActionListener() {
247:                    public void actionPerformed(ActionEvent e) {
248:                        if (isUpdateOnChange && (getElement() != null)) {
249:                            ((Starter) getElement())
250:                                    .setDetectDuration(detectDurationCheckbox
251:                                            .isSelected());
252:                            durationField.setEnabled(!detectDurationCheckbox
253:                                    .isSelected());
254:                        }
255:                    }
256:                });
257:                editorPanel.add(detectDurationCheckbox, c);
258:            }
259:
260:            /**
261:             * Returns whether this editor is responsible for a given structure element. This editor is
262:             * responsible for user recordables.
263:             *
264:             * @param element the structure element
265:             *
266:             * @return <code>true</code> if <i>element</i> is a starter recordable and not
267:             *         <code>null</code>, otherwise <code>false</code>
268:             */
269:            public boolean handlesElement(StructureElement element) {
270:                return (element != null) && (element instanceof  Starter);
271:            }
272:
273:            /**
274:             * Returns the actual recordable to be edited.
275:             *
276:             * @return DOCUMENT ME!
277:             */
278:            public StructureElement getElement() {
279:                return element;
280:            }
281:
282:            /**
283:             * Sets the structure element to edit.
284:             *
285:             * @param element DOCUMENT ME!
286:             */
287:            public void setElement(StructureElement element) {
288:                this .element = element;
289:
290:                Starter starter = (Starter) element;
291:                nameField.setText(starter.getName());
292:                classnameField.setText(starter.getClassname());
293:                initClassnameField.setText(starter.getInitClassname());
294:                durationField.setValue(starter.getDuration());
295:                detectDurationCheckbox.setSelected(starter.getDetectDuration());
296:
297:                durationField.setEnabled(!detectDurationCheckbox.isSelected());
298:
299:                String classpathext = starter.getClassPathExtension();
300:
301:                if (classpathext == null) {
302:                    classpathext = "";
303:                }
304:
305:                classpathExtField.setText(classpathext);
306:            }
307:
308:            /**
309:             * Returns the component of the editor.
310:             *
311:             * @return the editor component
312:             */
313:            public Component getComponent() {
314:                return editorPanel;
315:            }
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.