Revision 306
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/DynObjectSwingManager.java | ||
---|---|---|
72 | 72 |
/** |
73 | 73 |
* Creates a {@link JDynFieldComponent} to render a {@link DynObject} field. |
74 | 74 |
* |
75 |
* @param writable |
|
76 |
* |
|
75 | 77 |
* @param field |
76 | 78 |
* to render |
77 | 79 |
* @param dynObject |
... | ... | |
83 | 85 |
throws ServiceException; |
84 | 86 |
|
85 | 87 |
/** |
88 |
* Creates a {@link JDynFieldComponent} to render a {@link DynObject} field. |
|
89 |
* |
|
90 |
* @param writable |
|
91 |
* |
|
92 |
* @param field |
|
93 |
* to render |
|
94 |
* @param dynObject |
|
95 |
* with the value to render |
|
96 |
* @return the component |
|
97 |
* @throws ServiceException |
|
98 |
*/ |
|
99 |
public JDynFieldComponent createJDynFieldComponent(ValueField valueItem, |
|
100 |
boolean writable) throws ServiceException; |
|
101 |
|
|
102 |
/** |
|
86 | 103 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject} in the |
87 |
* default mode. |
|
104 |
* default view mode, in read only mode.
|
|
88 | 105 |
* |
89 | 106 |
* @param dynObject |
90 | 107 |
* to create the component for |
... | ... | |
95 | 112 |
throws ServiceException; |
96 | 113 |
|
97 | 114 |
/** |
98 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject}. |
|
115 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject} in the |
|
116 |
* default mode. |
|
99 | 117 |
* |
100 | 118 |
* @param dynObject |
101 | 119 |
* to create the component for |
102 |
* @param mode |
|
120 |
* @param writable |
|
121 |
* if the component will be used to edit the DynObject or as |
|
122 |
* readonly |
|
103 | 123 |
* @return a {@link JDynObjectComponent} |
104 | 124 |
* @throws ServiceException |
105 | 125 |
*/ |
106 | 126 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
127 |
boolean writable) throws ServiceException; |
|
128 |
|
|
129 |
/** |
|
130 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject} in read |
|
131 |
* only mode. |
|
132 |
* |
|
133 |
* @param dynObject |
|
134 |
* to create the component for |
|
135 |
* @param model |
|
136 |
* for the user interface of the DynObject |
|
137 |
* @return a {@link JDynObjectComponent} |
|
138 |
* @throws ServiceException |
|
139 |
*/ |
|
140 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
107 | 141 |
DynObjectModel model) throws ServiceException; |
108 | 142 |
|
109 | 143 |
/** |
... | ... | |
111 | 145 |
* |
112 | 146 |
* @param dynObject |
113 | 147 |
* to create the component for |
148 |
* @param model |
|
149 |
* for the user interface of the DynObject |
|
150 |
* @param writable |
|
151 |
* if the component will be used to edit the DynObject or as |
|
152 |
* readonly |
|
153 |
* @return a {@link JDynObjectComponent} |
|
154 |
* @throws ServiceException |
|
155 |
*/ |
|
156 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
157 |
DynObjectModel model, boolean writable) throws ServiceException; |
|
158 |
|
|
159 |
/** |
|
160 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject}. |
|
161 |
* |
|
162 |
* @param dynObject |
|
163 |
* to create the component for |
|
114 | 164 |
* @param mode |
165 |
* the mode to view the DynObject (default ones: |
|
166 |
* {@link DynObjectSwingManager#MODE_FORM} and |
|
167 |
* {@link DynObjectSwingManager#MODE_LIST}) |
|
115 | 168 |
* @return a {@link JDynObjectComponent} |
116 | 169 |
* @throws ServiceException |
117 | 170 |
*/ |
... | ... | |
123 | 176 |
* |
124 | 177 |
* @param dynObject |
125 | 178 |
* to create the component for |
179 |
* @param model |
|
180 |
* for the user interface of the DynObject |
|
126 | 181 |
* @param mode |
182 |
* the mode to view the DynObject (default ones: |
|
183 |
* {@link DynObjectSwingManager#MODE_FORM} and |
|
184 |
* {@link DynObjectSwingManager#MODE_LIST}) |
|
185 |
* @param writable |
|
186 |
* if the component will be used to edit the DynObject or as |
|
187 |
* readonly |
|
127 | 188 |
* @return a {@link JDynObjectComponent} |
128 | 189 |
* @throws ServiceException |
129 | 190 |
*/ |
130 | 191 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
192 |
DynObjectModel model, String mode, boolean writable) |
|
193 |
throws ServiceException; |
|
194 |
|
|
195 |
/** |
|
196 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject} in read |
|
197 |
* only mode. |
|
198 |
* |
|
199 |
* @param dynObject |
|
200 |
* to create the component for |
|
201 |
* @param mode |
|
202 |
* the mode to view the DynObject (default ones: |
|
203 |
* {@link DynObjectSwingManager#MODE_FORM} and |
|
204 |
* {@link DynObjectSwingManager#MODE_LIST}) |
|
205 |
* @return a {@link JDynObjectComponent} |
|
206 |
* @throws ServiceException |
|
207 |
*/ |
|
208 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
131 | 209 |
String mode) throws ServiceException; |
132 | 210 |
|
133 | 211 |
/** |
212 |
* Creates a {@link JDynObjectComponent} for a {@link DynObject}. |
|
213 |
* |
|
214 |
* @param dynObject |
|
215 |
* to create the component for |
|
216 |
* @param mode |
|
217 |
* the mode to view the DynObject (default ones: |
|
218 |
* {@link DynObjectSwingManager#MODE_FORM} and |
|
219 |
* {@link DynObjectSwingManager#MODE_LIST}) |
|
220 |
* @param writable |
|
221 |
* if the component will be used to edit the DynObject or as |
|
222 |
* readonly |
|
223 |
* @return a {@link JDynObjectComponent} |
|
224 |
* @throws ServiceException |
|
225 |
*/ |
|
226 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
227 |
String mode, boolean writable) throws ServiceException; |
|
228 |
|
|
229 |
/** |
|
134 | 230 |
* Creates a {@link JDynObjectSetComponent} to render a {@link DynObjectSet} |
135 |
* . |
|
231 |
* in read only mode.
|
|
136 | 232 |
* |
137 | 233 |
* @param dynObjectSet |
138 | 234 |
* to create the component for |
... | ... | |
143 | 239 |
public JDynObjectSetComponent createJDynObjectSetComponent( |
144 | 240 |
DynObjectSet dynObjectSet) throws BaseException; |
145 | 241 |
|
242 |
/** |
|
243 |
* Creates a {@link JDynObjectSetComponent} to render a {@link DynObjectSet} |
|
244 |
* . |
|
245 |
* |
|
246 |
* @param dynObjectSet |
|
247 |
* to create the component for |
|
248 |
* @param writable |
|
249 |
* if the component will be used to edit the {@link DynObjectSet} |
|
250 |
* or not |
|
251 |
* @return a {@link JDynObjectSetComponent} |
|
252 |
* @throws BaseException |
|
253 |
* if there is an error creating the component |
|
254 |
*/ |
|
255 |
public JDynObjectSetComponent createJDynObjectSetComponent( |
|
256 |
DynObjectSet dynObjectSet, boolean writable) throws BaseException; |
|
257 |
|
|
146 | 258 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/JDynObjectComponentFactory.java | ||
---|---|---|
34 | 34 |
package org.gvsig.tools.swing.api.dynobject; |
35 | 35 |
|
36 | 36 |
import org.gvsig.tools.dynobject.DynObject; |
37 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
37 | 38 |
import org.gvsig.tools.service.ServiceException; |
38 | 39 |
import org.gvsig.tools.service.spi.ServiceFactory; |
39 | 40 |
|
... | ... | |
51 | 52 |
*/ |
52 | 53 |
public interface JDynObjectComponentFactory extends ServiceFactory { |
53 | 54 |
|
54 |
/** |
|
55 |
* |
|
56 |
* Creates a new JDynObjectComponent base on its {@link DynObject} and its |
|
57 |
* {@link DynObjectModel}. |
|
58 |
* |
|
59 |
* @param dynObject |
|
60 |
* the current {@link DynObject}. |
|
61 |
* @param model |
|
62 |
* the {@link DynObjectModel} that specifies which values are to |
|
63 |
* be displayed. |
|
64 |
* @return |
|
65 |
* the {@link JDynObjectComponent} object. |
|
66 |
* @throws ServiceException |
|
67 |
*/ |
|
68 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
69 |
DynObjectModel model) throws ServiceException; |
|
55 |
/** |
|
56 |
* |
|
57 |
* Creates a new JDynObjectComponent base on its {@link DynObject} and its |
|
58 |
* {@link DynObjectModel}. |
|
59 |
* |
|
60 |
* @param dynObject |
|
61 |
* the current {@link DynObject}. |
|
62 |
* @param model |
|
63 |
* the {@link DynObjectModel} that specifies which values are to |
|
64 |
* be displayed. |
|
65 |
* @param writable |
|
66 |
* if the component will be used to edit the {@link DynObjectSet} |
|
67 |
* or not |
|
68 |
* @return the {@link JDynObjectComponent} object. |
|
69 |
* @throws ServiceException |
|
70 |
*/ |
|
71 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
|
72 |
DynObjectModel model, boolean writable) throws ServiceException; |
|
70 | 73 |
|
71 | 74 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/set/JDynObjectSetComponent.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
package org.gvsig.tools.swing.api.dynobject.set; |
24 | 24 |
|
25 |
import org.gvsig.tools.dispose.Disposable; |
|
25 | 26 |
import org.gvsig.tools.dynobject.DynObjectSet; |
26 | 27 |
import org.gvsig.tools.swing.api.ComponentService; |
27 | 28 |
|
... | ... | |
31 | 32 |
* @author gvSIG team |
32 | 33 |
* @version $Id$ |
33 | 34 |
*/ |
34 |
public interface JDynObjectSetComponent extends ComponentService { |
|
35 |
public interface JDynObjectSetComponent extends ComponentService, Disposable {
|
|
35 | 36 |
|
36 | 37 |
/** |
37 | 38 |
* Returns the {@link DynObjectSet} that is being rendered by this |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/JDynObjectComponent.java | ||
---|---|---|
52 | 52 |
public static String MANAGER = "manager"; |
53 | 53 |
public static String DYNOBJECT = "dynobject"; |
54 | 54 |
public static String DYNMODEL = "model"; |
55 |
public static String WRITABLE = "writable"; |
|
55 | 56 |
} |
56 | 57 |
|
57 | 58 |
/** |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/dynfield/JDynFieldComponentFactory.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
public static final String SERVICE_NAMESPACE = "dynobject.fields"; |
42 | 42 |
|
43 |
/** |
|
44 |
* Creates a {@link JDynFieldComponent} to render an attribute of a |
|
45 |
* {@link DynObject}. |
|
46 |
* |
|
47 |
* @param dynField |
|
48 |
* defines the field or attribute of the {@link DynObject} to |
|
49 |
* render |
|
50 |
* @param dynObject |
|
51 |
* contains the attribute value to render |
|
52 |
* @return the component to render the {@link DynObject} attribute value |
|
53 |
* @throws ServiceException |
|
54 |
*/ |
|
55 |
public JDynFieldComponent createJDynFieldComponent(ValueField dynObject) |
|
56 |
throws ServiceException; |
|
43 |
/** |
|
44 |
* Creates a {@link JDynFieldComponent} to render an attribute of a |
|
45 |
* {@link DynObject}. |
|
46 |
* |
|
47 |
* @param dynField |
|
48 |
* defines the field or attribute of the {@link DynObject} to |
|
49 |
* render |
|
50 |
* @param dynObject |
|
51 |
* contains the attribute value to render |
|
52 |
* @param writable |
|
53 |
* @return the component to render the {@link DynObject} attribute value |
|
54 |
* @throws ServiceException |
|
55 |
*/ |
|
56 |
public JDynFieldComponent createJDynFieldComponent(ValueField dynObject, |
|
57 |
boolean writable) throws ServiceException; |
|
57 | 58 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/dynfield/JDynComponent.java | ||
---|---|---|
47 | 47 |
public interface JDynComponent { |
48 | 48 |
|
49 | 49 |
/** |
50 |
* Allows adding a listener to the list of listeners of this JDynComponent. |
|
51 |
* |
|
52 |
* @param listener |
|
53 |
* the {@link ValueChangedListener} |
|
54 |
* |
|
55 |
* @see ValueChangedListener#handleValueChanged(JDynFieldComponent) |
|
56 |
*/ |
|
57 |
public void addValueChangedListener(ValueChangedListener listener); |
|
58 |
|
|
59 |
/** |
|
60 |
* @return |
|
61 |
*/ |
|
62 |
public Object getValue(); |
|
63 |
|
|
64 |
/** |
|
65 | 50 |
* Returns whether the {@link DynField} value passes the validation phase or |
66 | 51 |
* not. |
67 | 52 |
* |
... | ... | |
82 | 67 |
*/ |
83 | 68 |
public void saveStatus(); |
84 | 69 |
|
70 |
/** |
|
71 |
* Allows adding a listener to the list of listeners of this JDynComponent. |
|
72 |
* |
|
73 |
* @param listener |
|
74 |
* the {@link ValueChangedListener} |
|
75 |
* |
|
76 |
* @see ValueChangedListener#handleValueChanged(JDynFieldComponent) |
|
77 |
*/ |
|
78 |
public void addValueChangedListener(ValueChangedListener listener); |
|
79 |
|
|
80 |
|
|
81 |
/** |
|
82 |
* @return |
|
83 |
*/ |
|
84 |
public Object getValue(); |
|
85 |
|
|
86 |
/** |
|
87 |
* Returns if the current component has changes not saved into the source |
|
88 |
* data. |
|
89 |
* |
|
90 |
* @return if the current component has changes TODO: add the method when |
|
91 |
* the edition options are enabled again |
|
92 |
*/ |
|
93 |
// public boolean hasChanges(); |
|
94 |
|
|
85 | 95 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/dynobject/dynfield/JDynFieldComponent.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
public static class PARAMETERS { |
60 | 60 |
|
61 |
public static String MANAGER = "manager";
|
|
62 |
public static String DYNFIELD = "dynobject";
|
|
63 |
public static String PARENT = "dynfield";
|
|
61 |
public static String DYNFIELD = "dynfield";
|
|
62 |
public static String PARENT = "parent";
|
|
63 |
public static String WRITABLE = "writable";
|
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
/** |
67 |
* Walks through the list of {@link ValueChangedListener} objects and |
|
68 |
* calls the <b>handleValueChanged</b> function by specifying this |
|
69 |
* JDynFieldComponent object |
|
70 |
* as the one that has been changed. |
|
67 |
* Returns the {@link DynField} to be rendered. |
|
71 | 68 |
* |
72 |
* @see ValueChangedListener#handleValueChanged(JDynFieldComponent)
|
|
69 |
* @return the DynField
|
|
73 | 70 |
*/ |
74 |
public void fireValueChangedEvent();
|
|
71 |
public DynField getDynField();
|
|
75 | 72 |
|
76 | 73 |
/** |
77 | 74 |
* Returns the {@link DynObject} to be rendered. |
... | ... | |
81 | 78 |
// public DynObject getDynObject(); |
82 | 79 |
|
83 | 80 |
/** |
84 |
* Returns the {@link DynField} to be rendered. |
|
85 |
* |
|
86 |
* @return the DynField |
|
87 |
*/ |
|
88 |
public DynField getDynField(); |
|
89 |
|
|
90 |
/** |
|
91 | 81 |
* Gets the {@link DynField}'s value at this particular moment, if any. |
92 | 82 |
* |
93 | 83 |
* |
... | ... | |
116 | 106 |
*/ |
117 | 107 |
public void setEnabled(boolean isEnabled); |
118 | 108 |
|
109 |
/** |
|
110 |
* Walks through the list of {@link ValueChangedListener} objects and |
|
111 |
* calls the <b>handleValueChanged</b> function by specifying this |
|
112 |
* JDynFieldComponent object |
|
113 |
* as the one that has been changed. |
|
114 |
* |
|
115 |
* @see ValueChangedListener#handleValueChanged(JDynFieldComponent) |
|
116 |
*/ |
|
117 |
public void fireValueChangedEvent(); |
|
118 |
|
|
119 | 119 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/AbstractDynObjectComponent.java | ||
---|---|---|
75 | 75 |
* |
76 | 76 |
* @param dynObject |
77 | 77 |
* the {@link DynObject} to render |
78 |
* @param writable |
|
78 | 79 |
*/ |
79 | 80 |
public AbstractDynObjectComponent(DynObject dynObject, DynObjectModel model) { |
80 | 81 |
this.dynObject = dynObject; |
... | ... | |
87 | 88 |
// TODO Auto-generated catch block |
88 | 89 |
e.printStackTrace(); |
89 | 90 |
} |
90 |
} else {
|
|
91 |
} else {
|
|
91 | 92 |
this.model = model; |
92 |
}
|
|
93 |
}
|
|
93 | 94 |
manager = ToolsSwingLocator.getDynObjectSwingManager(); |
94 | 95 |
} |
95 | 96 |
|
... | ... | |
106 | 107 |
this.getComponents().put(component, input); |
107 | 108 |
} |
108 | 109 |
|
109 |
/* |
|
110 |
* (non-Javadoc) |
|
111 |
* |
|
112 |
* @seeorg.gvsig.tools.swing.api.dynobject.JDynObjectComponent# |
|
113 |
* addValueChangedListener |
|
114 |
* (org.gvsig.tools.swing.api.dynobject.ValueChangedListener) |
|
115 |
*/ |
|
116 |
public void addValueChangedListener(ValueChangedListener listener) { |
|
117 |
Iterator<JDynFieldComponent> componentFields = |
|
118 |
this.getComponents().values().iterator(); |
|
119 |
JDynFieldComponent comp; |
|
120 |
while (componentFields.hasNext()) { |
|
121 |
comp = componentFields.next(); |
|
122 |
comp.addValueChangedListener(listener); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 | 110 |
/** |
127 |
* |
|
128 |
* Sets all FieldValues of this {@link JDynObjectComponent} to null. |
|
129 |
* |
|
130 |
*/ |
|
131 |
protected void emptyAll() { |
|
132 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
|
133 |
for (JDynFieldComponent item : items.values()) { |
|
134 |
item.setValue(null); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Sets all FieldValues of this {@link JDynObjectComponent} to its the |
|
140 |
* current values |
|
141 |
* of the same FieldValues at the {@link DynObject} given as input. |
|
142 |
* |
|
143 |
* @param value |
|
144 |
*/ |
|
145 |
protected void fillValues(DynObject dynObject) { |
|
146 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
|
147 |
for (JDynFieldComponent item : items.values()) { |
|
148 |
item.setValue(dynObject.getDynValue(item.getDynField().getName())); |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 | 111 |
* Gets the map of all graphic JDynFieldComponents of this |
154 | 112 |
* JDynObjectComponent. |
155 | 113 |
* |
... | ... | |
184 | 142 |
return dynObject; |
185 | 143 |
} |
186 | 144 |
|
187 |
// |
|
188 |
// public Object getValue() { |
|
189 |
// return this.getDynObject(); |
|
190 |
// } |
|
191 |
|
|
192 | 145 |
/** |
193 | 146 |
* |
194 | 147 |
* Returns a {@link JDynFieldComponent} that best matches with the given |
... | ... | |
246 | 199 |
} |
247 | 200 |
|
248 | 201 |
/** |
202 |
* |
|
203 |
* Sets all FieldValues of this {@link JDynObjectComponent} to null. |
|
204 |
* |
|
205 |
*/ |
|
206 |
protected void emptyAll() { |
|
207 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
|
208 |
for (JDynFieldComponent item : items.values()) |
|
209 |
item.setValue(null); |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Sets all FieldValues of this {@link JDynObjectComponent} to its the |
|
214 |
* current values |
|
215 |
* of the same FieldValues at the {@link DynObject} given as input. |
|
216 |
* |
|
217 |
* @param value |
|
218 |
*/ |
|
219 |
protected void fillValues(DynObject dynObject) { |
|
220 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
|
221 |
for (JDynFieldComponent item : items.values()) |
|
222 |
item.setValue(dynObject.getDynValue(item.getDynField().getName())); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
249 | 226 |
* Walks through all JDynFieldComponents to save its current values into |
250 | 227 |
* their DynObject. |
251 | 228 |
*/ |
... | ... | |
259 | 236 |
} |
260 | 237 |
} |
261 | 238 |
|
239 |
public void addValueChangedListener(ValueChangedListener listener) { |
|
240 |
Iterator<JDynFieldComponent> componentFields = |
|
241 |
this.getComponents().values().iterator(); |
|
242 |
JDynFieldComponent comp; |
|
243 |
while (componentFields.hasNext()) { |
|
244 |
comp = componentFields.next(); |
|
245 |
comp.addValueChangedListener(listener); |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
262 | 249 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/AbstractJDynField.java | ||
---|---|---|
67 | 67 |
|
68 | 68 |
protected final List<ValueChangedListener> listeners; |
69 | 69 |
|
70 |
public AbstractJDynField(ValueField parent) {
|
|
70 |
public AbstractJDynField(ValueField parent) {
|
|
71 | 71 |
this.parent = parent; |
72 | 72 |
listeners = new ArrayList<ValueChangedListener>(); |
73 | 73 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/AbstractDynObjectFactory.java | ||
---|---|---|
54 | 54 |
* |
55 | 55 |
*/ |
56 | 56 |
public abstract class AbstractDynObjectFactory extends |
57 |
AbstractSwingServiceFactory implements JDynObjectComponentFactory {
|
|
57 |
AbstractSwingServiceFactory implements JDynObjectComponentFactory {
|
|
58 | 58 |
|
59 |
@Override
|
|
60 |
protected DynClass createParametersDynClass() {
|
|
59 |
@Override
|
|
60 |
protected DynClass createParametersDynClass() {
|
|
61 | 61 |
|
62 |
DynClass dynClassParams = this.getDynClassParams(); |
|
63 |
dynClassParams.addDynField(JDynObjectComponent.PARAMETERS.DYNOBJECT) |
|
64 |
.setType(DataTypes.OBJECT).setMandatory(true); |
|
65 |
dynClassParams.addDynField(JDynObjectComponent.PARAMETERS.DYNMODEL) |
|
66 |
.setType(DataTypes.OBJECT).setMandatory(true); |
|
67 |
return dynClassParams; |
|
68 |
} |
|
62 |
DynClass dynClassParams = this.getDynClassParams(); |
|
63 |
dynClassParams.addDynField(JDynObjectComponent.PARAMETERS.DYNOBJECT) |
|
64 |
.setType(DataTypes.DYNOBJECT).setMandatory(true); |
|
65 |
dynClassParams |
|
66 |
.addDynFieldObject(JDynObjectComponent.PARAMETERS.DYNMODEL) |
|
67 |
.setClassOfValue(DynObjectModel.class).setMandatory(true); |
|
68 |
dynClassParams |
|
69 |
.addDynFieldBoolean(JDynObjectComponent.PARAMETERS.WRITABLE) |
|
70 |
.setMandatory(false).setDefaultFieldValue(Boolean.FALSE); |
|
69 | 71 |
|
70 |
@Override |
|
71 |
protected Service doCreate(DynObject parameters, |
|
72 |
ServiceManager serviceManager) throws ServiceException { |
|
72 |
return dynClassParams; |
|
73 |
} |
|
73 | 74 |
|
74 |
DynObjectModel dynModel = |
|
75 |
(DynObjectModel) parameters |
|
76 |
.getDynValue(JDynObjectComponent.PARAMETERS.DYNMODEL); |
|
77 |
DynObject dynObject = |
|
78 |
(DynObject) parameters |
|
79 |
.getDynValue(JDynObjectComponent.PARAMETERS.DYNOBJECT); |
|
75 |
@Override |
|
76 |
protected Service doCreate(DynObject parameters, |
|
77 |
ServiceManager serviceManager) throws ServiceException { |
|
80 | 78 |
|
81 |
return this.createJDynObjectComponent(dynObject, dynModel); |
|
82 |
} |
|
79 |
DynObjectModel dynModel = (DynObjectModel) parameters |
|
80 |
.getDynValue(JDynObjectComponent.PARAMETERS.DYNMODEL); |
|
81 |
DynObject dynObject = (DynObject) parameters |
|
82 |
.getDynValue(JDynObjectComponent.PARAMETERS.DYNOBJECT); |
|
83 |
Boolean writable = (Boolean) parameters |
|
84 |
.getDynValue(JDynObjectComponent.PARAMETERS.WRITABLE); |
|
85 |
writable = writable == null ? Boolean.FALSE : writable; |
|
83 | 86 |
|
84 |
public void initialize() { |
|
85 |
// Nothing to do |
|
86 |
} |
|
87 |
return this.createJDynObjectComponent(dynObject, dynModel, |
|
88 |
writable.booleanValue()); |
|
89 |
} |
|
90 |
|
|
91 |
public void initialize() { |
|
92 |
// Nothing to do |
|
93 |
} |
|
87 | 94 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/AbstractJDynFieldComponent.java | ||
---|---|---|
65 | 65 |
* @param dynObject |
66 | 66 |
* the {@link DynObject} with the attribute to render |
67 | 67 |
*/ |
68 |
public AbstractJDynFieldComponent(ValueField parent)
|
|
68 |
public AbstractJDynFieldComponent(ValueField parent)
|
|
69 | 69 |
throws ServiceException { |
70 |
super(parent);
|
|
70 |
super(parent);
|
|
71 | 71 |
listeners = new ArrayList<ValueChangedListener>(); |
72 | 72 |
// this.dynObject = dynObject.getDynObject(); |
73 | 73 |
manager = ToolsSwingLocator.getDynObjectSwingManager(); |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/DynObjectSwingServiceManager.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
public static final String DEFAULT_FACTORY_SUBTYPE = "default"; |
56 | 56 |
|
57 |
/**
|
|
58 |
*
|
|
59 |
* Returns a {@link JDynFieldComponent} that best matches with the given
|
|
60 |
* {@link ValueField} and type.
|
|
61 |
*
|
|
62 |
* @param parent
|
|
63 |
* the {@link ValueField} element.
|
|
64 |
* @param type
|
|
65 |
* the current type.
|
|
66 |
*
|
|
67 |
* @return
|
|
68 |
* the {@link JDynFieldComponent}.
|
|
69 |
*
|
|
70 |
* @throws ServiceException
|
|
71 |
*/
|
|
57 |
/**
|
|
58 |
*
|
|
59 |
* Returns a {@link JDynFieldComponent} that best matches with the given
|
|
60 |
* {@link ValueField} and type.
|
|
61 |
*
|
|
62 |
* @param parent
|
|
63 |
* the {@link ValueField} element.
|
|
64 |
* @param type
|
|
65 |
* the current type.
|
|
66 |
* @param writable
|
|
67 |
*
|
|
68 |
* @return the {@link JDynFieldComponent}.
|
|
69 |
*
|
|
70 |
* @throws ServiceException
|
|
71 |
*/
|
|
72 | 72 |
public JDynFieldComponent getJDynFieldComponent(ValueField parent, |
73 |
boolean type) throws ServiceException;
|
|
73 |
boolean type, boolean writable) throws ServiceException;
|
|
74 | 74 |
|
75 | 75 |
/** |
76 | 76 |
* |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.spi/src/main/java/org/gvsig/tools/swing/spi/AbstractJDynFieldComponentFactory.java | ||
---|---|---|
33 | 33 |
*/ |
34 | 34 |
package org.gvsig.tools.swing.spi; |
35 | 35 |
|
36 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
37 | 36 |
import org.gvsig.tools.dynobject.DynClass; |
38 | 37 |
import org.gvsig.tools.dynobject.DynField; |
39 | 38 |
import org.gvsig.tools.dynobject.DynObject; |
40 | 39 |
import org.gvsig.tools.service.Service; |
41 | 40 |
import org.gvsig.tools.service.ServiceException; |
42 | 41 |
import org.gvsig.tools.service.spi.ServiceManager; |
42 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
|
43 | 43 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
44 | 44 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory; |
45 | 45 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
... | ... | |
56 | 56 |
public abstract class AbstractJDynFieldComponentFactory extends |
57 | 57 |
AbstractSwingServiceFactory implements JDynFieldComponentFactory { |
58 | 58 |
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* |
|
62 |
* @see |
|
63 |
* |
|
64 |
* |
|
65 |
* |
|
66 |
* org.gvsig.tools.service.spi.AbstractServiceFactory#createParametersDynClass |
|
67 |
* () |
|
68 |
*/ |
|
69 | 59 |
@Override |
70 | 60 |
protected DynClass createParametersDynClass() { |
71 | 61 |
|
72 |
DynClass dynClassParams = this.getDynClassParams();
|
|
62 |
DynClass dynClassParams = this.getDynClassParams();
|
|
73 | 63 |
|
74 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.PARENT) |
|
75 |
.setType(DataTypes.OBJECT).setMandatory(true); |
|
76 |
dynClassParams.addDynField(JDynFieldComponent.PARAMETERS.DYNFIELD) |
|
77 |
.setType(DataTypes.OBJECT).setMandatory(true); |
|
78 |
return dynClassParams; |
|
64 |
dynClassParams.addDynFieldObject(JDynFieldComponent.PARAMETERS.PARENT) |
|
65 |
.setClassOfValue(ValueField.class).setMandatory(true); |
|
66 |
dynClassParams |
|
67 |
.addDynFieldObject(JDynFieldComponent.PARAMETERS.DYNFIELD) |
|
68 |
.setClassOfValue(DynField.class).setMandatory(true); |
|
69 |
dynClassParams.addDynFieldBoolean( |
|
70 |
JDynFieldComponent.PARAMETERS.WRITABLE).setMandatory(false); |
|
71 |
|
|
72 |
return dynClassParams; |
|
79 | 73 |
} |
80 | 74 |
|
81 | 75 |
/* |
... | ... | |
95 | 89 |
ValueField valueField = |
96 | 90 |
(ValueField) parameters |
97 | 91 |
.getDynValue(JDynFieldComponent.PARAMETERS.PARENT); |
92 |
|
|
93 |
Boolean writable = (Boolean) parameters |
|
94 |
.getDynValue(JDynObjectComponent.PARAMETERS.WRITABLE); |
|
95 |
writable = writable == null ? Boolean.FALSE : writable; |
|
96 |
|
|
98 | 97 |
// |
99 | 98 |
// JDynObjectComponent parent = (JDynObjectComponent) parameters |
100 | 99 |
// .getDynValue(JDynFieldComponent.PARAMETERS.PARENT); |
... | ... | |
103 | 102 |
// DynObjectValueField(parent.getDynObject(), child.getName()); |
104 | 103 |
// |
105 | 104 |
try { |
106 |
JDynFieldComponent comp = this.createJDynFieldComponent(valueField); |
|
105 |
JDynFieldComponent comp = this.createJDynFieldComponent(valueField, |
|
106 |
writable.booleanValue()); |
|
107 | 107 |
|
108 | 108 |
return this.getSuitableComponent(comp, valueField); |
109 | 109 |
|
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/JDefaultDynFieldComponentFactory.java | ||
---|---|---|
27 | 27 |
* http://www.geoinfo.uji.es |
28 | 28 |
* Universitat Jaume I, Spain |
29 | 29 |
*/ |
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 | 30 |
package org.gvsig.tools.swing.serv.field; |
35 | 31 |
|
36 | 32 |
import org.gvsig.tools.dataTypes.DataTypes; |
... | ... | |
46 | 42 |
* Swing Factory for the DynField of an unregistered type. |
47 | 43 |
* |
48 | 44 |
* @author 2010 - <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG Team |
49 |
* @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n </a> - |
|
50 |
* gvSIG Team |
|
45 |
* @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n </a> - gvSIG Team |
|
51 | 46 |
* @version $Id$ |
52 |
*
|
|
47 |
* |
|
53 | 48 |
*/ |
54 | 49 |
public class JDefaultDynFieldComponentFactory extends |
55 | 50 |
AbstractJDynFieldComponentFactory implements JDynFieldComponentFactory { |
56 | 51 |
|
57 | 52 |
private static final String FACTORY_DESCRIPTION = ""; |
58 | 53 |
|
59 |
public JDynFieldComponent createJDynFieldComponent(ValueField parent) |
|
60 |
throws ServiceException { |
|
61 |
return new JTextFieldComponent(parent); |
|
54 |
public JDynFieldComponent createJDynFieldComponent(ValueField parent, |
|
55 |
boolean writable) throws ServiceException { |
|
56 |
// TODO: take into account the writable flag |
|
57 |
return new JTextFieldComponent(parent); |
|
62 | 58 |
} |
63 | 59 |
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* |
|
67 |
* @see |
|
68 |
* |
|
69 |
* |
|
70 |
* |
|
71 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryDescription |
|
72 |
* () |
|
73 |
*/ |
|
74 | 60 |
@Override |
75 | 61 |
public String getFactoryDescription() { |
76 | 62 |
return FACTORY_DESCRIPTION; |
77 | 63 |
} |
78 | 64 |
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* |
|
82 |
* @seeorg.gvsig.tools.swing.serv.field.AbstractJDynFieldComponentFactory# |
|
83 |
* getFactorySubType() |
|
84 |
*/ |
|
85 | 65 |
@Override |
86 | 66 |
public String getFactorySubType() { |
87 | 67 |
return null; |
88 | 68 |
} |
89 | 69 |
|
90 |
/* |
|
91 |
* (non-Javadoc) |
|
92 |
* |
|
93 |
* @seeorg.gvsig.tools.swing.serv.field.AbstractJDynFieldComponentFactory# |
|
94 |
* getFactoryType() |
|
95 |
*/ |
|
96 | 70 |
@Override |
97 | 71 |
public Integer getFactoryType() { |
98 | 72 |
return DataTypes.STRING; |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/JNumberDynFieldComponentFactory.java | ||
---|---|---|
53 | 53 |
* Constructor. |
54 | 54 |
* |
55 | 55 |
* @param dataType |
56 |
* the current data Type
|
|
56 |
* the current data Type |
|
57 | 57 |
*/ |
58 | 58 |
public JNumberDynFieldComponentFactory(Integer dataType) { |
59 | 59 |
this.dataType = dataType; |
60 | 60 |
} |
61 | 61 |
|
62 |
public JDynFieldComponent createJDynFieldComponent(ValueField parent) |
|
63 |
throws ServiceException { |
|
64 |
return new JNumberDynFieldComponent(parent); |
|
62 |
public JDynFieldComponent createJDynFieldComponent(ValueField parent, |
|
63 |
boolean writable) throws ServiceException { |
|
64 |
// TODO: take into account the writable flag |
|
65 |
return new JNumberDynFieldComponent(parent); |
|
65 | 66 |
} |
66 | 67 |
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* |
|
70 |
* @see |
|
71 |
* |
|
72 |
* |
|
73 |
* |
|
74 |
* org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryDescription |
|
75 |
* () |
|
76 |
*/ |
|
77 | 68 |
@Override |
78 | 69 |
public String getFactoryDescription() { |
79 | 70 |
return FACTORY_DESCRIPTION; |
80 | 71 |
} |
81 | 72 |
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* |
|
85 |
* @seeorg.gvsig.tools.swing.serv.field.AbstractJDynFieldComponentFactory# |
|
86 |
* getFactorySubType() |
|
87 |
*/ |
|
88 | 73 |
@Override |
89 | 74 |
public String getFactorySubType() { |
90 | 75 |
return null; |
91 | 76 |
} |
92 | 77 |
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* |
|
96 |
* @seeorg.gvsig.tools.swing.serv.field.AbstractJDynFieldComponentFactory# |
|
97 |
* getFactoryType() |
|
98 |
*/ |
|
99 | 78 |
@Override |
100 | 79 |
public Integer getFactoryType() { |
101 | 80 |
if (dataType != null) { |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/component/JTextFieldComponent.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
private JComponent pane; |
64 | 64 |
|
65 |
/** |
|
66 |
* @param dynField |
|
67 |
* @param dynObject |
|
68 |
* @throws ServiceException |
|
69 |
*/ |
|
70 |
public JTextFieldComponent(ValueField parent) throws ServiceException { |
|
71 |
super(parent); |
|
65 |
/** |
|
66 |
* @param writable |
|
67 |
* @param dynField |
|
68 |
* @param dynObject |
|
69 |
* @throws ServiceException |
|
70 |
*/ |
|
71 |
public JTextFieldComponent(ValueField parent) |
|
72 |
throws ServiceException { |
|
73 |
super(parent); |
|
72 | 74 |
} |
73 | 75 |
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* |
|
77 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#afterUI() |
|
78 |
*/ |
|
79 | 76 |
@Override |
80 | 77 |
protected void afterUI() { |
81 | 78 |
// TODO Auto-generated method stub |
82 | 79 |
|
83 | 80 |
} |
84 | 81 |
|
85 |
/* |
|
86 |
* (non-Javadoc) |
|
87 |
* |
|
88 |
* @see org.gvsig.tools.swing.api.dynobject.JComponent#getComponent() |
|
89 |
*/ |
|
90 | 82 |
public JComponent asJComponent() { |
91 | 83 |
if (pane != null) { |
92 | 84 |
return pane; |
... | ... | |
122 | 114 |
tf.setFont(tf.getFont().deriveFont(12f)); |
123 | 115 |
tf.setRows(2); |
124 | 116 |
} |
125 |
// JTextField tff = new JTextField();
|
|
126 |
// tff.setEditable(false);
|
|
127 |
// tff.add(tf);
|
|
117 |
// JTextField tff = new JTextField();
|
|
118 |
// tff.setEditable(false);
|
|
119 |
// tff.add(tf);
|
|
128 | 120 |
// tf.setVisible(false); |
129 | 121 |
this.jtext = tf; |
130 | 122 |
return tf; |
... | ... | |
135 | 127 |
return (value == null) ? "" : value.toString(); |
136 | 128 |
} |
137 | 129 |
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* |
|
141 |
* @see |
|
142 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#getValue |
|
143 |
* () |
|
144 |
*/ |
|
145 |
@Override |
|
146 | 130 |
public Object getValue() { |
147 | 131 |
if (label != null) { |
148 | 132 |
return label.getText(); |
... | ... | |
153 | 137 |
return null; |
154 | 138 |
} |
155 | 139 |
|
156 |
/* |
|
157 |
* (non-Javadoc) |
|
158 |
* |
|
159 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#initData() |
|
160 |
*/ |
|
161 | 140 |
@Override |
162 | 141 |
protected void initData() { |
163 | 142 |
// TODO Auto-generated method stub |
... | ... | |
185 | 164 |
} |
186 | 165 |
} |
187 | 166 |
|
188 |
/* |
|
189 |
* (non-Javadoc) |
|
190 |
* |
|
191 |
* @see |
|
192 |
* |
|
193 |
* |
|
194 |
* |
|
195 |
* |
|
196 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isMandatory |
|
197 |
* () |
|
198 |
*/ |
|
199 | 167 |
@Override |
200 | 168 |
public boolean isMandatory() { |
201 | 169 |
return this.getDynField().isMandatory(); |
202 | 170 |
} |
203 | 171 |
|
204 |
/* |
|
205 |
* (non-Javadoc) |
|
206 |
* |
|
207 |
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) |
|
208 |
*/ |
|
209 | 172 |
public void keyPressed(KeyEvent e) { |
210 | 173 |
// TODO Auto-generated method stub |
211 | 174 |
|
212 | 175 |
} |
213 | 176 |
|
214 |
/* |
|
215 |
* (non-Javadoc) |
|
216 |
* |
|
217 |
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) |
|
218 |
*/ |
|
219 | 177 |
public void keyReleased(KeyEvent e) { |
220 | 178 |
// TODO Auto-generated method stub |
221 | 179 |
|
222 | 180 |
} |
223 | 181 |
|
224 |
/* |
|
225 |
* (non-Javadoc) |
|
226 |
* |
|
227 |
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) |
|
228 |
*/ |
|
229 | 182 |
public void keyTyped(KeyEvent e) { |
230 | 183 |
this.fireValueChangedEvent(); |
231 | 184 |
} |
232 | 185 |
|
233 |
/* |
|
234 |
* (non-Javadoc) |
|
235 |
* |
|
236 |
* @see |
|
237 |
* |
|
238 |
* |
|
239 |
* |
|
240 |
* |
|
241 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#requestFocus |
|
242 |
* () |
|
243 |
*/ |
|
244 | 186 |
public void requestFocus() { |
245 | 187 |
if (label != null) { |
246 | 188 |
label.requestFocus(); |
... | ... | |
249 | 191 |
} |
250 | 192 |
} |
251 | 193 |
|
252 |
/* |
|
253 |
* (non-Javadoc) |
|
254 |
* |
|
255 |
* @see |
|
256 |
* |
|
257 |
* |
|
258 |
* |
|
259 |
* |
|
260 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#setEnabled |
|
261 |
* (boolean) |
|
262 |
*/ |
|
263 | 194 |
public void setEnabled(boolean isEnabled) { |
264 | 195 |
label.setEnabled(isEnabled); |
265 | 196 |
if (label != null) { |
... | ... | |
270 | 201 |
} |
271 | 202 |
} |
272 | 203 |
|
273 |
/* |
|
274 |
* (non-Javadoc) |
|
275 |
* |
|
276 |
* @seeorg.gvsig.tools.swing.spi.AbstractJDynFieldComponent# |
|
277 |
* setJDynFieldComponentListeners() |
|
278 |
*/ |
|
279 | 204 |
@Override |
280 | 205 |
protected void setJDynFieldComponentListeners() { |
281 | 206 |
if (label != null) { |
... | ... | |
287 | 212 |
} |
288 | 213 |
|
289 | 214 |
@Override |
290 |
protected void setNonNullValue(Object value) { |
|
291 |
if (label != null) { |
|
292 |
label.setText(value.toString()); |
|
293 |
} else |
|
294 |
if (jtext != null) { |
|
295 |
jtext.setText(value.toString()); |
|
296 |
} |
|
215 |
protected void setReadOnly() { |
|
216 |
if (jtext != null) { |
|
217 |
jtext.setEditable(false); |
|
218 |
} |
|
297 | 219 |
} |
298 | 220 |
|
299 |
/* |
|
300 |
* (non-Javadoc) |
|
301 |
* |
|
302 |
* @see |
|
303 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#setValue |
|
304 |
* (java.lang.Object) |
|
305 |
*/ |
|
306 |
@Override |
|
307 | 221 |
protected void setNullValue() { |
308 | 222 |
setNonNullValue(""); |
309 | 223 |
} |
310 | 224 |
|
311 |
/* |
|
312 |
* (non-Javadoc) |
|
313 |
* |
|
314 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#setReadOnly() |
|
315 |
*/ |
|
316 |
@Override |
|
317 |
protected void setReadOnly() { |
|
318 |
if (jtext != null) { |
|
319 |
jtext.setEditable(false); |
|
225 |
protected void setNonNullValue(Object value) { |
|
226 |
if (label != null) { |
|
227 |
label.setText(value.toString()); |
|
228 |
} else { |
|
229 |
if (jtext != null) { |
|
230 |
jtext.setText(value.toString()); |
|
231 |
} |
|
320 | 232 |
} |
321 | 233 |
} |
322 | 234 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/component/JBooleanDynFieldComponent.java | ||
---|---|---|
61 | 61 |
private JPanel panel; |
62 | 62 |
private ButtonGroup group; |
63 | 63 |
|
64 |
/** |
|
65 |
* @param dynField |
|
66 |
* @param value |
|
67 |
* @throws ServiceException |
|
68 |
*/ |
|
69 |
public JBooleanDynFieldComponent(ValueField parent) throws ServiceException { |
|
70 |
super(parent); |
|
64 |
/** |
|
65 |
* @param writable |
|
66 |
* @param dynField |
|
67 |
* @param value |
|
68 |
* @throws ServiceException |
|
69 |
*/ |
|
70 |
public JBooleanDynFieldComponent(ValueField parent) |
|
71 |
throws ServiceException { |
|
72 |
super(parent); |
|
71 | 73 |
if (parent.getDynField().isContainer()) { |
72 | 74 |
this.btUnknown.setEnabled(false); |
73 | 75 |
} |
... | ... | |
86 | 88 |
|
87 | 89 |
} |
88 | 90 |
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* |
|
92 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#afterUI() |
|
93 |
*/ |
|
94 | 91 |
@Override |
95 | 92 |
protected void afterUI() { |
96 | 93 |
|
97 | 94 |
} |
98 | 95 |
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* |
|
102 |
* @see |
|
103 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JComponent#getComponent() |
|
104 |
*/ |
|
105 | 96 |
public JComponent asJComponent() { |
106 | 97 |
return panel; |
107 | 98 |
} |
108 | 99 |
|
109 |
/* |
|
110 |
* (non-Javadoc) |
|
111 |
* |
|
112 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue() |
|
113 |
*/ |
|
114 |
@Override |
|
115 | 100 |
public Object getValue() { |
116 | 101 |
return value; |
117 | 102 |
} |
118 | 103 |
|
119 |
/* |
|
120 |
* (non-Javadoc) |
|
121 |
* |
|
122 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#initData() |
|
123 |
*/ |
|
124 | 104 |
@Override |
125 | 105 |
protected void initData() { |
126 | 106 |
|
... | ... | |
164 | 144 |
panel.add(btUnknown); |
165 | 145 |
} |
166 | 146 |
|
167 |
/* |
|
168 |
* (non-Javadoc) |
|
169 |
* |
|
170 |
* @see |
|
171 |
* |
|
172 |
* |
|
173 |
* |
|
174 |
* |
|
175 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isMandatory |
|
176 |
* () |
|
177 |
*/ |
|
178 | 147 |
@Override |
179 | 148 |
public boolean isMandatory() { |
180 | 149 |
return this.getDynField().isMandatory(); |
181 | 150 |
} |
182 | 151 |
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* |
|
186 |
* @see |
|
187 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#setFocus |
|
188 |
* () |
|
189 |
*/ |
|
190 | 152 |
public void requestFocus() { |
191 | 153 |
btFalse.requestFocus(); |
192 | 154 |
} |
193 | 155 |
|
194 |
/* |
|
195 |
* (non-Javadoc) |
|
196 |
* |
|
197 |
* @see |
|
198 |
* |
|
199 |
* |
|
200 |
* |
|
201 |
* |
|
202 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#setEnabled |
|
203 |
* (boolean) |
|
204 |
*/ |
|
205 | 156 |
public void setEnabled(boolean isEnabled) { |
206 | 157 |
// We are trying to enable something that is ReadOnly. |
207 | 158 |
// This is not possible |
... | ... | |
214 | 165 |
btUnknown.setEnabled(isEnabled); |
215 | 166 |
} |
216 | 167 |
|
217 |
/* |
|
218 |
* (non-Javadoc) |
|
219 |
* |
|
220 |
* @seeorg.gvsig.tools.swing.spi.AbstractJDynFieldComponent# |
|
221 |
* setJDynFieldComponentListeners() |
|
222 |
*/ |
|
223 | 168 |
@Override |
224 | 169 |
protected void setJDynFieldComponentListeners() { |
225 | 170 |
// TODO Auto-generated method stub |
... | ... | |
227 | 172 |
} |
228 | 173 |
|
229 | 174 |
@Override |
175 |
protected void setReadOnly() { |
|
176 |
this.setEnabled(false); |
|
177 |
} |
|
178 |
|
|
179 |
protected void setNullValue() { |
|
180 |
btTrue.setSelected(false); |
|
181 |
btFalse.setSelected(false); |
|
182 |
btUnknown.setSelected(true); |
|
183 |
this.value = null; |
|
184 |
} |
|
185 |
|
|
230 | 186 |
protected void setNonNullValue(Object value) { |
231 | 187 |
if (value instanceof String) { |
232 | 188 |
setNullValue(); |
... | ... | |
246 | 202 |
setNullValue(); |
247 | 203 |
} |
248 | 204 |
} |
249 |
|
|
250 |
/* |
|
251 |
* (non-Javadoc) |
|
252 |
* |
|
253 |
* @see |
|
254 |
* org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java |
|
255 |
* .lang.Object) |
|
256 |
*/ |
|
257 |
@Override |
|
258 |
protected void setNullValue() { |
|
259 |
btTrue.setSelected(false); |
|
260 |
btFalse.setSelected(false); |
|
261 |
btUnknown.setSelected(true); |
|
262 |
this.value = null; |
|
263 |
} |
|
264 |
|
|
265 |
/* |
|
266 |
* (non-Javadoc) |
|
267 |
* |
|
268 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#setReadOnly() |
|
269 |
*/ |
|
270 |
@Override |
|
271 |
protected void setReadOnly() { |
|
272 |
this.setEnabled(false); |
|
273 |
} |
|
274 | 205 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/component/JFileDynfieldComponent.java | ||
---|---|---|
66 | 66 |
private JFileChooser fc; |
67 | 67 |
private JButton jBtnChangeFile; |
68 | 68 |
|
69 |
/** |
|
70 |
* @param parent |
|
71 |
* @param dynField |
|
72 |
* @throws ServiceException |
|
73 |
*/ |
|
74 |
public JFileDynfieldComponent(ValueField parent) throws ServiceException { |
|
75 |
super(parent); |
|
69 |
/** |
|
70 |
* @param parent |
|
71 |
* @param writable |
|
72 |
* @param dynField |
|
73 |
* @throws ServiceException |
|
74 |
*/ |
|
75 |
public JFileDynfieldComponent(ValueField parent) |
|
76 |
throws ServiceException { |
|
77 |
super(parent); |
|
76 | 78 |
} |
77 | 79 |
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* |
|
81 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#afterUI() |
|
82 |
*/ |
|
83 | 80 |
@Override |
84 | 81 |
protected void afterUI() { |
85 | 82 |
// TODO Auto-generated method stub |
86 | 83 |
|
87 | 84 |
} |
88 | 85 |
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* |
|
92 |
* @see |
|
93 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JComponent#getComponent() |
|
94 |
*/ |
|
95 |
public JComponent asJComponent() { |
|
96 |
return panel; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* @param path |
|
101 |
*/ |
|
102 |
private boolean checkPath(String path) { |
|
103 |
if ((path == null) || (path.equals(""))) { |
|
104 |
if (this.getDynField().isMandatory()) { |
|
105 |
return false; |
|
106 |
} |
|
107 |
return true; |
|
108 |
} |
|
109 |
java.io.File f = new File(path); |
|
110 |
if (f == null) { |
|
111 |
return false; |
|
112 |
} |
|
113 |
this.file = f; |
|
114 |
return true; |
|
115 |
} |
|
116 |
|
|
117 |
/* |
|
118 |
* (non-Javadoc) |
|
119 |
* |
|
120 |
* @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) |
|
121 |
*/ |
|
122 | 86 |
public void focusGained(FocusEvent e) { |
123 | 87 |
previousText = tfFile.getText(); |
124 | 88 |
} |
125 | 89 |
|
126 |
/* |
|
127 |
* (non-Javadoc) |
|
128 |
* |
|
129 |
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) |
|
130 |
*/ |
|
131 | 90 |
public void focusLost(FocusEvent e) { |
132 | 91 |
// if (!this.isValid()) |
133 | 92 |
// tfFile.setText(previousText); |
... | ... | |
136 | 95 |
this.fireValueChangedEvent(); |
137 | 96 |
} |
138 | 97 |
|
98 |
public JComponent asJComponent() { |
|
99 |
return panel; |
|
100 |
} |
|
101 |
|
|
102 |
public Object getValue() { |
|
103 |
return file; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
protected void initData() { |
|
108 |
previousText = ""; |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
protected void initUI() { |
|
113 |
tfFile = new JTextField(); |
|
114 |
tfFile.addKeyListener(this); |
|
115 |
panel = this.createBoxLayout(tfFile,getJBtnChangeFile() , 1, 1, null); |
|
116 |
initBtnChangeFile(); |
|
117 |
} |
|
118 |
|
|
139 | 119 |
/** |
140 | 120 |
* This method initializes jButton |
141 | 121 |
* |
... | ... | |
149 | 129 |
} |
150 | 130 |
return jBtnChangeFile; |
151 | 131 |
} |
152 |
|
|
153 |
/* |
|
154 |
* (non-Javadoc) |
|
155 |
* |
|
156 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue() |
|
157 |
*/ |
|
158 |
@Override |
|
159 |
public Object getValue() { |
|
160 |
return file; |
|
161 |
} |
|
162 |
|
|
132 |
|
|
163 | 133 |
private void initBtnChangeFile() { |
164 | 134 |
getJBtnChangeFile().addActionListener(new ActionListener() { |
165 | 135 |
|
... | ... | |
170 | 140 |
}); |
171 | 141 |
} |
172 | 142 |
|
173 |
/* |
|
174 |
* (non-Javadoc) |
|
175 |
* |
|
176 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#initData() |
|
177 |
*/ |
|
178 | 143 |
@Override |
179 |
protected void initData() { |
|
180 |
previousText = ""; |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
protected void initUI() { |
|
185 |
tfFile = new JTextField(); |
|
186 |
tfFile.addKeyListener(this); |
|
187 |
panel = this.createBoxLayout(tfFile, getJBtnChangeFile(), 1, 1, null); |
|
188 |
initBtnChangeFile(); |
|
189 |
} |
|
190 |
|
|
191 |
/* |
|
192 |
* (non-Javadoc) |
|
193 |
* |
|
194 |
* @see |
|
195 |
* |
|
196 |
* |
|
197 |
* |
|
198 |
* |
|
199 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isMandatory |
|
200 |
* () |
|
201 |
*/ |
|
202 |
@Override |
|
203 | 144 |
public boolean isMandatory() { |
204 | 145 |
return this.getDynField().isMandatory(); |
205 | 146 |
} |
206 | 147 |
|
207 |
/* |
|
208 |
* (non-Javadoc) |
|
209 |
* |
|
210 |
* @see org.gvsig.tools.swing.spi.AbstractJDynFieldComponent#isValid() |
|
211 |
*/ |
|
212 |
@Override |
|
213 |
public boolean isValid() { |
|
214 |
String path = this.tfFile.getText(); |
|
215 |
return checkPath(path); |
|
216 |
} |
|
217 |
|
|
218 |
/* |
|
219 |
* (non-Javadoc) |
|
220 |
* |
|
221 |
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) |
|
222 |
*/ |
|
223 |
public void keyPressed(KeyEvent e) { |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
/* |
|
228 |
* (non-Javadoc) |
|
229 |
* |
Also available in: Unified diff