Source Code Cross Referenced for PropertyEditorPane.java in  » Mail-Clients » pooka » net » suberic » util » gui » propedit » 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 » Mail Clients » pooka » net.suberic.util.gui.propedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.util.gui.propedit;
002:
003:        import javax.swing.*;
004:        import java.util.List;
005:        import java.util.LinkedList;
006:        import java.awt.*;
007:
008:        /**
009:         * This is a top-level editor for properties.  It includes buttons for
010:         * activating changes, accepting and closing, and cancelling the action.
011:         */
012:        public class PropertyEditorPane extends Box {
013:            SwingPropertyEditor editor;
014:            PropertyEditorManager manager;
015:            Container container;
016:            Box buttonBox;
017:            Box editorBox;
018:
019:            /**
020:             * This contructor creates a PropertyEditor for the list of 
021:             * properties in the properties List.
022:             */
023:            public PropertyEditorPane(PropertyEditorManager newManager,
024:                    List properties, Container newContainer) {
025:                this (newManager, properties, properties, newContainer);
026:            }
027:
028:            /**
029:             * This contructor creates a PropertyEditor for the list of 
030:             * properties in the properties List, using the template
031:             * types in the templates List.  Note that there should be
032:             * one entry in each of the properties List and the templates
033:             * List for each property to be edited.
034:             */
035:            public PropertyEditorPane(PropertyEditorManager newManager,
036:                    List properties, List templates, Container newContainer) {
037:                super (BoxLayout.Y_AXIS);
038:
039:                manager = newManager;
040:                container = newContainer;
041:
042:                editor = (SwingPropertyEditor) manager.createEditor(properties,
043:                        templates);
044:
045:                editorBox = new Box(BoxLayout.X_AXIS);
046:
047:                if (editor.getValueComponent() != null) {
048:                    if (editor.getLabelComponent() != null)
049:                        editorBox.add(editor.getLabelComponent());
050:                    editorBox.add(editor.getValueComponent());
051:                } else {
052:                    editorBox.add(editor);
053:                }
054:                this .add(editorBox);
055:
056:                this .addButtons();
057:            }
058:
059:            /**
060:             * This contructor creates a PropertyEditor using the given 
061:             * SwingPropertyEditor.
062:             */
063:            public PropertyEditorPane(PropertyEditorManager newManager,
064:                    SwingPropertyEditor newEditor, Container newContainer) {
065:                super (BoxLayout.Y_AXIS);
066:
067:                manager = newManager;
068:                container = newContainer;
069:
070:                editor = newEditor;
071:
072:                this .add(newEditor);
073:
074:                this .addButtons();
075:            }
076:
077:            /**
078:             * Accepts the changes for the edited properties, and writes them to
079:             * the PropertyEditorManager.
080:             */
081:            public void setValue() throws PropertyValueVetoException {
082:                editor.setValue();
083:            }
084:
085:            /**
086:             * Gets the currently selected values for the edited properties.
087:             */
088:            public java.util.Properties getValue() {
089:                return editor.getValue();
090:            }
091:
092:            /**
093:             * Resets the original values for the edited properties.
094:             */
095:            public void resetDefaultValue() throws PropertyValueVetoException {
096:                editor.resetDefaultValue();
097:            }
098:
099:            /**
100:             * Adds the appropriate buttons (Ok, Accept, Cancel) to this component.
101:             */
102:            public void addButtons() {
103:                buttonBox = new Box(BoxLayout.X_AXIS);
104:
105:                buttonBox.add(createButton("Ok", new AbstractAction() {
106:                    public void actionPerformed(java.awt.event.ActionEvent e) {
107:                        try {
108:                            setValue();
109:                            manager.commit();
110:                            if (container instanceof  JInternalFrame) {
111:                                try {
112:                                    ((JInternalFrame) container)
113:                                            .setClosed(true);
114:                                } catch (java.beans.PropertyVetoException pve) {
115:                                }
116:                            } else if (container instanceof  JFrame) {
117:                                ((JFrame) container).dispose();
118:                            }
119:                        } catch (PropertyValueVetoException pvve) {
120:                            manager.getFactory().showError(
121:                                    PropertyEditorPane.this ,
122:                                    "Error changing value "
123:                                            + pvve.getProperty() + " to "
124:                                            + pvve.getRejectedValue() + ":  "
125:                                            + pvve.getReason());
126:                        }
127:                    }
128:                }, true));
129:
130:                buttonBox.add(createButton("Apply", new AbstractAction() {
131:                    public void actionPerformed(java.awt.event.ActionEvent e) {
132:                        try {
133:                            setValue();
134:                            manager.commit();
135:                        } catch (PropertyValueVetoException pvve) {
136:                            manager.getFactory().showError(
137:                                    PropertyEditorPane.this ,
138:                                    "Error changing value "
139:                                            + pvve.getProperty() + " to "
140:                                            + pvve.getRejectedValue() + ":  "
141:                                            + pvve.getReason());
142:                        }
143:                    }
144:                }, false));
145:
146:                buttonBox.add(createButton("Cancel", new AbstractAction() {
147:                    public void actionPerformed(java.awt.event.ActionEvent e) {
148:                        if (container instanceof  JInternalFrame) {
149:                            try {
150:                                ((JInternalFrame) container).setClosed(true);
151:                            } catch (java.beans.PropertyVetoException pve) {
152:                            }
153:                        } else if (container instanceof  JFrame) {
154:                            ((JFrame) container).dispose();
155:                        }
156:                    }
157:                }, false));
158:
159:                this .add(buttonBox);
160:            }
161:
162:            /**
163:             * Creates the appropriate Button.
164:             */
165:            private JButton createButton(String label, Action e,
166:                    boolean isDefault) {
167:                JButton this Button;
168:
169:                this Button = new JButton(manager.getProperty("label." + label,
170:                        label));
171:                String mnemonic = manager.getProperty("label." + label
172:                        + ".mnemonic", "");
173:                if (mnemonic.length() > 0) {
174:                    this Button.setMnemonic(mnemonic.charAt(0));
175:                }
176:
177:                this Button.setSelected(isDefault);
178:
179:                this Button.addActionListener(e);
180:
181:                return this Button;
182:            }
183:
184:            /**
185:             * Resizes this component.  Called when a subcomponent changes its size.
186:             */
187:            public void resizeEditor() {
188:                container.setSize(container.getPreferredSize());
189:            }
190:
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.