Source Code Cross Referenced for PropertyEditor.java in  » 6.0-JDK-Core » beans » java » beans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » beans » java.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1996-2003 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.beans;
027
028        /**
029         * A PropertyEditor class provides support for GUIs that want to
030         * allow users to edit a property value of a given type.
031         * <p>
032         * PropertyEditor supports a variety of different kinds of ways of
033         * displaying and updating property values.  Most PropertyEditors will
034         * only need to support a subset of the different options available in
035         * this API.
036         * <P>
037         * Simple PropertyEditors may only support the getAsText and setAsText
038         * methods and need not support (say) paintValue or getCustomEditor.  More
039         * complex types may be unable to support getAsText and setAsText but will
040         * instead support paintValue and getCustomEditor.
041         * <p>
042         * Every propertyEditor must support one or more of the three simple
043         * display styles.  Thus it can either (1) support isPaintable or (2)
044         * both return a non-null String[] from getTags() and return a non-null
045         * value from getAsText or (3) simply return a non-null String from 
046         * getAsText().
047         * <p>
048         * Every property editor must support a call on setValue when the argument
049         * object is of the type for which this is the corresponding propertyEditor.
050         * In addition, each property editor must either support a custom editor,
051         * or support setAsText.
052         * <p>
053         * Each PropertyEditor should have a null constructor.
054         */
055
056        public interface PropertyEditor {
057
058            /**
059             * Set (or change) the object that is to be edited.  Primitive types such
060             * as "int" must be wrapped as the corresponding object type such as
061             * "java.lang.Integer".
062             *
063             * @param value The new target object to be edited.  Note that this
064             *     object should not be modified by the PropertyEditor, rather 
065             *     the PropertyEditor should create a new object to hold any
066             *     modified value.
067             */
068            void setValue(Object value);
069
070            /**
071             * Gets the property value.
072             *
073             * @return The value of the property.  Primitive types such as "int" will
074             * be wrapped as the corresponding object type such as "java.lang.Integer".
075             */
076
077            Object getValue();
078
079            //----------------------------------------------------------------------
080
081            /**
082             * Determines whether this property editor is paintable.
083             *
084             * @return  True if the class will honor the paintValue method.
085             */
086
087            boolean isPaintable();
088
089            /**
090             * Paint a representation of the value into a given area of screen
091             * real estate.  Note that the propertyEditor is responsible for doing
092             * its own clipping so that it fits into the given rectangle.
093             * <p>
094             * If the PropertyEditor doesn't honor paint requests (see isPaintable)
095             * this method should be a silent noop.
096             * <p>
097             * The given Graphics object will have the default font, color, etc of
098             * the parent container.  The PropertyEditor may change graphics attributes
099             * such as font and color and doesn't need to restore the old values.
100             *
101             * @param gfx  Graphics object to paint into.
102             * @param box  Rectangle within graphics object into which we should paint.
103             */
104            void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box);
105
106            //----------------------------------------------------------------------
107
108            /**
109             * Returns a fragment of Java code that can be used to set a property
110             * to match the editors current state. This method is intended
111             * for use when generating Java code to reflect changes made through the 
112             * property editor.
113             * <p>
114             * The code fragment should be context free and must be a legal Java 
115             * expression as specified by the JLS.
116             * <p>
117             * Specifically, if the expression represents a computation then all
118             * classes and static members should be fully qualified. This rule 
119             * applies to constructors, static methods and non primitive arguments.
120             * <p>
121             * Caution should be used when evaluating the expression as it may throw
122             * exceptions. In particular, code generators must ensure that generated
123             * code will compile in the presence of an expression that can throw 
124             * checked exceptions.
125             * <p>
126             * Example results are:
127             * <ul>
128             * <li>Primitive expresssion: <code>2</code>
129             * <li>Class constructor: <code>new java.awt.Color(127,127,34)</code>
130             * <li>Static field: <code>java.awt.Color.orange</code>
131             * <li>Static method: <code>javax.swing.Box.createRigidArea(new 
132             *                                   java.awt.Dimension(0, 5))</code>
133             * </ul>
134             *
135             * @return a fragment of Java code representing an initializer for the
136             *         current value. It should not contain a semi-colon 
137             *         ('<code>;</code>') to end the expression.
138             */
139            String getJavaInitializationString();
140
141            //----------------------------------------------------------------------
142
143            /**
144             * Gets the property value as text.
145             * 
146             * @return The property value as a human editable string.
147             * <p>   Returns null if the value can't be expressed as an editable string.
148             * <p>   If a non-null value is returned, then the PropertyEditor should
149             *	     be prepared to parse that string back in setAsText().
150             */
151            String getAsText();
152
153            /**
154             * Set the property value by parsing a given String.  May raise
155             * java.lang.IllegalArgumentException if either the String is
156             * badly formatted or if this kind of property can't be expressed
157             * as text.
158             * @param text  The string to be parsed.
159             */
160            void setAsText(String text)
161                    throws java.lang.IllegalArgumentException;
162
163            //----------------------------------------------------------------------
164
165            /**
166             * If the property value must be one of a set of known tagged values, 
167             * then this method should return an array of the tags.  This can
168             * be used to represent (for example) enum values.  If a PropertyEditor
169             * supports tags, then it should support the use of setAsText with
170             * a tag value as a way of setting the value and the use of getAsText
171             * to identify the current value.
172             *
173             * @return The tag values for this property.  May be null if this 
174             *   property cannot be represented as a tagged value.
175             *	
176             */
177            String[] getTags();
178
179            //----------------------------------------------------------------------
180
181            /**
182             * A PropertyEditor may choose to make available a full custom Component
183             * that edits its property value.  It is the responsibility of the
184             * PropertyEditor to hook itself up to its editor Component itself and
185             * to report property value changes by firing a PropertyChange event.
186             * <P>
187             * The higher-level code that calls getCustomEditor may either embed
188             * the Component in some larger property sheet, or it may put it in
189             * its own individual dialog, or ...
190             *
191             * @return A java.awt.Component that will allow a human to directly
192             *      edit the current property value.  May be null if this is
193             *	    not supported.
194             */
195
196            java.awt.Component getCustomEditor();
197
198            /**
199             * Determines whether this property editor supports a custom editor.
200             *
201             * @return  True if the propertyEditor can provide a custom editor.
202             */
203            boolean supportsCustomEditor();
204
205            //----------------------------------------------------------------------
206
207            /**
208             * Register a listener for the PropertyChange event.  When a
209             * PropertyEditor changes its value it should fire a PropertyChange
210             * event on all registered PropertyChangeListeners, specifying the
211             * null value for the property name and itself as the source.
212             *
213             * @param listener  An object to be invoked when a PropertyChange
214             *		event is fired.
215             */
216            void addPropertyChangeListener(PropertyChangeListener listener);
217
218            /**
219             * Remove a listener for the PropertyChange event.
220             *
221             * @param listener  The PropertyChange listener to be removed.
222             */
223            void removePropertyChangeListener(PropertyChangeListener listener);
224
225        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.