View Javadoc

1   package com.silvermindsoftware.hitch.annotations;
2   
3   /**
4    * Copyright 2007 Brandon Goodin
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import com.silvermindsoftware.hitch.ReadOnly;
20  
21  import java.lang.annotation.*;
22  
23  /**
24   * BoundComponent to bind domain objects to Swing components
25   * 
26   * @svnLink $Revision: 3873 $;$Date: 2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/swing/src/main/java/com/silvermindsoftware/hitch/annotations/BoundComponent.java $
27   */
28  @Target({ElementType.FIELD})
29  @Documented
30  @Retention(RetentionPolicy.RUNTIME)
31  public @interface BoundComponent {
32  	/**
33  	 * <p>
34  	 * If specified. This is the type the component value
35  	 * will be converted to before being set on the model
36  	 * object.
37  	 * <p/>
38  	 * If not specified an attempt will be made to determine
39  	 * the type to be set based on the model objects getter
40  	 * return type or field type.
41  	 *
42  	 * @return
43  	 */
44  	Class type() default void.class;
45  
46  	/**
47  	 * <p>
48  	 * If specified. This is the property the component
49  	 * will be bound to on the model class.
50  	 * <p/>
51  	 * If not specified an attempt will be made to find an
52  	 * identically named property on the model.
53  	 *
54  	 * @return
55  	 */
56  	String property() default "[default]";
57  
58  	/**
59  	 * If specified. This is the id of the ModelObject
60  	 * that will be used when performing bindings.
61  	 * <p/>
62  	 * If not it will use the default ModelObject
63  	 *
64  	 * @return
65  	 */
66  	String modelId() default "[default]";
67  
68  	/**
69  	 * If specified. This is a custom component handler
70  	 * that will be used to handle value extraction and
71  	 * setting of a component.
72  	 *
73  	 * If not specified the default class component handler
74  	 * will be used. void.class is used in this case because
75  	 * Java annotations does not provide a means to default
76  	 * a value to null.
77  	 *
78  	 * @return
79  	 */
80  	Class handler() default void.class;
81  
82  	/**
83  	 * This is a set of string parameters that can be passed
84  	 * component handler. These parameters need to be passed
85  	 * in the form of "[property]=[value]". You can pass
86  	 * as many property/value combos as you like. In order for
87  	 * the property/value to be useful your ComponentHandler
88  	 * must have compatible setters.
89  	 *
90  	 * @return
91  	 */
92  	String[] handlerValues() default "";
93  
94  	/**
95  	 * This attribute specifies whether a component is read only.
96  	 * If read only is true the component will be updated during
97  	 * the updateForm but will not be accessed when performing
98  	 * an updateModel. If default is specified then the default behavior
99  	 * is used. This could be different for the type of component being
100 	 * bound. Currently JLabels are defaulted to be read-only.
101 	 * @return
102 	 */
103 	ReadOnly readOnly() default ReadOnly.DEFAULT;
104 	
105 
106 }