gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.dynform / org.gvsig.tools.dynform.impl / src / main / java / org / gvsig / tools / dynform / impl / DefaultDynFormFieldDefinition.java @ 1031
History | View | Annotate | Download (3.41 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.tools.dynform.impl; |
25 |
|
26 |
import java.util.Iterator; |
27 |
|
28 |
import org.gvsig.tools.ToolsLocator; |
29 |
import org.gvsig.tools.dynform.DynFormFieldDefinition; |
30 |
import org.gvsig.tools.dynobject.DynField; |
31 |
import org.gvsig.tools.dynobject.DynField_v2; |
32 |
import org.gvsig.tools.dynobject.DynObjectManager; |
33 |
import org.gvsig.tools.dynobject.impl.DefaultDynField; |
34 |
import org.gvsig.tools.service.Manager; |
35 |
|
36 |
public class DefaultDynFormFieldDefinition extends DefaultDynField implements DynFormFieldDefinition { |
37 |
|
38 |
private DefaultDynFormManager manager = null; |
39 |
private String label = null; |
40 |
private String groups = null; |
41 |
|
42 |
public DefaultDynFormFieldDefinition(DefaultDynFormManager manager, DynField definition) {
|
43 |
super(definition.getName(),
|
44 |
definition.getType(), |
45 |
definition.getDefaultValue(), |
46 |
definition.isPersistent(), |
47 |
definition.isMandatory()); |
48 |
this.setHidden(definition.isHidden());
|
49 |
this.setReadOnly(definition.isReadOnly());
|
50 |
this.setGroups(definition.getGroup());
|
51 |
this.setDescription(definition.getDescription());
|
52 |
this.setMaxValue(definition.getMaxValue());
|
53 |
this.setMinValue(definition.getMinValue());
|
54 |
this.setOrder(definition.getOder());
|
55 |
|
56 |
this.setAvailableValues(definition.getAvailableValues());
|
57 |
|
58 |
this.manager = manager;
|
59 |
DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
60 |
this.label = (String) dynManager.getAttributeValue(definition, "label"); |
61 |
if(definition instanceof DynField_v2){ |
62 |
this.setStructWhenTypeIsDynObject(((DynField_v2)definition).getStructWhenTypeIsDynObject());
|
63 |
Iterator it = ((DynField_v2)definition).getTagKeys();
|
64 |
if(it != null){ |
65 |
while(it.hasNext()){
|
66 |
String key = (String) it.next(); |
67 |
this.setTag(key, ((DynField_v2)definition).getTag(key));
|
68 |
} |
69 |
} |
70 |
if(((DynField_v2)definition).getStructWhenTypeIsDynObject() == null){ |
71 |
this.setSubtype(definition.getSubtype());
|
72 |
} |
73 |
}else{
|
74 |
this.setSubtype(definition.getSubtype());
|
75 |
} |
76 |
} |
77 |
|
78 |
public Manager getManager() {
|
79 |
return this.manager; |
80 |
} |
81 |
|
82 |
public String getLabel() { |
83 |
return this.label; |
84 |
} |
85 |
|
86 |
public DynField setLabel(String label) { |
87 |
this.label = label;
|
88 |
return this; |
89 |
} |
90 |
|
91 |
public String getGroup() { |
92 |
if( this.groups==null ) { |
93 |
return null; |
94 |
} |
95 |
String parts[] = this.groups.split("/"); |
96 |
return parts[0]; |
97 |
} |
98 |
|
99 |
public String getSubgroup() { |
100 |
String parts[] = this.groups.split("/"); |
101 |
if( parts.length<=1 ) { |
102 |
return null; |
103 |
} |
104 |
return parts[1]; |
105 |
} |
106 |
|
107 |
public String getGroups() { |
108 |
return this.groups; |
109 |
} |
110 |
|
111 |
public void setGroups(String groups) { |
112 |
this.groups = groups;
|
113 |
} |
114 |
} |