Revision 46876 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretype/tags/TagController.java
TagController.java | ||
---|---|---|
8 | 8 |
import javax.swing.JComboBox; |
9 | 9 |
import javax.swing.JLabel; |
10 | 10 |
import org.apache.commons.lang3.StringUtils; |
11 |
import org.gvsig.fmap.dal.swing.impl.featuretype.AggregateController; |
|
11 | 12 |
import org.gvsig.fmap.dal.swing.impl.featuretype.AggregateController.AggregateItemController; |
12 | 13 |
import org.gvsig.tools.ToolsLocator; |
13 | 14 |
import org.gvsig.tools.dynobject.DynField; |
15 |
import org.gvsig.tools.dynobject.DynField_v2; |
|
16 |
import org.gvsig.tools.dynobject.DynMethod; |
|
14 | 17 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
15 | 18 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
16 | 19 |
import org.gvsig.tools.util.LabeledValue; |
... | ... | |
20 | 23 |
* |
21 | 24 |
* @author gvSIG Team |
22 | 25 |
*/ |
26 |
@SuppressWarnings("UseSpecificCatch") |
|
23 | 27 |
public class TagController implements AggregateItemController<Tag> { |
24 | 28 |
|
25 | 29 |
private final JComboBox cboName; |
26 | 30 |
private final JComboBox cboValue; |
27 | 31 |
private final JLabel lblDescription; |
28 | 32 |
private final UnmodifiableBasicMap<String, DynField> tagDefinitions; |
33 |
private TagsModel tagsModel; |
|
29 | 34 |
|
30 | 35 |
public TagController( |
31 | 36 |
JComboBox cboName, |
... | ... | |
74 | 79 |
if( tagname.equalsIgnoreCase(tagDefinition.getName()) ) { |
75 | 80 |
this.lblDescription.setText("<html>"+tagDefinition.getDescription()+"<html>"); |
76 | 81 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
77 |
LabeledValue[] values = tagDefinition.getAvailableValues(); |
|
82 |
LabeledValue[] values; |
|
83 |
if( tagDefinition instanceof DynField_v2 ) { |
|
84 |
DynMethod method = ((DynField_v2)tagDefinition).getAvailableValuesMethod(); |
|
85 |
try { |
|
86 |
values = (LabeledValue[]) method.invoke(null, new Object[] { this.tagsModel.getTags() }); |
|
87 |
} catch(Throwable t) { |
|
88 |
values = null; |
|
89 |
} |
|
90 |
if( values == null ) { |
|
91 |
values = tagDefinition.getAvailableValues(); |
|
92 |
} |
|
93 |
} else { |
|
94 |
values = tagDefinition.getAvailableValues(); |
|
95 |
} |
|
96 |
|
|
78 | 97 |
if( values != null ) { |
79 | 98 |
for (LabeledValue value : values) { |
80 | 99 |
model.addElement(value); |
... | ... | |
127 | 146 |
public boolean isEnabled() { |
128 | 147 |
return this.cboName.isEnabled(); |
129 | 148 |
} |
149 |
|
|
150 |
@Override |
|
151 |
public void setAggregateModel(AggregateController.AggregateModel model) { |
|
152 |
this.tagsModel = (TagsModel) model; |
|
153 |
} |
|
130 | 154 |
|
131 | 155 |
} |
Also available in: Unified diff