Source Code Cross Referenced for WindowPropertiesRecordableEditor.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.comp.Components;
027:        import jacareto.record.WindowPropertiesRecordable;
028:        import jacareto.struct.StructureElement;
029:        import jacareto.system.Environment;
030:        import jacareto.system.Language;
031:        import jacareto.toolkit.event.TextValueListener;
032:        import jacareto.toolkit.swing.IntegerTextField;
033:
034:        import java.awt.Component;
035:        import java.awt.FlowLayout;
036:        import java.awt.GridBagConstraints;
037:        import java.awt.GridBagLayout;
038:        import java.awt.Insets;
039:        import java.awt.Window;
040:        import java.awt.event.ActionEvent;
041:        import java.awt.event.ActionListener;
042:
043:        import java.util.Iterator;
044:        import java.util.Set;
045:
046:        import javax.swing.JButton;
047:        import javax.swing.JCheckBox;
048:        import javax.swing.JComboBox;
049:        import javax.swing.JFrame;
050:        import javax.swing.JLabel;
051:        import javax.swing.JPanel;
052:        import javax.swing.JTextField;
053:        import javax.swing.SwingConstants;
054:        import javax.swing.WindowConstants;
055:        import javax.swing.event.DocumentEvent;
056:
057:        /**
058:         * An editor for window properties recordables.
059:         *
060:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
061:         * @version 1.0
062:         */
063:        public class WindowPropertiesRecordableEditor extends Editor {
064:            /** The structure element to edit. */
065:            private StructureElement element;
066:
067:            /** The editor panel. */
068:            private JPanel editorPanel;
069:
070:            /** The combo box for window names. */
071:            private JComboBox windowNameBox;
072:
073:            /** Components for the title. */
074:            private JCheckBox titleCheckBox;
075:            private JTextField titleField;
076:
077:            /** Components for the isResizable property. */
078:            private JCheckBox resizableCheckBox;
079:            private JComboBox resizableComboBox;
080:
081:            /** Components for the isVisible property. */
082:            private JCheckBox visibleCheckBox;
083:            private JComboBox visibleComboBox;
084:
085:            /** Components for the isUndecorated property. */
086:            private JCheckBox undecoratedCheckBox;
087:            private JComboBox undecoratedComboBox;
088:
089:            /** Components for the size property. */
090:            private JCheckBox sizeCheckBox;
091:            private IntegerTextField widthField;
092:            private IntegerTextField heightField;
093:
094:            /** Components for the default close operation property. */
095:            private JCheckBox defaultCloseOperationCheckBox;
096:            private JComboBox defaultCloseOperationComboBox;
097:
098:            /** Components for the location property. */
099:            private JCheckBox locationCheckBox;
100:            private JComboBox locationComboBox;
101:            private IntegerTextField locationXField;
102:            private IntegerTextField locationYField;
103:
104:            /**
105:             * Create a new window properties recordable editor.
106:             *
107:             * @param env the environment
108:             */
109:            public WindowPropertiesRecordableEditor(Environment env) {
110:                super (env);
111:
112:                Language language = getLanguage();
113:
114:                editorPanel = new JPanel(new GridBagLayout());
115:
116:                GridBagConstraints c = new GridBagConstraints();
117:                c.insets = new Insets(5, 5, 5, 5);
118:
119:                // The window name combo box.
120:                JLabel windowNameLabel = new JLabel(
121:                        language
122:                                .getString("Recordables.WindowPropertiesRecordable.WindowName")
123:                                + ":");
124:                windowNameBox = new JComboBox();
125:                windowNameBox.addActionListener(new ActionListener() {
126:                    public void actionPerformed(ActionEvent e) {
127:                        if (getElement() != null) {
128:                            ((WindowPropertiesRecordable) getElement())
129:                                    .setWindowName((String) windowNameBox
130:                                            .getSelectedItem());
131:                        }
132:                    }
133:                });
134:                c.gridx = 0;
135:                c.gridy = 0;
136:                c.anchor = GridBagConstraints.WEST;
137:                c.fill = GridBagConstraints.BOTH;
138:                c.gridwidth = 1;
139:                c.gridheight = 1;
140:                c.weightx = 20;
141:                editorPanel.add(windowNameLabel, c);
142:                c.gridx = 1;
143:                c.gridy = 0;
144:                c.gridwidth = 3;
145:                editorPanel.add(windowNameBox, c);
146:
147:                // The title combo box.
148:                // The visible field
149:                titleCheckBox = new JCheckBox(
150:                        language
151:                                .getString("Recordables.WindowPropertiesRecordable.Title")
152:                                + ":");
153:                titleCheckBox.addActionListener(new ActionListener() {
154:                    public void actionPerformed(ActionEvent e) {
155:                        if (getElement() != null) {
156:                            ((WindowPropertiesRecordable) getElement())
157:                                    .setApplyTitle(titleCheckBox.isSelected());
158:                            titleField.setEnabled(titleCheckBox.isSelected());
159:                        }
160:                    }
161:                });
162:                titleField = new JTextField(30);
163:                titleField.getDocument().addDocumentListener(
164:                        new TextValueListener() {
165:                            public void textValueChanged(DocumentEvent e) {
166:                                if (isUpdateOnChange && (getElement() != null)) {
167:                                    ((WindowPropertiesRecordable) getElement())
168:                                            .setTitle(titleField.getText());
169:                                }
170:                            }
171:                        });
172:                c.gridx = 0;
173:                c.gridy = 1;
174:                c.gridwidth = 1;
175:                editorPanel.add(titleCheckBox, c);
176:                c.gridx = 1;
177:                c.gridy = 1;
178:                c.weightx = 30;
179:                c.gridwidth = 3;
180:                editorPanel.add(titleField, c);
181:
182:                // The default close operation field
183:                defaultCloseOperationCheckBox = new JCheckBox(
184:                        language
185:                                .getString("Recordables.WindowPropertiesRecordable.DefaultCloseOperation")
186:                                + ":");
187:                defaultCloseOperationCheckBox
188:                        .addActionListener(new ActionListener() {
189:                            public void actionPerformed(ActionEvent e) {
190:                                if (getElement() != null) {
191:                                    ((WindowPropertiesRecordable) getElement())
192:                                            .setApplyDefaultCloseOperation(defaultCloseOperationCheckBox
193:                                                    .isSelected());
194:                                    defaultCloseOperationComboBox
195:                                            .setEnabled(defaultCloseOperationCheckBox
196:                                                    .isSelected());
197:                                }
198:                            }
199:                        });
200:                defaultCloseOperationComboBox = new JComboBox();
201:                defaultCloseOperationComboBox
202:                        .addItem(language
203:                                .getString("Recordables.WindowPropertiesRecordable.CloseOperations.HideOnClose"));
204:                defaultCloseOperationComboBox
205:                        .addItem(language
206:                                .getString("Recordables.WindowPropertiesRecordable.CloseOperations.DisposeOnClose"));
207:                defaultCloseOperationComboBox
208:                        .addItem(language
209:                                .getString("Recordables.WindowPropertiesRecordable.CloseOperations.DoNothingOnClose"));
210:                defaultCloseOperationComboBox
211:                        .addItem(language
212:                                .getString("Recordables.WindowPropertiesRecordable.CloseOperations.ExitOnClose"));
213:                defaultCloseOperationComboBox
214:                        .addActionListener(new ActionListener() {
215:                            public void actionPerformed(ActionEvent e) {
216:                                if (isUpdateOnChange && (getElement() != null)) {
217:                                    switch (defaultCloseOperationComboBox
218:                                            .getSelectedIndex()) {
219:                                    case 0:
220:                                        ((WindowPropertiesRecordable) getElement())
221:                                                .setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
222:
223:                                        break;
224:
225:                                    case 1:
226:                                        ((WindowPropertiesRecordable) getElement())
227:                                                .setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
228:
229:                                        break;
230:
231:                                    case 2:
232:                                        ((WindowPropertiesRecordable) getElement())
233:                                                .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
234:
235:                                        break;
236:
237:                                    case 3:
238:                                        ((WindowPropertiesRecordable) getElement())
239:                                                .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
240:
241:                                        break;
242:                                    }
243:                                }
244:                            }
245:                        });
246:                c.gridx = 0;
247:                c.gridy = 2;
248:                c.gridwidth = 1;
249:                editorPanel.add(defaultCloseOperationCheckBox, c);
250:                c.gridx = 1;
251:                c.gridy = 2;
252:                c.weightx = 30;
253:                c.gridwidth = 2;
254:                editorPanel.add(defaultCloseOperationComboBox, c);
255:
256:                // The visible field
257:                visibleCheckBox = new JCheckBox(
258:                        language
259:                                .getString("Recordables.WindowPropertiesRecordable.Visible")
260:                                + ":");
261:                visibleCheckBox.addActionListener(new ActionListener() {
262:                    public void actionPerformed(ActionEvent e) {
263:                        if (getElement() != null) {
264:                            ((WindowPropertiesRecordable) getElement())
265:                                    .setApplyIsVisible(visibleCheckBox
266:                                            .isSelected());
267:                            visibleComboBox.setEnabled(visibleCheckBox
268:                                    .isSelected());
269:                        }
270:                    }
271:                });
272:                visibleComboBox = new JComboBox();
273:                visibleComboBox.addItem(language.getString("General.True"));
274:                visibleComboBox.addItem(language.getString("General.False"));
275:                visibleComboBox.addActionListener(new ActionListener() {
276:                    public void actionPerformed(ActionEvent e) {
277:                        if (isUpdateOnChange && (getElement() != null)) {
278:                            ((WindowPropertiesRecordable) getElement())
279:                                    .setIsVisible(visibleComboBox
280:                                            .getSelectedIndex() == 0);
281:                        }
282:                    }
283:                });
284:                c.gridx = 0;
285:                c.gridy = 3;
286:                c.gridwidth = 1;
287:                editorPanel.add(visibleCheckBox, c);
288:                c.gridx = 1;
289:                c.gridy = 3;
290:                c.weightx = 30;
291:                c.gridwidth = 2;
292:                editorPanel.add(visibleComboBox, c);
293:
294:                // The resizable field
295:                resizableCheckBox = new JCheckBox(
296:                        language
297:                                .getString("Recordables.WindowPropertiesRecordable.Resizable")
298:                                + ":");
299:                resizableCheckBox.addActionListener(new ActionListener() {
300:                    public void actionPerformed(ActionEvent e) {
301:                        if (getElement() != null) {
302:                            ((WindowPropertiesRecordable) getElement())
303:                                    .setApplyIsResizable(resizableCheckBox
304:                                            .isSelected());
305:                            resizableComboBox.setEnabled(resizableCheckBox
306:                                    .isSelected());
307:                        }
308:                    }
309:                });
310:                resizableComboBox = new JComboBox();
311:                resizableComboBox.addItem(language.getString("General.True"));
312:                resizableComboBox.addItem(language.getString("General.False"));
313:                resizableComboBox.addActionListener(new ActionListener() {
314:                    public void actionPerformed(ActionEvent e) {
315:                        if (isUpdateOnChange && (getElement() != null)) {
316:                            ((WindowPropertiesRecordable) getElement())
317:                                    .setIsResizable(resizableComboBox
318:                                            .getSelectedIndex() == 0);
319:                        }
320:                    }
321:                });
322:
323:                c.gridx = 0;
324:                c.gridy = 4;
325:                c.gridwidth = 1;
326:                editorPanel.add(resizableCheckBox, c);
327:                c.gridx = 1;
328:                c.gridwidth = 2;
329:                editorPanel.add(resizableComboBox, c);
330:
331:                // The undecorated field
332:                undecoratedCheckBox = new JCheckBox(
333:                        language
334:                                .getString("Recordables.WindowPropertiesRecordable.Undecorated")
335:                                + ":");
336:                undecoratedCheckBox.addActionListener(new ActionListener() {
337:                    public void actionPerformed(ActionEvent e) {
338:                        if (getElement() != null) {
339:                            ((WindowPropertiesRecordable) getElement())
340:                                    .setApplyIsUndecorated(undecoratedCheckBox
341:                                            .isSelected());
342:                            undecoratedComboBox.setEnabled(undecoratedCheckBox
343:                                    .isSelected());
344:                        }
345:                    }
346:                });
347:                undecoratedComboBox = new JComboBox();
348:                undecoratedComboBox.addItem(language.getString("General.True"));
349:                undecoratedComboBox
350:                        .addItem(language.getString("General.False"));
351:                undecoratedComboBox.addActionListener(new ActionListener() {
352:                    public void actionPerformed(ActionEvent e) {
353:                        if (isUpdateOnChange && (getElement() != null)) {
354:                            ((WindowPropertiesRecordable) getElement())
355:                                    .setIsUndecorated(undecoratedComboBox
356:                                            .getSelectedIndex() == 0);
357:                        }
358:                    }
359:                });
360:
361:                c.gridx = 0;
362:                c.gridy = 5;
363:                c.gridwidth = 1;
364:                editorPanel.add(undecoratedCheckBox, c);
365:                c.gridx = 1;
366:                c.gridwidth = 2;
367:                editorPanel.add(undecoratedComboBox, c);
368:
369:                // The size components
370:                sizeCheckBox = new JCheckBox(
371:                        language
372:                                .getString("Recordables.WindowPropertiesRecordable.Width")
373:                                + ":");
374:                sizeCheckBox.addActionListener(new ActionListener() {
375:                    public void actionPerformed(ActionEvent e) {
376:                        if (getElement() != null) {
377:                            ((WindowPropertiesRecordable) getElement())
378:                                    .setApplySize(sizeCheckBox.isSelected());
379:                            widthField.setEnabled(sizeCheckBox.isSelected());
380:                            heightField.setEnabled(sizeCheckBox.isSelected());
381:                        }
382:                    }
383:                });
384:                c.gridx = 0;
385:                c.gridy = 6;
386:                c.gridwidth = 1;
387:                editorPanel.add(sizeCheckBox, c);
388:
389:                widthField = new IntegerTextField(4);
390:                widthField.getDocument().addDocumentListener(
391:                        new TextValueListener() {
392:                            public void textValueChanged(DocumentEvent e) {
393:                                if (isUpdateOnChange && (getElement() != null)) {
394:                                    ((WindowPropertiesRecordable) getElement())
395:                                            .setWidth(widthField.getValue());
396:                                }
397:                            }
398:                        });
399:                c.gridx = 1;
400:                editorPanel.add(widthField, c);
401:
402:                heightField = new IntegerTextField(4);
403:                heightField.getDocument().addDocumentListener(
404:                        new TextValueListener() {
405:                            public void textValueChanged(DocumentEvent e) {
406:                                if (isUpdateOnChange && (getElement() != null)) {
407:                                    ((WindowPropertiesRecordable) getElement())
408:                                            .setHeight(heightField.getValue());
409:                                }
410:                            }
411:                        });
412:
413:                JLabel heightLabel = new JLabel(
414:                        " "
415:                                + language
416:                                        .getString("Recordables.WindowPropertiesRecordable.Height")
417:                                + ":");
418:                c.gridx = 2;
419:                c.weightx = 20;
420:                editorPanel.add(heightLabel, c);
421:                c.gridx = 3;
422:                c.weightx = 30;
423:                editorPanel.add(heightField, c);
424:
425:                // The location components
426:                // The resizable field
427:                locationCheckBox = new JCheckBox(
428:                        language
429:                                .getString("Recordables.WindowPropertiesRecordable.Location")
430:                                + ":");
431:                locationCheckBox.addActionListener(new ActionListener() {
432:                    public void actionPerformed(ActionEvent e) {
433:                        if (getElement() != null) {
434:                            boolean isSelected = locationCheckBox.isSelected();
435:                            ((WindowPropertiesRecordable) getElement())
436:                                    .setApplyLocation(isSelected);
437:                            locationComboBox.setEnabled(isSelected);
438:                            locationXField
439:                                    .setEnabled(isSelected
440:                                            && (locationComboBox
441:                                                    .getSelectedIndex() == WindowPropertiesRecordable.CUSTOM_LOCATION));
442:                            locationYField
443:                                    .setEnabled(isSelected
444:                                            && (locationComboBox
445:                                                    .getSelectedIndex() == WindowPropertiesRecordable.CUSTOM_LOCATION));
446:                        }
447:                    }
448:                });
449:                c.gridx = 0;
450:                c.gridy = 7;
451:                c.gridwidth = 1;
452:                editorPanel.add(locationCheckBox, c);
453:
454:                locationComboBox = new JComboBox();
455:                locationComboBox
456:                        .addItem(language
457:                                .getString("Recordables.WindowPropertiesRecordable.Custom"));
458:                locationComboBox.addItem(language
459:                        .getString("General.Direction.Center"));
460:                locationComboBox.addItem(language
461:                        .getString("General.Direction.NorthWest"));
462:                locationComboBox.addItem(language
463:                        .getString("General.Direction.North"));
464:                locationComboBox.addItem(language
465:                        .getString("General.Direction.NorthEast"));
466:                locationComboBox.addItem(language
467:                        .getString("General.Direction.East"));
468:                locationComboBox.addItem(language
469:                        .getString("General.Direction.SouthEast"));
470:                locationComboBox.addItem(language
471:                        .getString("General.Direction.South"));
472:                locationComboBox.addItem(language
473:                        .getString("General.Direction.SouthWest"));
474:                locationComboBox.addItem(language
475:                        .getString("General.Direction.West"));
476:                locationComboBox.addActionListener(new ActionListener() {
477:                    public void actionPerformed(ActionEvent e) {
478:                        if (isUpdateOnChange && (getElement() != null)) {
479:                            int selectedIndex = locationComboBox
480:                                    .getSelectedIndex();
481:                            ((WindowPropertiesRecordable) getElement())
482:                                    .setLocation(selectedIndex);
483:                            locationXField
484:                                    .setEnabled(selectedIndex == WindowPropertiesRecordable.CUSTOM_LOCATION);
485:                            locationYField
486:                                    .setEnabled(selectedIndex == WindowPropertiesRecordable.CUSTOM_LOCATION);
487:                        }
488:                    }
489:                });
490:
491:                c.gridx = 1;
492:                c.gridwidth = 3;
493:                editorPanel.add(locationComboBox, c);
494:
495:                JLabel locationXLabel = new JLabel(language
496:                        .getString("General.Coordinates.X")
497:                        + ":", SwingConstants.RIGHT);
498:                c.gridx = 0;
499:                c.gridy = 8;
500:                c.gridwidth = 1;
501:                editorPanel.add(locationXLabel, c);
502:
503:                locationXField = new IntegerTextField(4);
504:                locationXField.getDocument().addDocumentListener(
505:                        new TextValueListener() {
506:                            public void textValueChanged(DocumentEvent e) {
507:                                if (isUpdateOnChange && (getElement() != null)) {
508:                                    ((WindowPropertiesRecordable) getElement())
509:                                            .setLocationX(locationXField
510:                                                    .getValue());
511:                                }
512:                            }
513:                        });
514:                c.gridx = 1;
515:                editorPanel.add(locationXField, c);
516:
517:                JLabel locationYLabel = new JLabel(language
518:                        .getString("General.Coordinates.Y")
519:                        + ":", SwingConstants.RIGHT);
520:                c.gridx = 2;
521:                editorPanel.add(locationYLabel, c);
522:
523:                locationYField = new IntegerTextField(4);
524:                locationYField.getDocument().addDocumentListener(
525:                        new TextValueListener() {
526:                            public void textValueChanged(DocumentEvent e) {
527:                                if (isUpdateOnChange && (getElement() != null)) {
528:                                    ((WindowPropertiesRecordable) getElement())
529:                                            .setLocationY(locationYField
530:                                                    .getValue());
531:                                }
532:                            }
533:                        });
534:                c.gridx = 3;
535:                editorPanel.add(locationYField, c);
536:
537:                // The buttons
538:                JButton getValuesButton = new JButton(language
539:                        .getString("Editors.WindowPropertiesEditor.GetValues"));
540:                getValuesButton.addActionListener(new ActionListener() {
541:                    public void actionPerformed(ActionEvent e) {
542:                        if (getElement() != null) {
543:                            WindowPropertiesRecordable wpRecordable = (WindowPropertiesRecordable) getElement();
544:                            Components components = getComponents();
545:                            String windowName = wpRecordable.getWindowName();
546:                            Component component = components
547:                                    .getComponent(windowName);
548:
549:                            if ((component != null)
550:                                    && (component instanceof  Window)) {
551:                                wpRecordable.setProperties((Window) component,
552:                                        components);
553:                                setElement(getElement());
554:                            }
555:                        }
556:                    }
557:                });
558:
559:                JButton applyButton = new JButton(language
560:                        .getString("Editors.WindowPropertiesEditor.Apply"));
561:                applyButton.addActionListener(new ActionListener() {
562:                    public void actionPerformed(ActionEvent e) {
563:                        if (getElement() != null) {
564:                            WindowPropertiesRecordable wpRecordable = (WindowPropertiesRecordable) getElement();
565:                            Components components = getComponents();
566:                            String windowName = wpRecordable.getWindowName();
567:                            Component component = components
568:                                    .getComponent(windowName);
569:
570:                            if ((component != null)
571:                                    && (component instanceof  Window)) {
572:                                wpRecordable.apply((Window) component);
573:                            }
574:                        }
575:                    }
576:                });
577:
578:                JPanel buttonPanel = new JPanel(new FlowLayout());
579:                buttonPanel.add(getValuesButton);
580:                buttonPanel.add(applyButton);
581:                c.gridx = 0;
582:                c.gridy = 9;
583:                c.gridwidth = 4;
584:                editorPanel.add(buttonPanel, c);
585:            }
586:
587:            /**
588:             * Returns whether this editor is responsible for a given structure element. This editor is
589:             * responsible for window properties recordables.
590:             *
591:             * @param element the structure element
592:             *
593:             * @return <code>true</code> if <i>element</i> is an window properties recordable and not
594:             *         <code>null</code>, otherwise <code>false</code>
595:             */
596:            public boolean handlesElement(StructureElement element) {
597:                return (element != null)
598:                        && (element instanceof  WindowPropertiesRecordable);
599:            }
600:
601:            /**
602:             * Returns the actual structure element to be edited.
603:             *
604:             * @return the element
605:             */
606:            public StructureElement getElement() {
607:                return element;
608:            }
609:
610:            /**
611:             * Returns the component for editing the specified structure element.
612:             *
613:             * @return the editor component
614:             */
615:            public Component getComponent() {
616:                return editorPanel;
617:            }
618:
619:            /**
620:             * Sets the structure element to edit.
621:             *
622:             * @param element the structure element
623:             */
624:            public void setElement(StructureElement element) {
625:                this .element = element;
626:
627:                WindowPropertiesRecordable wpRecordable = (WindowPropertiesRecordable) element;
628:                String containedWindowName = wpRecordable.getWindowName();
629:                boolean containsWindowName = (containedWindowName != null)
630:                        && !containedWindowName.equals("");
631:
632:                // visible components
633:                visibleCheckBox.setSelected(wpRecordable.getApplyIsVisible());
634:
635:                if (wpRecordable.getIsVisible()) {
636:                    visibleComboBox.setSelectedIndex(0);
637:                } else {
638:                    visibleComboBox.setSelectedIndex(1);
639:                }
640:
641:                visibleComboBox.setEnabled(wpRecordable.getApplyIsVisible());
642:
643:                titleField.setText(wpRecordable.getTitle());
644:                titleCheckBox.setSelected(wpRecordable.getApplyTitle());
645:                titleField.setEnabled(wpRecordable.getApplyTitle());
646:
647:                defaultCloseOperationCheckBox.setSelected(wpRecordable
648:                        .getApplyDefaultCloseOperation());
649:
650:                switch (wpRecordable.getDefaultCloseOperation()) {
651:                case WindowConstants.HIDE_ON_CLOSE:
652:                    defaultCloseOperationComboBox.setSelectedIndex(0);
653:
654:                    break;
655:
656:                case WindowConstants.DISPOSE_ON_CLOSE:
657:                    defaultCloseOperationComboBox.setSelectedIndex(1);
658:
659:                    break;
660:
661:                case WindowConstants.DO_NOTHING_ON_CLOSE:
662:                    defaultCloseOperationComboBox.setSelectedIndex(2);
663:
664:                    break;
665:
666:                case JFrame.EXIT_ON_CLOSE:
667:                    defaultCloseOperationComboBox.setSelectedIndex(3);
668:
669:                    break;
670:                }
671:
672:                defaultCloseOperationComboBox.setEnabled(wpRecordable
673:                        .getApplyDefaultCloseOperation());
674:
675:                // resizable components
676:                resizableCheckBox.setSelected(wpRecordable
677:                        .getApplyIsResizable());
678:
679:                if (wpRecordable.getIsResizable()) {
680:                    resizableComboBox.setSelectedIndex(0);
681:                } else {
682:                    resizableComboBox.setSelectedIndex(1);
683:                }
684:
685:                resizableComboBox
686:                        .setEnabled(wpRecordable.getApplyIsResizable());
687:
688:                // undecorated components
689:                undecoratedCheckBox.setSelected(wpRecordable
690:                        .getApplyIsUndecorated());
691:
692:                if (wpRecordable.getIsUndecorated()) {
693:                    undecoratedComboBox.setSelectedIndex(0);
694:                } else {
695:                    undecoratedComboBox.setSelectedIndex(1);
696:                }
697:
698:                undecoratedComboBox.setEnabled(wpRecordable
699:                        .getApplyIsUndecorated());
700:
701:                // size components
702:                sizeCheckBox.setSelected(wpRecordable.getApplySize());
703:                widthField.setValue(wpRecordable.getWidth());
704:                heightField.setValue(wpRecordable.getHeight());
705:                widthField.setEnabled(wpRecordable.getApplySize());
706:                heightField.setEnabled(wpRecordable.getApplySize());
707:
708:                // location components
709:                boolean applyLocation = wpRecordable.getApplyLocation();
710:                int location = wpRecordable.getLocation();
711:                locationCheckBox.setSelected(applyLocation);
712:                locationComboBox.setSelectedIndex(location);
713:                locationXField.setValue(wpRecordable.getLocationX());
714:                locationYField.setValue(wpRecordable.getLocationY());
715:                locationComboBox.setEnabled(applyLocation);
716:                locationXField
717:                        .setEnabled(applyLocation
718:                                && (location == WindowPropertiesRecordable.CUSTOM_LOCATION));
719:                locationYField
720:                        .setEnabled(applyLocation
721:                                && (location == WindowPropertiesRecordable.CUSTOM_LOCATION));
722:
723:                // Add window names to combo box
724:                boolean containedWindowNameFound = false;
725:                windowNameBox.removeAllItems();
726:
727:                Components components = getComponents();
728:                Set roots = components.getIncludedRoots();
729:                Iterator it = roots.iterator();
730:
731:                while (it.hasNext()) {
732:                    Object root = it.next();
733:
734:                    if (root instanceof  Window) {
735:                        String windowName = components.getName((Window) root);
736:                        windowNameBox.addItem(windowName);
737:                        containedWindowNameFound = containsWindowName
738:                                && containedWindowName.equals(windowName);
739:                    }
740:                }
741:
742:                if (containsWindowName && !containedWindowNameFound) {
743:                    windowNameBox.addItem(containedWindowName);
744:                }
745:
746:                if (containsWindowName) {
747:                    windowNameBox.setSelectedItem(containedWindowName);
748:                }
749:            }
750:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.