001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.form;
043:
044: /**
045: * FormDesignValue interface gives a way how to use special property
046: * values that holds some additional or design specific information.
047: * Objects implementing FormDesignValue are specially supported by
048: * properties (@see FormProperty) in the form editor. An instance of
049: * FormDesignValue can be set as a property value - but it is not set to
050: * the real object (target bean) directly - some "design value" is derived
051: * from it first. Method getDesignValue() is defined for this purpose.
052: * The value returned from getDesignValue() is used on the real instance
053: * of the bean during design-time, while the object implementing
054: * FormDesignValue will be used for persistence and for code generation.
055: *
056: * Various property editors may provide values implementing FormDesignValue.
057: * For example, an internationalization string editor can work with
058: * values holding the key of internationalized string and returning the
059: * content of the key (from a Bundle.properties file) as the "design value"
060: * (from getDesignValue() method). Such an editor can be used then on any
061: * property of type String.
062: *
063: * @author Ian Formanek
064: */
065: public interface FormDesignValue extends java.io.Serializable {
066:
067: /** A special value indicating (when returned from getDesignValue())
068: * that no real value is available during design-time for this object.
069: * @see #getDesignValue
070: */
071: public static final Object IGNORED_VALUE = new Object();
072:
073: static final long serialVersionUID = 5993614134339828170L;
074:
075: /** Provides a value which should be used during design-time
076: * as the real value of a property on the bean instance.
077: * E.g. the ResourceBundle String would provide the real value
078: * of the String from the resource bundle, so that the design-time
079: * representation reflects the real code being generated.
080: * @return the real property value to be used during design-time
081: */
082: public Object getDesignValue();
083:
084: public Object getDesignValue(Object target);
085:
086: /** Returns description of the design value. Can be useful when
087: * the real value for design-time is not provided.
088: *
089: * @return description of the design value.
090: */
091: public String getDescription();
092:
093: /**
094: * Returns a new FormDesignValue instance which should, as appropriate,
095: * correspond to the target form property.
096: *
097: * @param targetFormProperty the FormProperty the copied value will be set to
098: * @return the new FormDesignValue instance or null if it's impossible to copy
099: * the particular subtype; may also return the represented real value
100: */
101: public Object copy(FormProperty targetFormProperty);
102:
103: //
104: // In the future, some methods for handling persistence
105: // will be probably added here.
106: //
107:
108: // /** Extended version of FormDesignValue which supports listening on
109: // * changes of the design value. */
110: // public interface Listener extends FormDesignValue {
111: // static final long serialVersionUID =7127443991708952900L;
112: //
113: // /** Attaches specified listener to the design value.
114: // * The change event is fired whenever the design value (accessible
115: // * via getDesignValue() method call) changes.
116: // * @param listener the change listener to add
117: // */
118: // public void addChangeListener(javax.swing.event.ChangeListener listener);
119: //
120: // /** Deattaches specified listener from the design value.
121: // * @param listener the change listener to remove
122: // */
123: // public void removeChangeListener(javax.swing.event.ChangeListener listener);
124: // }
125: }
|