Revision 1405 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/AbstractJDynForm.java
AbstractJDynForm.java | ||
---|---|---|
21 | 21 |
import javax.swing.JPanel; |
22 | 22 |
import javax.swing.JScrollPane; |
23 | 23 |
import javax.swing.JViewport; |
24 |
import org.apache.commons.lang3.StringUtils; |
|
24 | 25 |
import org.gvsig.tools.dataTypes.CoercionException; |
25 | 26 |
import org.gvsig.tools.dataTypes.DataType; |
26 | 27 |
import org.gvsig.tools.dynform.DynFormDefinition; |
27 | 28 |
import org.gvsig.tools.dynform.DynFormManager; |
28 | 29 |
import org.gvsig.tools.dynform.JDynForm; |
29 | 30 |
import org.gvsig.tools.dynform.JDynFormField; |
31 |
import org.gvsig.tools.dynform.JDynFormSet; |
|
30 | 32 |
import org.gvsig.tools.dynobject.DynObject; |
33 |
import org.gvsig.tools.dynobject.Tags; |
|
31 | 34 |
import org.gvsig.tools.service.ServiceException; |
32 | 35 |
import org.slf4j.Logger; |
33 | 36 |
import org.slf4j.LoggerFactory; |
... | ... | |
56 | 59 |
this.definition = definition; |
57 | 60 |
this.listeners = new HashSet(); |
58 | 61 |
this.customActions = new HashMap(); |
59 |
if (definition.getTags().has("LayoutMode")) { |
|
60 |
try { |
|
61 |
this.layoutMode = definition.getTags().getInt("LayoutMode"); |
|
62 |
} catch (CoercionException e) { |
|
63 |
// Ignorada |
|
62 |
this.loadDefaultValuesFromTags(definition.getTags()); |
|
63 |
} |
|
64 |
|
|
65 |
public static int getLayoutFromTags(Tags tags) { |
|
66 |
String layoutMode = (String) tags.get(DynFormSPIManager.TAG_DYNFORM_LAYOUTMODE); |
|
67 |
if( !StringUtils.isEmpty(layoutMode) ) { |
|
68 |
if( layoutMode.equalsIgnoreCase("0") || |
|
69 |
layoutMode.equalsIgnoreCase(DynFormSPIManager.TAG_DYNFORM_LAYOUTMODE_VALUE_PLAIN) ) { |
|
70 |
return JDynFormSet.USE_PLAIN; |
|
71 |
} else if( layoutMode.equalsIgnoreCase("1") || |
|
72 |
layoutMode.equalsIgnoreCase(DynFormSPIManager.TAG_DYNFORM_LAYOUTMODE_VALUE_TABS) ) { |
|
73 |
return JDynFormSet.USE_TABS; |
|
74 |
} else if( layoutMode.equalsIgnoreCase("2") || |
|
75 |
layoutMode.equalsIgnoreCase(DynFormSPIManager.TAG_DYNFORM_LAYOUTMODE_VALUE_SEPARATORS) ) { |
|
76 |
return JDynFormSet.USE_SEPARATORS; |
|
64 | 77 |
} |
65 | 78 |
} |
79 |
return JDynFormSet.USE_PLAIN; |
|
66 | 80 |
} |
81 |
|
|
82 |
public void loadDefaultValuesFromTags(Tags tags) { |
|
83 |
this.setLayoutMode(getLayoutFromTags(tags)); |
|
84 |
|
|
85 |
try { |
|
86 |
this.formWidth = tags.getInt(DynFormSPIManager.TAG_DYNFORM_WIDTH); |
|
87 |
} catch (CoercionException ex) { |
|
88 |
} |
|
89 |
try { |
|
90 |
this.formHeight = tags.getInt(DynFormSPIManager.TAG_DYNFORM_HEIGHT); |
|
91 |
} catch (CoercionException ex) { |
|
92 |
} |
|
93 |
try { |
|
94 |
this.border = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_BORDER); |
|
95 |
} catch (CoercionException ex) { |
|
96 |
} |
|
97 |
try { |
|
98 |
this.useScrollBars = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_USESCROLLBARS); |
|
99 |
} catch (CoercionException ex) { |
|
100 |
} |
|
101 |
try { |
|
102 |
this.readOnly = tags.getBoolean(DynFormSPIManager.TAG_DYNFORM_READONLY); |
|
103 |
} catch (CoercionException ex) { |
|
104 |
} |
|
105 |
} |
|
67 | 106 |
|
68 |
|
|
69 | 107 |
public DynFormSPIManager getServiceManager() { |
70 | 108 |
if ( serviceManager == null ) { |
71 | 109 |
serviceManager = DynFormSPILocator.getDynFormSPIManager(); |
Also available in: Unified diff