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

History | View | Annotate | Download (3.52 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 org.gvsig.tools.ToolsLocator;
27
import org.gvsig.tools.dynform.DynFormFieldDefinition;
28
import org.gvsig.tools.dynobject.DynField;
29
import org.gvsig.tools.dynobject.DynField_v2;
30
import org.gvsig.tools.dynobject.DynObjectManager;
31
import org.gvsig.tools.dynobject.impl.DefaultDynField;
32
import org.gvsig.tools.service.Manager;
33

    
34
public class DefaultDynFormFieldDefinition extends DefaultDynField implements DynFormFieldDefinition {
35

    
36
        private DefaultDynFormManager manager = null;
37
        private String label = null;
38
        private String groups = null;
39

    
40
        public DefaultDynFormFieldDefinition(DefaultDynFormManager manager, DynField definition) {
41
                super(definition.getName(),
42
                        definition.getType(),
43
                        definition.getDefaultValue(),
44
                        definition.isPersistent(),
45
                        definition.isMandatory());
46
                this.setHidden(definition.isHidden());
47
                this.setReadOnly(definition.isReadOnly());
48
                this.setGroups(definition.getGroup());
49
                this.setDescription(definition.getDescription());
50
                this.setMaxValue(definition.getMaxValue());
51
                this.setMinValue(definition.getMinValue());
52
                this.setOrder(definition.getOder());
53
                this.setSubtype(definition.getSubtype());
54

    
55
                this.setAvailableValues(definition.getAvailableValues());
56

    
57
                this.manager = manager;
58
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
59
                this.label = (String) dynManager.getAttributeValue(definition, "label");
60
                if(definition instanceof DynField_v2){
61
                        this.setClassOfValue(((DynField_v2)definition).getDynClassOfValue());
62
                        this.setClassOfValue(((DynField_v2)definition).getClassOfValue());
63
                        if( definition.isContainer() ) {
64
                            this.setClassOfItems(((DynField_v2)definition).getDynClassOfItems());
65
                            this.setClassOfItems(((DynField_v2)definition).getClassOfItems());
66
                            this.setTypeOfItems(((DynField_v2)definition).getTypeOfItems());
67
                        }
68
                        this.getTags().add(((DynField_v2)definition).getTags());
69

    
70
                }else{
71
                        this.setSubtype(definition.getSubtype());
72
                }
73
        }
74

    
75
        public String getLabel() {
76
                return this.label;
77
        }
78

    
79
        public DynField setLabel(String label) {
80
                this.label = label;
81
                return this;
82
        }
83

    
84
        public String getGroup() {
85
                if( this.groups==null ) {
86
                        return null;
87
                }
88
                String parts[] = this.groups.split("/");
89
                return parts[0];
90
        }
91

    
92
        public String getSubgroup() {
93
                String parts[] = this.groups.split("/");
94
                if( parts.length<=1 ) {
95
                        return null;
96
                }
97
                return parts[1];
98
        }
99

    
100
        public String getGroups() {
101
                return this.groups;
102
        }
103

    
104
        public void setGroups(String groups) {
105
                this.groups = groups;
106
        }
107
}