01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.beaneditor;
16:
17: import org.apache.tapestry.PropertyConduit;
18:
19: /**
20: * Part of a {@link BeanModel} that defines the attributes of a single property of a bean.
21: */
22: public interface PropertyModel {
23: /** Returns the name of the property (which may, in fact, be a property expression). */
24: String getPropertyName();
25:
26: /**
27: * Returns the id used to access other resources (this is based on the property name, but with
28: * any excess punctiuation stripped out).
29: */
30: String getId();
31:
32: /** Returns a user-presentable label for the property. */
33: String getLabel();
34:
35: /** Returns the order vlaue, used to sort the properties into presentation order. */
36: int getOrder();
37:
38: /** Returns the type of the property. */
39: Class getPropertyType();
40:
41: /**
42: * Returns a logical name for the type of UI needed to view or edit the property. This is
43: * initially determined from the property type.
44: */
45: String getDataType();
46:
47: /**
48: * Changes the data type for the property.
49: *
50: * @param dataType
51: * @return the property edit model, for further changes
52: */
53: PropertyModel dataType(String dataType);
54:
55: /**
56: * Returns an object used to read or update the property. For virtual properties (properties
57: * that do not actually exist on the bean), the conduit may be null until one is provided via
58: * {@link MutablePropertyEditModel#conduit(PropertyConduit)}.
59: */
60: PropertyConduit getConduit();
61:
62: /**
63: * Changes the label for the property to the provided value.
64: *
65: * @param label
66: * new label for property
67: * @return the property edit model, for further changes
68: */
69: PropertyModel label(String label);
70:
71: /**
72: * Changes the order for the property. The properties are sorted by order (and then by name for
73: * identical orders) when building the user interface.
74: */
75: PropertyModel order(int order);
76:
77: /** Returns the containing model, often used for "fluent" construction of the model. */
78: BeanModel model();
79:
80: /**
81: * Returns true if the property can be used for sorting. By default, this is true only if the
82: * property type implements Comparable.
83: */
84: boolean isSortable();
85:
86: /** Updates sortable and returns the model for further changes. */
87: PropertyModel sortable(boolean sortable);
88: }
|