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 | 954 | jbadia | /**
|
---|---|---|---|
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 | 919 | jjdelcerro | package org.gvsig.tools.dynform.impl; |
25 | |||
26 | 1031 | jbadia | import java.util.Iterator; |
27 | |||
28 | 919 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
29 | 933 | jjdelcerro | import org.gvsig.tools.dynform.DynFormFieldDefinition; |
30 | 919 | jjdelcerro | import org.gvsig.tools.dynobject.DynField; |
31 | 1031 | jbadia | import org.gvsig.tools.dynobject.DynField_v2; |
32 | 919 | jjdelcerro | 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 | 1031 | jbadia | |
56 | 919 | jjdelcerro | this.setAvailableValues(definition.getAvailableValues());
|
57 | |||
58 | this.manager = manager;
|
||
59 | DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
||
60 | 1031 | jbadia | 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 | 919 | jjdelcerro | } |
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 | 930 | jjdelcerro | if( this.groups==null ) { |
93 | return null; |
||
94 | } |
||
95 | 919 | jjdelcerro | 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 | } |