Revision 477
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.main/src/main/java/org/gvsig/tools/main/dynobject/DynObjectComponentAction.java | ||
---|---|---|
38 | 38 |
import javax.swing.JPanel; |
39 | 39 |
import javax.swing.JTabbedPane; |
40 | 40 |
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 | 41 |
import org.gvsig.tools.ToolsLocator; |
45 | 42 |
import org.gvsig.tools.dynobject.DynObjectManager; |
46 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
47 | 43 |
import org.gvsig.tools.main.MainAction; |
48 | 44 |
import org.gvsig.tools.service.ServiceException; |
49 | 45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
... | ... | |
59 | 55 |
|
60 | 56 |
private static final long serialVersionUID = -3386010046112585198L; |
61 | 57 |
|
62 |
private final static Logger LOG = LoggerFactory |
|
63 |
.getLogger(DynObjectComponentAction.class); |
|
64 |
|
|
65 | 58 |
private static DynObjectManager dynManager = |
66 | 59 |
ToolsLocator.getDynObjectManager(); |
67 | 60 |
|
... | ... | |
129 | 122 |
*/ |
130 | 123 |
protected void launchNewFrame() { |
131 | 124 |
|
132 |
try { |
|
133 |
getDynObjectView().saveStatus(); |
|
134 |
|
|
125 |
getDynObjectView().saveStatus(); |
|
135 | 126 |
|
136 | 127 |
final JFrame frame = new JFrame("Tools swing components test app"); |
137 | 128 |
// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
... | ... | |
142 | 133 |
// Display the window. |
143 | 134 |
frame.pack(); |
144 | 135 |
frame.setVisible(true); |
145 |
} catch (DynFieldValidateException e) { |
|
146 |
LOG.warn("Value validation error: " |
|
147 |
+ this.getDynObjectView().getDynField().getName(), this.getDynObjectView().getValue()); |
|
148 |
} |
|
149 | 136 |
} |
150 | 137 |
|
151 | 138 |
public void registerDynObjects() { |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/test/java/org/gvsig/tools/persistence/case1/model/Layer.java | ||
---|---|---|
91 | 91 |
public void clear() { |
92 | 92 |
values.clear(); |
93 | 93 |
} |
94 |
|
|
95 |
public boolean hasEmptyValues() { |
|
96 |
return values.hasEmptyValues(); |
|
97 |
} |
|
98 | 94 |
|
99 | 95 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/DynObject.java | ||
---|---|---|
52 | 52 |
Object invokeDynMethod(int code, DynObject context) throws DynMethodException; |
53 | 53 |
|
54 | 54 |
void clear(); |
55 |
|
|
56 |
boolean hasEmptyValues(); |
|
57 | 55 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/persistence/impl/AbstractPersistenceManager.java | ||
---|---|---|
220 | 220 |
// Nothing to do |
221 | 221 |
} |
222 | 222 |
|
223 |
public boolean hasEmptyValues() { |
|
224 |
return true; |
|
225 |
} |
|
226 |
|
|
227 | 223 |
} |
228 | 224 |
|
229 | 225 |
public int getAutoValidation() { |
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 | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.gvsig.tools.dynobject.DynField; |
33 | 33 |
import org.gvsig.tools.dynobject.DynObject; |
34 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
35 | 34 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
36 | 35 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
37 | 36 |
|
... | ... | |
65 | 64 |
|
66 | 65 |
/** |
67 | 66 |
* Stores the edited data into the {@link DynObject} field. |
68 |
* @throws DynFieldValidateException |
|
69 | 67 |
*/ |
70 |
public void saveStatus() throws DynFieldValidateException;
|
|
68 |
public void saveStatus(); |
|
71 | 69 |
|
72 | 70 |
/** |
73 | 71 |
* Allows adding a listener to the list of listeners of this JDynComponent. |
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 | ||
---|---|---|
30 | 30 |
package org.gvsig.tools.swing.api.dynobject.dynfield; |
31 | 31 |
|
32 | 32 |
import org.gvsig.tools.dynobject.DynField; |
33 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
34 | 33 |
import org.gvsig.tools.swing.api.ComponentService; |
35 | 34 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
36 | 35 |
|
... | ... | |
112 | 111 |
* calls the <b>handleValueChanged</b> function by specifying this |
113 | 112 |
* JDynFieldComponent object |
114 | 113 |
* as the one that has been changed. |
114 |
* |
|
115 |
* @see ValueChangedListener#handleValueChanged(JDynFieldComponent) |
|
115 | 116 |
*/ |
116 | 117 |
public void fireValueChangedEvent(); |
117 | 118 |
|
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/ValueField.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import org.gvsig.tools.dynobject.DynField; |
37 | 37 |
import org.gvsig.tools.dynobject.DynObject; |
38 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
39 | 38 |
|
40 | 39 |
/** |
41 | 40 |
* |
... | ... | |
85 | 84 |
* |
86 | 85 |
* @return the default value. |
87 | 86 |
*/ |
88 |
public void setFieldValue(Object value)throws DynFieldValidateException;
|
|
87 |
public void setFieldValue(Object value); |
|
89 | 88 |
|
90 | 89 |
/** |
91 | 90 |
* Sets the current value to the DynObject element. |
92 | 91 |
* |
93 | 92 |
* @param value |
94 | 93 |
* the value to be set. |
95 |
* @throws DynFieldValidateException |
|
96 | 94 |
*/ |
97 |
public void setValue(Object value) throws DynFieldValidateException;
|
|
95 |
public void setValue(Object value); |
|
98 | 96 |
|
99 | 97 |
} |
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/ValueChangedListener.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import java.util.EventListener; |
37 | 37 |
|
38 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
39 | 38 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynComponent; |
40 | 39 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
41 | 40 |
|
... | ... | |
60 | 59 |
* @param jDynFieldComponent |
61 | 60 |
* the JDynFieldComponent that changed its value and caused this |
62 | 61 |
* event. |
63 |
* @throws DynFieldValidateException |
|
64 | 62 |
*/ |
65 | 63 |
public void handleValueChanged(JDynFieldComponent jDynFieldComponent); |
66 | 64 |
} |
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/task/JTaskStatus.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
public abstract void setShowCancelButton(boolean showCancelButton); |
21 | 21 |
|
22 |
public abstract boolean getShowRemoveTaskButton(); |
|
23 |
|
|
24 |
public abstract void setShowRemoveTaskButton(boolean showRemoveTaskButton) ; |
|
25 |
|
|
22 | 26 |
public abstract void setTittle(String tittle); |
23 | 27 |
|
24 | 28 |
public abstract TaskStatus getTaskStatus(); |
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 | ||
---|---|---|
32 | 32 |
import javax.swing.JButton; |
33 | 33 |
import javax.swing.JPanel; |
34 | 34 |
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 | 35 |
import org.gvsig.tools.ToolsLocator; |
39 | 36 |
import org.gvsig.tools.dynobject.DynObject; |
40 | 37 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
... | ... | |
55 | 52 |
implements JDynFieldComponent { |
56 | 53 |
|
57 | 54 |
private static final long serialVersionUID = 7833217085675382320L; |
58 |
|
|
59 |
private final static Logger LOG = LoggerFactory |
|
60 |
.getLogger(AbstractJDynFieldComponent.class); |
|
61 | 55 |
|
62 | 56 |
private final DynObjectSwingManager manager; |
63 | 57 |
|
... | ... | |
216 | 210 |
* Stores the edited data into the DynObject field. |
217 | 211 |
*/ |
218 | 212 |
public void saveStatus() { |
219 |
try { |
|
220 |
this.setFieldValue(this.getValue()); |
|
221 |
} catch (DynFieldValidateException e) { |
|
222 |
LOG.warn("Field '" + this.getFieldName() + "' with validation error: " + this.getValue()); |
|
223 |
} |
|
213 |
this.setFieldValue(this.getValue()); |
|
224 | 214 |
} |
225 | 215 |
|
226 | 216 |
/** |
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 | ||
---|---|---|
39 | 39 |
import java.util.Map; |
40 | 40 |
|
41 | 41 |
import org.gvsig.tools.dynobject.DynObject; |
42 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
|
43 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
44 | 42 |
import org.gvsig.tools.service.Manager; |
45 | 43 |
import org.gvsig.tools.service.ServiceException; |
46 | 44 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
... | ... | |
207 | 205 |
*/ |
208 | 206 |
protected void emptyAll() { |
209 | 207 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
210 |
for (JDynFieldComponent item : items.values()){ |
|
211 |
try { |
|
212 |
item.setValue(null); |
|
213 |
} catch (DynFieldValidateException e) { |
|
214 |
// TODO Auto-generated catch block |
|
215 |
e.printStackTrace(); |
|
216 |
} |
|
217 |
} |
|
208 |
for (JDynFieldComponent item : items.values()) |
|
209 |
item.setValue(null); |
|
218 | 210 |
} |
219 | 211 |
|
220 | 212 |
/** |
... | ... | |
226 | 218 |
*/ |
227 | 219 |
protected void fillValues(DynObject dynObject) { |
228 | 220 |
Map<Component, JDynFieldComponent> items = this.getComponents(); |
229 |
for (JDynFieldComponent item : items.values()){ |
|
230 |
try { |
|
231 |
item.setValue(dynObject.getDynValue(item.getDynField().getName())); |
|
232 |
} catch (DynFieldValidateException e) { |
|
233 |
// TODO Auto-generated catch block |
|
234 |
e.printStackTrace(); |
|
235 |
} catch (DynFieldNotFoundException e) { |
|
236 |
// TODO Auto-generated catch block |
|
237 |
e.printStackTrace(); |
|
238 |
} |
|
239 |
} |
|
221 |
for (JDynFieldComponent item : items.values()) |
|
222 |
item.setValue(dynObject.getDynValue(item.getDynField().getName())); |
|
240 | 223 |
} |
241 | 224 |
|
242 | 225 |
/** |
... | ... | |
249 | 232 |
JDynFieldComponent comp; |
250 | 233 |
while (componentFields.hasNext()) { |
251 | 234 |
comp = componentFields.next(); |
252 |
try { |
|
253 |
comp.saveStatus(); |
|
254 |
} catch (DynFieldValidateException e) { |
|
255 |
// TODO Auto-generated catch block |
|
256 |
e.printStackTrace(); |
|
257 |
} |
|
235 |
comp.saveStatus(); |
|
258 | 236 |
} |
259 | 237 |
} |
260 | 238 |
|
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 | ||
---|---|---|
36 | 36 |
import java.util.ArrayList; |
37 | 37 |
import java.util.List; |
38 | 38 |
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 | 39 |
import org.gvsig.tools.dynobject.DynField; |
43 | 40 |
import org.gvsig.tools.dynobject.DynObject; |
44 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
45 | 41 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
46 | 42 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
47 | 43 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
... | ... | |
67 | 63 |
*/ |
68 | 64 |
public abstract class AbstractJDynField { |
69 | 65 |
|
70 |
private final static Logger LOG = LoggerFactory |
|
71 |
.getLogger(AbstractJDynField.class); |
|
72 |
|
|
73 | 66 |
private ValueField parent; |
74 | 67 |
|
75 | 68 |
protected final List<ValueChangedListener> listeners; |
... | ... | |
106 | 99 |
* Then all {@link ValueChangedListener}s are fired to alert them |
107 | 100 |
* to check if the value has changed via the {@link getValue()} function of |
108 | 101 |
* the {@link JDynFieldComponent}. |
109 |
* @throws DynFieldValidateException |
|
110 | 102 |
*/ |
111 | 103 |
public abstract void fireValueChangedEvent(); |
112 | 104 |
|
... | ... | |
176 | 168 |
if (this.getDynField().isReadOnly()) { |
177 | 169 |
this.setReadOnly(); |
178 | 170 |
} |
179 |
try { |
|
180 |
this.setValue(getInitialValue()); |
|
181 |
} catch (DynFieldValidateException e) { |
|
182 |
LOG.warn("Initial value validation error: " + this.getDynField().getName() + ", value =" + getInitialValue()); |
|
183 |
} |
|
171 |
this.setValue(getInitialValue()); |
|
184 | 172 |
this.afterUI(); |
185 | 173 |
} |
186 | 174 |
|
... | ... | |
200 | 188 |
/** |
201 | 189 |
* Sets the current value of the {@link JDynFieldComponent} to the |
202 | 190 |
* {@link DynObject} value via the {@link ValueField} object. |
203 |
* @throws DynFieldValidateException |
|
204 | 191 |
* |
205 | 192 |
*/ |
206 |
public void setFieldValue(Object value) throws DynFieldValidateException {
|
|
193 |
public void setFieldValue(Object value) { |
|
207 | 194 |
this.getValueField().setFieldValue(value); |
208 | 195 |
} |
209 | 196 |
|
... | ... | |
246 | 233 |
* |
247 | 234 |
* @param value |
248 | 235 |
* the value to be set into the swing component. |
249 |
* @throws DynFieldValidateException |
|
250 | 236 |
*/ |
251 |
public void setValue(Object value) throws DynFieldValidateException {
|
|
237 |
public void setValue(Object value) { |
|
252 | 238 |
if (value == null) { |
253 | 239 |
setNullValue(); |
254 | 240 |
} else { |
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/JNumberDynFieldComponent.java | ||
---|---|---|
31 | 31 |
import javax.swing.ImageIcon; |
32 | 32 |
import javax.swing.JComponent; |
33 | 33 |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 | 34 |
import org.gvsig.tools.dynobject.DynObject; |
38 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
39 | 35 |
import org.gvsig.tools.service.ServiceException; |
40 | 36 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
41 | 37 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
... | ... | |
52 | 48 |
|
53 | 49 |
private static final long serialVersionUID = -8120715001446683582L; |
54 | 50 |
|
55 |
private final static Logger LOG = LoggerFactory |
|
56 |
.getLogger(JNumberDynFieldComponent.class); |
|
57 |
|
|
58 | 51 |
private static Object NULL_VALUE = null; |
59 |
private static final String BTN_EMPTY_IMG_PATH = "editdelete.png";
|
|
52 |
private static final String BTN_EMPTY_IMG_PATH = "editdelete.png";
|
|
60 | 53 |
|
61 | 54 |
private JNullValueMuttableTextField pane; |
62 | 55 |
|
... | ... | |
65 | 58 |
* @throws ServiceException |
66 | 59 |
* @see JDynFieldComponent#JDynFieldComponent(DynField, DynObject). |
67 | 60 |
*/ |
68 |
public JNumberDynFieldComponent(ValueField parent) throws ServiceException { |
|
69 |
super(parent); |
|
61 |
public JNumberDynFieldComponent(ValueField parent) |
|
62 |
throws ServiceException { |
|
63 |
super(parent); |
|
70 | 64 |
} |
71 | 65 |
|
72 | 66 |
/* |
... | ... | |
89 | 83 |
} |
90 | 84 |
|
91 | 85 |
protected ImageIcon getBtnEmptyImageIcon() { |
92 |
return new ImageIcon(this.getClass().getResource(BTN_EMPTY_IMG_PATH));
|
|
86 |
return new ImageIcon(this.getClass().getResource(BTN_EMPTY_IMG_PATH));
|
|
93 | 87 |
} |
94 | 88 |
|
95 | 89 |
private JNullValueMuttableTextField getModel() { |
... | ... | |
127 | 121 |
@Override |
128 | 122 |
protected void initUI() { |
129 | 123 |
this.pane = |
130 |
new JNullValueMuttableTextField(this.getDynField(), |
|
131 |
this.getInitialValue(), Locale.getDefault(), |
|
132 |
getBtnEmptyImageIcon()); |
|
124 |
new JNullValueMuttableTextField(this.getDynField(), this |
|
125 |
.getInitialValue(), Locale.getDefault(), getBtnEmptyImageIcon()); |
|
133 | 126 |
this.pane.addValueChangedListener(this); |
134 | 127 |
} |
135 | 128 |
|
... | ... | |
161 | 154 |
@Override |
162 | 155 |
public void saveStatus() { |
163 | 156 |
if (getModel() != null) { |
164 |
try { |
|
165 |
this.setFieldValue(getModel().getValue()); |
|
166 |
} catch (DynFieldValidateException e) { |
|
167 |
// LOG.warn("Value validation error: " |
|
168 |
// + this.getDynField().getName(), getModel().getValue()); |
|
169 |
} |
|
157 |
this.setFieldValue(getModel().getValue()); |
|
170 | 158 |
} |
171 | 159 |
} |
172 | 160 |
|
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/JNullValueMuttableTextField.java | ||
---|---|---|
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
String description = "Empties the field value."; |
120 |
icon.setDescription(description); |
|
121 |
|
|
120 | 122 |
btnEmptyLabel = new JButton(); |
121 | 123 |
btnEmptyLabel.setActionCommand("BTN_OK"); |
122 | 124 |
btnEmptyLabel.setOpaque(false); |
123 | 125 |
btnEmptyLabel.setBorderPainted(false); |
124 | 126 |
btnEmptyLabel.setBorder(BorderFactory.createEmptyBorder()); |
125 |
if (icon!=null){ |
|
126 |
icon.setDescription(description); |
|
127 |
|
|
128 |
btnEmptyLabel.setSize(new java.awt.Dimension(icon.getIconWidth(), icon |
|
129 |
.getIconHeight())); |
|
130 |
btnEmptyLabel.setIcon(icon); |
|
131 |
}else{ |
|
132 |
btnEmptyLabel.setText("X"); |
|
133 |
} |
|
127 |
btnEmptyLabel.setSize(new java.awt.Dimension(icon.getIconWidth(), icon |
|
128 |
.getIconHeight())); |
|
134 | 129 |
btnEmptyLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
135 | 130 |
btnEmptyLabel.setVerticalAlignment(SwingConstants.TOP); |
131 |
btnEmptyLabel.setIcon(icon); |
|
136 | 132 |
|
137 | 133 |
// btnEmptyPanel = new JPanel(); |
138 | 134 |
// btnEmptyPanel.add(btnEmptyLabel); |
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 | ||
---|---|---|
42 | 42 |
import javax.swing.JPanel; |
43 | 43 |
import javax.swing.JRadioButton; |
44 | 44 |
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
49 | 45 |
import org.gvsig.tools.service.ServiceException; |
50 | 46 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
51 | 47 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
... | ... | |
58 | 54 |
public class JBooleanDynFieldComponent extends AbstractJDynFieldComponent |
59 | 55 |
implements JDynFieldComponent, ActionListener { |
60 | 56 |
|
61 |
private final static Logger LOG = LoggerFactory |
|
62 |
.getLogger(JBooleanDynFieldComponent.class); |
|
63 |
|
|
64 | 57 |
private JRadioButton btTrue; |
65 | 58 |
private JRadioButton btFalse; |
66 | 59 |
private JRadioButton btUnknown; |
... | ... | |
68 | 61 |
private JPanel panel; |
69 | 62 |
private ButtonGroup group; |
70 | 63 |
|
71 |
/** |
|
72 |
* @param writable |
|
73 |
* @param dynField |
|
74 |
* @param value |
|
75 |
* @throws ServiceException |
|
76 |
*/ |
|
77 |
public JBooleanDynFieldComponent(ValueField parent) throws ServiceException { |
|
78 |
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); |
|
79 | 73 |
if (parent.getDynField().isContainer()) { |
80 | 74 |
this.btUnknown.setEnabled(false); |
81 | 75 |
} |
... | ... | |
83 | 77 |
|
84 | 78 |
public void actionPerformed(ActionEvent e) { |
85 | 79 |
Object source = e.getSource(); |
86 |
Boolean bool = null; |
|
87 | 80 |
if (source == btTrue) { |
88 |
bool = true;
|
|
81 |
this.setValue(true);
|
|
89 | 82 |
} else |
90 | 83 |
if (source == btFalse) { |
91 |
bool = false; |
|
84 |
this.setValue(false); |
|
85 |
} else { |
|
86 |
this.setValue(null); |
|
92 | 87 |
} |
93 |
|
|
94 |
try { |
|
95 |
this.setValue(bool); |
|
96 |
} catch (DynFieldValidateException e1) { |
|
97 |
LOG.warn("Value validation error: " |
|
98 |
+ this.getDynField().getName(), bool); |
|
99 |
} |
|
88 |
|
|
100 | 89 |
} |
101 | 90 |
|
102 | 91 |
@Override |
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/date/JDateCalendarDynFieldComponent.java | ||
---|---|---|
17 | 17 |
import javax.swing.event.ChangeListener; |
18 | 18 |
|
19 | 19 |
import org.freixas.jcalendar.DateEvent; |
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 | 20 |
|
23 | 21 |
import org.gvsig.tools.dataTypes.DataTypes; |
24 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
25 | 22 |
import org.gvsig.tools.service.ServiceException; |
26 | 23 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
27 | 24 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
... | ... | |
33 | 30 |
implements JDynFieldComponent, FocusListener, ChangeListener, |
34 | 31 |
ValueChangedListener, ActionListener { |
35 | 32 |
|
36 |
private final static Logger LOG = LoggerFactory |
|
37 |
.getLogger(JDateCalendarDynFieldComponent.class); |
|
33 |
private static final String BTN_EMPTY_IMG_PATH = "editdelete.png"; |
|
38 | 34 |
|
39 |
private static final String BTN_EMPTY_IMG_PATH = "editdelete.png"; |
|
40 |
|
|
41 | 35 |
private JButton jBtnChangeDate; |
42 | 36 |
// private JNullSpinner dateField; |
43 | 37 |
private DateCalendarPicker datePicker; |
... | ... | |
46 | 40 |
private JNullValueMuttableTextField dateFieldPanel; |
47 | 41 |
private Object oldTxt; |
48 | 42 |
|
49 |
public JDateCalendarDynFieldComponent(ValueField valueField)
|
|
43 |
public JDateCalendarDynFieldComponent(ValueField valueField)
|
|
50 | 44 |
throws ServiceException { |
51 |
super(valueField);
|
|
45 |
super(valueField);
|
|
52 | 46 |
if (getDynField().getType() != DataTypes.DATE) { |
53 | 47 |
this.getJBtnChangeDate().setVisible(false); |
54 | 48 |
} |
55 | 49 |
} |
56 | 50 |
|
57 | 51 |
public void actionPerformed(ActionEvent e) { |
58 |
try { |
|
59 |
JButton btn = (JButton) e.getSource(); |
|
60 |
if (btn.getActionCommand().equals("BTN_OK")) { |
|
61 |
if (dlg != null) { |
|
62 |
setValue(datePicker.getSelectedDate()); |
|
63 |
} |
|
64 |
} |
|
52 |
JButton btn = (JButton) e.getSource(); |
|
53 |
if (btn.getActionCommand().equals("BTN_OK")) { |
|
65 | 54 |
if (dlg != null) { |
66 |
dlg.setVisible(false);
|
|
55 |
setValue(datePicker.getSelectedDate());
|
|
67 | 56 |
} |
68 |
this.fireValueChangedEvent(); |
|
69 |
} catch (DynFieldValidateException e1) { |
|
70 |
// TODO Auto-generated catch block |
|
71 |
LOG.warn("Initial value validation error: " |
|
72 |
+ this.getDynField().getName(), datePicker.getSelectedDate()); |
|
73 | 57 |
} |
58 |
if (dlg != null) { |
|
59 |
dlg.setVisible(false); |
|
60 |
} |
|
61 |
this.fireValueChangedEvent(); |
|
74 | 62 |
} |
75 | 63 |
|
76 | 64 |
@Override |
... | ... | |
112 | 100 |
|
113 | 101 |
public void focusLost(FocusEvent e) { |
114 | 102 |
Object txt = getValue(); |
115 |
|
|
116 | 103 |
Date date = getDate(); |
117 | 104 |
if (date == null) { |
118 |
try { |
|
119 |
if (!((txt == null) || (txt.equals("")))) { |
|
120 |
setValue(oldTxt); |
|
121 |
} |
|
122 |
} catch (DynFieldValidateException e1) { |
|
123 |
// TODO Auto-generated catch block |
|
124 |
LOG.warn("Initial value validation error: " |
|
125 |
+ this.getDynField().getName(), txt); |
|
105 |
if (!((txt == null) || (txt.equals("")))) { |
|
106 |
setValue(oldTxt); |
|
126 | 107 |
} |
127 | 108 |
} else { |
128 |
try { |
|
129 |
setValue(txt); |
|
130 |
oldTxt = txt; |
|
131 |
} catch (DynFieldValidateException e1) { |
|
132 |
// TODO Auto-generated catch block |
|
133 |
LOG.warn("Initial value validation error: " |
|
134 |
+ this.getDynField().getName(), txt); |
|
135 |
} |
|
109 |
setValue(txt); |
|
110 |
oldTxt = txt; |
|
136 | 111 |
} |
137 | 112 |
this.fireValueChangedEvent(); |
138 |
|
|
139 | 113 |
} |
140 | 114 |
|
141 | 115 |
protected ImageIcon getBtnEmptyImageIcon() { |
142 |
URL res = |
|
143 |
org.gvsig.tools.swing.serv.field.component.date.JDateDynFieldComponent.class |
|
144 |
.getResource(BTN_EMPTY_IMG_PATH); |
|
145 |
if (res != null) { |
|
146 |
return new ImageIcon(res); |
|
116 |
URL res = this.getClass().getResource(BTN_EMPTY_IMG_PATH); |
|
117 |
if (res!=null){ |
|
118 |
return new ImageIcon(res); |
|
147 | 119 |
} |
148 | 120 |
return null; |
149 | 121 |
} |
... | ... | |
204 | 176 |
@Override |
205 | 177 |
protected void initUI() { |
206 | 178 |
this.dateFieldPanel = |
207 |
new JNullValueMuttableTextField(this.getDynField(), |
|
208 |
this.getInitialValue(), Locale.getDefault(), |
|
209 |
getBtnEmptyImageIcon()); |
|
179 |
new JNullValueMuttableTextField(this.getDynField(), this |
|
180 |
.getInitialValue(), Locale.getDefault(), getBtnEmptyImageIcon()); |
|
210 | 181 |
// this.dateFieldPanel.addEmptyButtonActionListener(this); |
211 | 182 |
this.dateFieldPanel.add(this.getJBtnChangeDate()); |
212 | 183 |
this.dateFieldPanel.addValueChangedListener(this); |
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/components/file/JFileChooser.java | ||
---|---|---|
40 | 40 |
import javax.swing.ImageIcon; |
41 | 41 |
import javax.swing.filechooser.FileFilter; |
42 | 42 |
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 | 43 |
import org.gvsig.tools.dataTypes.DataTypes; |
47 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
48 | 44 |
import org.gvsig.tools.swing.api.ComponentService; |
49 | 45 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
50 | 46 |
import org.gvsig.tools.swing.serv.field.ToolsSwingDefaultFieldImplLibrary; |
... | ... | |
60 | 56 |
*/ |
61 | 57 |
public class JFileChooser implements JFileExtensionList { |
62 | 58 |
|
63 |
private final static Logger LOG = LoggerFactory |
|
64 |
.getLogger(JFileChooser.class); |
|
65 |
|
|
66 | 59 |
private class JFileFilter extends FileFilter { |
67 | 60 |
|
68 | 61 |
public JFileFilter(String[] extensions) { |
... | ... | |
201 | 194 |
} |
202 | 195 |
|
203 | 196 |
public void showDialog() { |
204 |
|
|
205 | 197 |
int returnVal = fc.showOpenDialog(panel); |
206 | 198 |
if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) { |
207 | 199 |
File file = fc.getSelectedFile(); |
208 |
try { |
|
209 |
component.setValue(file); |
|
210 |
} catch (DynFieldValidateException e1) { |
|
211 |
// TODO Auto-generated catch block |
|
212 |
LOG.warn("Value validation error: " |
|
213 |
+ component.getDynField().getName(), file); |
|
214 |
} |
|
200 |
component.setValue(file); |
|
215 | 201 |
} |
216 | 202 |
fc.setVisible(false); |
217 |
|
|
218 | 203 |
} |
219 | 204 |
|
220 | 205 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/DefaultJDynObjectComponent.java | ||
---|---|---|
47 | 47 |
import org.gvsig.tools.dataTypes.DataTypes; |
48 | 48 |
import org.gvsig.tools.dynobject.DynField; |
49 | 49 |
import org.gvsig.tools.dynobject.DynObject; |
50 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
51 | 50 |
import org.gvsig.tools.i18n.I18nManager; |
52 | 51 |
import org.gvsig.tools.service.ServiceException; |
53 | 52 |
import org.gvsig.tools.swing.api.dynobject.DynFieldModel; |
... | ... | |
284 | 283 |
} |
285 | 284 |
|
286 | 285 |
public void setFieldValue(Object value) { |
287 |
try { |
|
288 |
input.setFieldValue(value); |
|
289 |
} catch (DynFieldValidateException e) { |
|
290 |
// TODO Auto-generated catch block |
|
291 |
e.printStackTrace(); |
|
292 |
} |
|
286 |
input.setFieldValue(value); |
|
293 | 287 |
} |
294 | 288 |
|
295 | 289 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/DefaultDynObjectSwingManager.java | ||
---|---|---|
92 | 92 |
|
93 | 93 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
94 | 94 |
boolean writable) throws ServiceException { |
95 |
if (dynObject!=null){ |
|
96 |
return createJDynObjectComponent(dynObject, |
|
97 |
createDynObjectModel(dynObject.getDynClass()), writable); |
|
98 |
} |
|
99 |
return null; |
|
95 |
return createJDynObjectComponent(dynObject, |
|
96 |
createDynObjectModel(dynObject.getDynClass()), writable); |
|
100 | 97 |
} |
101 | 98 |
|
102 | 99 |
public JDynObjectComponent createJDynObjectComponent(DynObject dynObject, |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/dynfield/JNDynFieldComponent.java | ||
---|---|---|
51 | 51 |
import javax.swing.event.ListSelectionEvent; |
52 | 52 |
import javax.swing.event.ListSelectionListener; |
53 | 53 |
|
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
56 |
|
|
57 | 54 |
import org.gvsig.tools.dataTypes.DataTypes; |
58 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
59 | 55 |
import org.gvsig.tools.service.ServiceException; |
60 | 56 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
61 | 57 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
... | ... | |
69 | 65 |
public class JNDynFieldComponent extends DelegatedJFieldComponent implements |
70 | 66 |
JDynFieldComponent, ListSelectionListener, ValueChangedListener { |
71 | 67 |
|
72 |
private final static Logger LOG = LoggerFactory |
|
73 |
.getLogger(JNDynFieldComponent.class); |
|
74 |
|
|
75 | 68 |
private static final Object UNKNOWN = "unknown"; |
76 | 69 |
|
77 | 70 |
private JList list; |
... | ... | |
91 | 84 |
* @param dynObject |
92 | 85 |
* @param dynField |
93 | 86 |
*/ |
94 |
public JNDynFieldComponent(ValueField valueField) {
|
|
95 |
super(valueField, valueField.getDynField());
|
|
87 |
public JNDynFieldComponent(ValueField valueField) {
|
|
88 |
super(valueField, valueField.getDynField());
|
|
96 | 89 |
this.component.addValueChangedListener(this); |
97 | 90 |
} |
98 | 91 |
|
... | ... | |
344 | 337 |
} |
345 | 338 |
|
346 | 339 |
private void removeElement(int ind) { |
347 |
try { |
|
348 |
if ((ind >= 0) && (ind < this.getItems().getSize())) { |
|
349 |
removeItem(ind); |
|
350 |
} |
|
351 | 340 |
|
352 |
if (getItems().getSize() < 0) { |
|
353 |
this.sbutton.setEnabled(false); |
|
341 |
if ((ind >= 0) && (ind < this.getItems().getSize())) { |
|
342 |
removeItem(ind); |
|
343 |
} |
|
354 | 344 |
|
355 |
this.component.setValue(null);
|
|
356 |
|
|
357 |
} else {
|
|
358 |
if (ind > 0) {
|
|
359 |
this.list.setSelectedIndex(ind - 1);
|
|
360 |
}
|
|
345 |
if (getItems().getSize() < 0) {
|
|
346 |
this.sbutton.setEnabled(false); |
|
347 |
this.component.setValue(null);
|
|
348 |
} else {
|
|
349 |
if (ind > 0) {
|
|
350 |
this.list.setSelectedIndex(ind - 1);
|
|
361 | 351 |
} |
362 |
} catch (DynFieldValidateException e) { |
|
363 |
// TODO Auto-generated catch block |
|
364 |
e.printStackTrace(); |
|
365 | 352 |
} |
366 | 353 |
} |
367 | 354 |
|
... | ... | |
395 | 382 |
* @see org.gvsig.tools.swing.spi.DelegatedJFieldComponent#saveStatus() |
396 | 383 |
*/ |
397 | 384 |
public void saveStatus() { |
398 |
try { |
|
399 |
setFieldValue(getItems()); |
|
400 |
} catch (DynFieldValidateException e) { |
|
401 |
// TODO Auto-generated catch block |
|
402 |
e.printStackTrace(); |
|
403 |
} |
|
385 |
setFieldValue(getItems()); |
|
404 | 386 |
} |
405 | 387 |
|
406 | 388 |
/* |
... | ... | |
480 | 462 |
* .ListSelectionEvent) |
481 | 463 |
*/ |
482 | 464 |
public void valueChanged(ListSelectionEvent e) { |
483 |
try { |
|
484 |
NValueField items = getItems(); |
|
485 |
int index = list.getSelectedIndex(); |
|
486 |
int size = items.getSize(); |
|
487 |
if (index >= 0) { |
|
488 |
this.component.setValue(items.getElementAt(list |
|
489 |
.getSelectedIndex())); |
|
490 |
// this.list.setVisibleRowCount(model.getSize()); |
|
491 |
this.sbutton.setVisible(true); |
|
492 |
// this.listScrollPane.setVisible(true); |
|
465 |
NValueField items = getItems(); |
|
466 |
int index = list.getSelectedIndex(); |
|
467 |
int size = items.getSize(); |
|
468 |
if (index >= 0) { |
|
469 |
this.component |
|
470 |
.setValue(items.getElementAt(list.getSelectedIndex())); |
|
471 |
// this.list.setVisibleRowCount(model.getSize()); |
|
472 |
this.sbutton.setVisible(true); |
|
473 |
// this.listScrollPane.setVisible(true); |
|
474 |
} else { |
|
475 |
if (size < 1) { |
|
476 |
// this.sbutton.setVisible(false); |
|
477 |
// this.listScrollPane.setVisible(false); |
|
493 | 478 |
} else { |
494 |
if (size < 1) { |
|
495 |
// this.sbutton.setVisible(false); |
|
496 |
// this.listScrollPane.setVisible(false); |
|
497 |
} else { |
|
498 |
index = items.indexOf(items.firstElement()); |
|
499 |
if (index != this.list.getSelectedIndex()) { |
|
500 |
this.list.setSelectedIndex(index); |
|
501 |
} |
|
479 |
index = items.indexOf(items.firstElement()); |
|
480 |
if (index != this.list.getSelectedIndex()) { |
|
481 |
this.list.setSelectedIndex(index); |
|
502 | 482 |
} |
503 | 483 |
} |
504 |
refresh(); |
|
505 |
this.fireValueChangedEvent(); |
|
506 |
} catch (DynFieldValidateException exp) { |
|
507 |
// TODO Auto-generated catch block |
|
508 |
exp.printStackTrace(); |
|
509 | 484 |
} |
485 |
refresh(); |
|
486 |
this.fireValueChangedEvent(); |
|
510 | 487 |
} |
511 |
|
|
512 |
public void fireValueChangedEvent() { |
|
513 |
// TODO Auto-generated method stub |
|
514 |
|
|
515 |
} |
|
516 | 488 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/dynfield/JDynObjectDynFieldComponent.java | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import javax.swing.JComponent; |
41 | 41 |
|
42 |
import org.slf4j.Logger; |
|
43 |
import org.slf4j.LoggerFactory; |
|
44 |
|
|
45 | 42 |
import org.gvsig.tools.ToolsLocator; |
46 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
47 | 43 |
import org.gvsig.tools.dynobject.DynClass; |
48 | 44 |
import org.gvsig.tools.dynobject.DynField; |
49 | 45 |
import org.gvsig.tools.dynobject.DynObject; |
... | ... | |
60 | 56 |
public class JDynObjectDynFieldComponent implements JDynFieldComponent, |
61 | 57 |
ValueChangedListener { |
62 | 58 |
|
63 |
private final static Logger LOG = LoggerFactory |
|
64 |
.getLogger(JDynObjectDynFieldComponent.class); |
|
65 |
|
|
66 | 59 |
private JDynObjectComponent jDynObjectComponent; |
67 | 60 |
private DynObject dynObject; |
68 | 61 |
private DynField dynField; |
... | ... | |
73 | 66 |
private List<ValueChangedListener> listeners; |
74 | 67 |
|
75 | 68 |
/** |
76 |
* |
|
77 |
* @param dynObjectValueField
|
|
78 |
* @param writable
|
|
69 |
* @param dynField
|
|
70 |
* @param dynObject2
|
|
71 |
* @param dynObject
|
|
79 | 72 |
* @throws ServiceException |
80 | 73 |
*/ |
81 |
|
|
82 |
public JDynObjectDynFieldComponent(ValueField dynObjectValueField, |
|
83 |
boolean writable) throws ServiceException { |
|
74 |
public JDynObjectDynFieldComponent(ValueField dynObjectValueField, |
|
75 |
boolean writable) throws ServiceException { |
|
84 | 76 |
this.dynField = dynObjectValueField.getDynField(); |
85 | 77 |
this.dynValueField = dynObjectValueField; |
86 | 78 |
this.dynObject = (DynObject) dynValueField.getFieldValue(); |
... | ... | |
91 | 83 |
if (dynObject != null) |
92 | 84 |
this.dynClass = dynObject.getDynClass(); |
93 | 85 |
} |
94 |
LOG.info("Checking component " + getFieldName(true) + ";" + dynField.getName()); |
|
95 |
|
|
96 | 86 |
this.jDynObjectComponent = |
97 | 87 |
ToolsSwingLocator.getDynObjectSwingManager() |
98 |
.createJDynObjectComponent(getDynObject(), writable);
|
|
88 |
.createJDynObjectComponent(getDynObject(), writable);
|
|
99 | 89 |
// this.dynObject = createDynObject(dynObjectValue.getValue()); |
100 | 90 |
|
101 | 91 |
// this.jDynObjectComponent.handleValueChanged(this); |
... | ... | |
120 | 110 |
* @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent# |
121 | 111 |
* fireValueChangedEvent() |
122 | 112 |
*/ |
123 |
public void fireValueChangedEvent(){ |
|
113 |
public void fireValueChangedEvent() {
|
|
124 | 114 |
for (ValueChangedListener listener : this.listeners) |
125 | 115 |
listener.handleValueChanged(this); |
126 | 116 |
} |
... | ... | |
128 | 118 |
public DynObject getDynObject() { |
129 | 119 |
if (this.dynObject != null) |
130 | 120 |
return this.dynObject; |
131 |
try { |
|
132 |
createDynObject(this.getInitialValue()); |
|
133 |
} catch (DynFieldValidateException e) { |
|
134 |
LOG.warn("Initial value validation error: " + this.getDynField().getName(), this.getInitialValue()); |
|
135 |
} |
|
121 |
createDynObject(this.getInitialValue()); |
|
136 | 122 |
return this.dynObject; |
137 | 123 |
} |
138 | 124 |
|
139 | 125 |
/** |
140 |
* @throws DynFieldValidateException |
|
141 | 126 |
* |
142 | 127 |
*/ |
143 |
private DynObject createDynObject(Object value) throws DynFieldValidateException {
|
|
128 |
private DynObject createDynObject(Object value) { |
|
144 | 129 |
if (this.dynClass == null) |
145 | 130 |
return null; |
146 | 131 |
this.dynObject = manager.createDynObject(this.dynClass); |
... | ... | |
158 | 143 |
String name = ""; |
159 | 144 |
String suffix = "-list-List-item"; |
160 | 145 |
|
161 |
if (this.dynField.getType() == DataTypes.DYNOBJECT) { |
|
162 |
name = this.dynField.getSubtype(); |
|
163 |
if (name == null) { |
|
164 |
DynField fieldType = this.dynField.getElementsType(); |
|
165 |
if (fieldType != null){ |
|
166 |
name = this.dynField.getElementsType().getName(); |
|
167 |
} |
|
168 |
} |
|
169 |
if (name == null) { |
|
170 |
name = this.dynField.getName(); |
|
171 |
} |
|
172 |
if (name != null) { |
|
173 |
return name; |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 | 146 |
if (this.dynField.isContainer()) |
178 | 147 |
name = this.dynField.getElementsType().getName(); |
179 | 148 |
else |
... | ... | |
312 | 281 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#saveStatus |
313 | 282 |
* () |
314 | 283 |
*/ |
315 |
public void saveStatus() throws DynFieldValidateException {
|
|
284 |
public void saveStatus() { |
|
316 | 285 |
this.jDynObjectComponent.saveStatus(); |
317 | 286 |
} |
318 | 287 |
|
... | ... | |
334 | 303 |
* org.gvsig.tools.swing.spi.DelegatedJFieldComponent#setFieldValue(java |
335 | 304 |
* .lang.Object) |
336 | 305 |
*/ |
337 |
public void setFieldValue(Object value) throws DynFieldValidateException {
|
|
306 |
public void setFieldValue(Object value) { |
|
338 | 307 |
if (value != null) { |
339 |
if (value instanceof DynObject){ |
|
340 |
this.dynObject = (DynObject) value; |
|
341 |
}else{ |
|
342 |
throw new DynFieldValidateException(value, dynField); |
|
343 |
} |
|
308 |
this.dynObject = (DynObject) value; |
|
344 | 309 |
} |
345 | 310 |
} |
346 | 311 |
|
... | ... | |
351 | 316 |
* org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java |
352 | 317 |
* .lang.Object) |
353 | 318 |
*/ |
354 |
public void setValue(Object value) throws DynFieldValidateException {
|
|
319 |
public void setValue(Object value) { |
|
355 | 320 |
Object dynValue = null; |
356 | 321 |
if (value instanceof DynObject) { |
357 | 322 |
boolean validated = true; |
... | ... | |
360 | 325 |
.getDeclaredDynFields()) { |
361 | 326 |
dynValue = dynObj.getDynValue(field.getName()); |
362 | 327 |
if (value != null) { |
363 |
field.validate(dynValue); |
|
364 |
dynObj.setDynValue(field.getName(), dynValue); |
|
328 |
try { |
|
329 |
field.validate(dynValue); |
|
330 |
dynObj.setDynValue(field.getName(), dynValue); |
|
331 |
|
|
332 |
} catch (DynFieldValidateException e) { |
|
333 |
e.printStackTrace(); |
|
334 |
validated = false; |
|
335 |
} |
|
365 | 336 |
} |
366 | 337 |
} |
367 | 338 |
if (validated) { |
... | ... | |
372 | 343 |
JDynFieldComponent field = (JDynFieldComponent) value; |
373 | 344 |
String name = field.getDynField().getName(); |
374 | 345 |
if (this.dynClass.getDynField(name) != null) { |
375 |
dynValue = field.getValue(); |
|
376 |
field.getDynField().validate(dynValue); |
|
377 |
this.dynObject.setDynValue(name, dynValue); |
|
346 |
try { |
|
347 |
dynValue = field.getValue(); |
|
348 |
field.getDynField().validate(dynValue); |
|
349 |
this.dynObject.setDynValue(name, dynValue); |
|
350 |
} catch (DynFieldValidateException e) { |
|
351 |
e.printStackTrace(); |
|
352 |
} |
|
353 |
|
|
378 | 354 |
} |
379 | 355 |
} else { |
380 | 356 |
this.jDynObjectComponent.setValue(null); |
... | ... | |
399 | 375 |
* org.gvsig.tools.swing.api.dynobject.ValueChangedListener#handleValueChanged |
400 | 376 |
* (org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent) |
401 | 377 |
*/ |
402 |
public void handleValueChanged(JDynFieldComponent field){ |
|
403 |
try { |
|
404 |
setValue(field); |
|
405 |
} catch (DynFieldValidateException e) { |
|
406 |
// TODO Auto-generated catch block |
|
407 |
e.printStackTrace(); |
|
408 |
} |
|
378 |
public void handleValueChanged(JDynFieldComponent field) { |
|
379 |
setValue(field); |
|
409 | 380 |
} |
410 | 381 |
|
411 | 382 |
public Object getDefaultFieldValue() { |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/dynfield/DelegatedJFieldComponent.java | ||
---|---|---|
34 | 34 |
package org.gvsig.tools.swing.impl.dynobject.dynfield; |
35 | 35 |
|
36 | 36 |
import org.gvsig.tools.dynobject.DynField; |
37 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
38 | 37 |
import org.gvsig.tools.service.Manager; |
39 | 38 |
import org.gvsig.tools.service.ServiceException; |
40 | 39 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
... | ... | |
179 | 178 |
component.addValueChangedListener(listener); |
180 | 179 |
} |
181 | 180 |
|
182 |
// /*
|
|
183 |
// * (non-Javadoc)
|
|
184 |
// *
|
|
185 |
// * @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#
|
|
186 |
// * raiseValueChangedEvent()
|
|
187 |
// */
|
|
188 |
// public void fireValueChangedEvent() throws DynFieldValidateException {
|
|
189 |
// // TODO: this creates an infinite loop, check what is happening
|
|
190 |
// // component.fireValueChangedEvent();
|
|
191 |
// }
|
|
181 |
/* |
|
182 |
* (non-Javadoc) |
|
183 |
* |
|
184 |
* @seeorg.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent# |
|
185 |
* raiseValueChangedEvent() |
|
186 |
*/ |
|
187 |
public void fireValueChangedEvent() {
|
|
188 |
// TODO: this creates an infinite loop, check what is happening |
|
189 |
// component.fireValueChangedEvent(); |
|
190 |
} |
|
192 | 191 |
|
193 | 192 |
/* |
194 | 193 |
* (non-Javadoc) |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/dynfield/AbstractNDynObjectValueField.java | ||
---|---|---|
36 | 36 |
import javax.swing.event.ListDataListener; |
37 | 37 |
|
38 | 38 |
import org.gvsig.tools.dynobject.DynField; |
39 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
40 | 39 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
41 | 40 |
import org.gvsig.tools.swing.impl.dynobject.valuefield.DynFieldFormatter; |
42 | 41 |
import org.gvsig.tools.swing.impl.dynobject.valuefield.NValueField; |
... | ... | |
201 | 200 |
this.model.removeListDataListener(l); |
202 | 201 |
} |
203 | 202 |
|
204 |
public void setFieldValue(Object value) throws DynFieldValidateException {
|
|
203 |
public void setFieldValue(Object value) { |
|
205 | 204 |
parent.setFieldValue(value); |
206 | 205 |
} |
207 | 206 |
|
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dynobject/dynfield/JComboBoxDynFieldComponent.java | ||
---|---|---|
41 | 41 |
import javax.swing.JComboBox; |
42 | 42 |
import javax.swing.JComponent; |
43 | 43 |
|
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 | 44 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
48 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
|
49 | 45 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
50 | 46 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
51 | 47 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
... | ... | |
64 | 60 |
public class JComboBoxDynFieldComponent extends DelegatedJFieldComponent |
65 | 61 |
implements JDynFieldComponent, ItemListener { |
66 | 62 |
|
67 |
private final static Logger LOG = LoggerFactory |
|
68 |
.getLogger(JComboBoxDynFieldComponent.class); |
|
69 |
|
|
70 | 63 |
private JComboBox combo; |
71 | 64 |
|
72 | 65 |
private DynObjectValueItem[] items; |
... | ... | |
82 | 75 |
* the ValueField object. |
83 | 76 |
*/ |
84 | 77 |
public JComboBoxDynFieldComponent(JDynFieldComponent component, |
85 |
ValueField valueField) {
|
|
86 |
super(component, valueField);
|
|
78 |
ValueField valueField) {
|
|
79 |
super(component, valueField);
|
|
87 | 80 |
} |
88 | 81 |
|
89 | 82 |
/* |
... | ... | |
136 | 129 |
* org.gvsig.tools.swing.spi.DelegatedJFieldComponent#fireValueChangedEvent |
137 | 130 |
* () |
138 | 131 |
*/ |
132 |
@Override |
|
139 | 133 |
public void fireValueChangedEvent() { |
140 | 134 |
for (ValueChangedListener listener : this.listeners) { |
141 | 135 |
listener.handleValueChanged(this); |
... | ... | |
226 | 220 |
* |
227 | 221 |
* @see org.gvsig.tools.swing.spi.DelegatedJFieldComponent#saveStatus() |
228 | 222 |
*/ |
229 |
public void saveStatus() throws DynFieldValidateException {
|
|
223 |
public void saveStatus() { |
|
230 | 224 |
this.setFieldValue(this.getValue()); |
231 | 225 |
} |
232 | 226 |
|
... | ... | |
259 | 253 |
* (java.lang.Object) |
260 | 254 |
*/ |
261 | 255 |
@Override |
262 |
public void setFieldValue(Object value) throws DynFieldValidateException {
|
|
256 |
public void setFieldValue(Object value) { |
|
263 | 257 |
this.component.setFieldValue(value); |
264 | 258 |
} |
265 | 259 |
|
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTaskStatus.java | ||
---|---|---|
32 | 32 |
private JLabel messagelabel = null; |
33 | 33 |
private JProgressBar progressBar = null; |
34 | 34 |
private JButton cancelRequestButton = null; |
35 |
private JButton removeTaskButton; |
|
36 |
|
|
35 | 37 |
private boolean showCancelButton; |
38 |
private boolean showRemoveTaskButton; |
|
36 | 39 |
|
37 | 40 |
private TaskStatus taskStatus; |
38 | 41 |
|
39 |
private JButton removeTaskButton; |
|
40 | 42 |
|
41 | 43 |
public DefaultJTaskStatus() { |
42 | 44 |
this.taskStatus = null; |
... | ... | |
60 | 62 |
} |
61 | 63 |
} |
62 | 64 |
|
65 |
public boolean getShowRemoveTaskButton() { |
|
66 |
return this.showRemoveTaskButton; |
|
67 |
} |
|
68 |
|
|
69 |
public void setShowRemoveTaskButton(boolean showRemoveTaskButton) { |
|
70 |
this.showRemoveTaskButton = showRemoveTaskButton; |
|
71 |
if( this.removeTaskButton != null ) { |
|
72 |
this.removeTaskButton.setVisible(this.showRemoveTaskButton); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
63 | 76 |
public JComponent asJComponent() { |
64 | 77 |
return this; |
65 | 78 |
} |
... | ... | |
158 | 171 |
TaskStatus taskStatus = (TaskStatus) observable; |
159 | 172 |
if( taskStatus == null || !taskStatus.isRunning() ) { |
160 | 173 |
this.messagelabel.setText(""); |
174 |
this.progressBar.setIndeterminate(false); |
|
161 | 175 |
this.progressBar.setValue(100); |
162 | 176 |
this.cancelRequestButton.setEnabled(false); |
163 | 177 |
this.removeTaskButton.setEnabled(true); |
Also available in: Unified diff