001 /*
002 * Copyright 2002-2005 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package org.springframework.binding.form;
017
018 import java.util.Map;
019
020 import org.springframework.binding.value.PropertyChangePublisher;
021
022 /**
023 * Encapsulates the state of an individual property of a form model.
024 *
025 * @author Oliver Hutchison
026 */
027 public interface FieldMetadata extends PropertyChangePublisher {
028
029 /** The name of the bound property <code>enabled</code>. */
030 public static final String ENABLED_PROPERTY = "enabled";
031
032 /** The name of the bound property <code>readOnly</code>. */
033 public static final String READ_ONLY_PROPERTY = "readOnly";
034
035 /** The name of the bound property <code>dirty</code>. */
036 public static final String DIRTY_PROPERTY = "dirty";
037
038 /**
039 * Return the type of this property.
040 */
041 Class getPropertyType();
042
043 /**
044 * Returns custom metadata that may be associated with this property.
045 */
046 Object getUserMetadata(String key);
047
048 /**
049 * Returns all custom metadata associated with this property in the form of
050 * a Map.
051 *
052 * @return Map containing String keys
053 */
054 Map getAllUserMetadata();
055
056 /**
057 * Sets whether or not this property is read only.
058 * <p>
059 * It's expected that controls bound to this form property will listen for
060 * changes to this value and if possible modify their display/behaviour to
061 * reflect the new state. e.g. When this property becomes true a text
062 * component would grey its self out and prevent any editing.
063 * <p>
064 * This value will be propagated up to any descendants.
065 *
066 * @param readOnly should this property be read only
067 */
068 void setReadOnly(boolean readOnly);
069
070 /**
071 * Returns whether or not the property is read only.
072 * <p>
073 * A property is read only if any of the following are true:
074 * <ul>
075 * <li>It is read only at the PropertyAccessStrategy level</li>
076 * <li>It is marked as read only by a call to the setReadOnly method of
077 * this class</li>
078 * <li>It is marked as read only by a call to the setReadOnly method of the
079 * metadata of any ancestor of the form model which contains this property</li>
080 * </ul>
081 */
082 boolean isReadOnly();
083
084 /**
085 * Sets the enabled value for this property.
086 * <p>
087 * It's expected that controls bound to this form property will listen for
088 * changes to this value and if possible modify their display/behaviour to
089 * reflect the new state.
090 * <p>
091 * This value will be propagated up to any descendants.
092 *
093 * @param enabled should this property be enabled
094 */
095 void setEnabled(boolean enabled);
096
097 /**
098 * Returns whether or not the property is enabled.
099 * <p>
100 * A property is enabled if all of the following are true:
101 * <ul>
102 * <li>The owning form model is enabled</li>
103 * <li>It has not been marked as disabled by a call to the setEnabled
104 * method of this class</li>
105 * <li>It has not been marked as disabled by by a call to the setEnabled
106 * method of the metadata of any ancestor of the form model which contains
107 * this property</li>
108 * </ul>
109 */
110 boolean isEnabled();
111
112 /**
113 * Returns whether or not the property is dirty.
114 */
115 boolean isDirty();
116 }