Statistics
| Revision:

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 @ 1118

History | View | Annotate | Download (3.61 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
                this.setSubtype(definition.getSubtype());
56
                
57
                this.setAvailableValues(definition.getAvailableValues());
58
                
59
                this.manager = manager;
60
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); 
61
                this.label = (String) dynManager.getAttributeValue(definition, "label");
62
                if(definition instanceof DynField_v2){
63
                        this.setClassOfValue(((DynField_v2)definition).getDynClassOfValue());
64
                        this.setClassOfValue(((DynField_v2)definition).getClassOfValue());
65
                        if( definition.isContainer() ) {
66
                            this.setClassOfItems(((DynField_v2)definition).getDynClassOfItems());
67
                            this.setClassOfItems(((DynField_v2)definition).getClassOfItems());
68
                            this.setTypeOfItems(((DynField_v2)definition).getTypeOfItems());
69
                        }
70
                        this.getTags().add(((DynField_v2)definition).getTags());
71

    
72
                }else{
73
                        this.setSubtype(definition.getSubtype());
74
                }
75
        }
76

    
77
        public Manager getManager() {
78
                return this.manager;
79
        }
80

    
81
        public String getLabel() {
82
                return this.label;
83
        }
84

    
85
        public DynField setLabel(String label) {
86
                this.label = label;
87
                return this;
88
        }
89
        
90
        public String getGroup() {
91
                if( this.groups==null ) {
92
                        return null;
93
                }
94
                String parts[] = this.groups.split("/");
95
                return parts[0];
96
        }
97

    
98
        public String getSubgroup() {
99
                String parts[] = this.groups.split("/");
100
                if( parts.length<=1 ) {
101
                        return null;
102
                }
103
                return parts[1];
104
        }
105

    
106
        public String getGroups() {
107
                return this.groups;
108
        }
109

    
110
        public void setGroups(String groups) {
111
                this.groups = groups;
112
        }
113
}