Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / dynobject / AbstractDynObjectModelElement.java @ 586

History | View | Annotate | Download (4.08 KB)

1 168 cmartin
/* gvSIG. Geographic Information System of the Valencian Government
2 270 cmartin
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22 168 cmartin
/*
23
 * AUTHORS (In addition to CIT):
24
 * 2010 Institute of New Imaging Technologies (INIT):
25
 *   http://www.init.uji.es
26
 * Geographic Information research group:
27
 *   http://www.geoinfo.uji.es
28
 * Universitat Jaume I, Spain
29
 */
30
31
/**
32
 *
33
 */
34
package org.gvsig.tools.swing.impl.dynobject;
35 270 cmartin
36 168 cmartin
import org.gvsig.tools.dynobject.DynField;
37 534 cmartin
import org.gvsig.tools.dynobject.DynStruct;
38 273 cmartin
import org.gvsig.tools.swing.api.dynobject.DynFieldModel;
39 168 cmartin
40
/**
41 270 cmartin
 *
42 281 cmartin
 * Abstract DynObjectModel element.
43
 *
44
 * @author 2010 - <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG Team
45 298 cmartin
 * @author 2010 - <a href="mailto:reinhold@uji.es">Cristian Mart?n&nbsp;</a> -
46
 *         gvSIG Team
47 281 cmartin
 * @version $Id$
48 298 cmartin
 *
49 168 cmartin
 */
50 298 cmartin
public abstract class AbstractDynObjectModelElement implements DynFieldModel {
51 270 cmartin
52 534 cmartin
    private DynStruct definition;
53 168 cmartin
    private String fieldName;
54
55
    private boolean isReadOnly;
56 270 cmartin
    private String group;
57
58 281 cmartin
    /**
59
     * Constructor.
60
     *
61
     * @param fieldName
62 298 cmartin
     *            the current field name.
63 534 cmartin
     * @param definition
64 298 cmartin
     *            the current DynClass.
65 281 cmartin
     * @param group
66 298 cmartin
     *            the current group name.
67 281 cmartin
     */
68 534 cmartin
    public AbstractDynObjectModelElement(String fieldName, DynStruct definition,
69 270 cmartin
        String group) {
70 534 cmartin
        this.definition = definition;
71 270 cmartin
        this.fieldName = fieldName;
72
        this.isReadOnly = false;
73
        this.group = group;
74 168 cmartin
    }
75 270 cmartin
76 281 cmartin
    /**
77
     * Compares an element to the current DynObjectModel and determines
78 298 cmartin
     * if it is equal or not.
79
     *
80 281 cmartin
     */
81 298 cmartin
    @Override
82 270 cmartin
    public boolean equals(Object elem) {
83 298 cmartin
        if (!(elem instanceof DynFieldModel)) {
84 270 cmartin
            return false;
85 298 cmartin
        }
86 273 cmartin
        DynFieldModel fieldElem = (DynFieldModel) elem;
87 298 cmartin
        if (this.getDynField().equals(fieldElem.getDynField())) {
88 270 cmartin
            return true;
89 298 cmartin
        }
90 270 cmartin
        return false;
91 168 cmartin
    }
92 270 cmartin
93
    /*
94
     * (non-Javadoc)
95
     *
96
     * @see
97 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#getDynClass()
98 168 cmartin
     */
99 534 cmartin
    public DynStruct getDefinition() {
100
        return this.definition;
101 168 cmartin
    }
102
103 270 cmartin
    /*
104
     * (non-Javadoc)
105
     *
106
     * @see
107 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#getDynField()
108 168 cmartin
     */
109
    public DynField getDynField() {
110 534 cmartin
        return this.definition.getDynField(this.fieldName);
111 168 cmartin
    }
112
113 270 cmartin
    /*
114
     * (non-Javadoc)
115
     *
116
     * @see
117 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#getGroup()
118 168 cmartin
     */
119
    public String getGroup() {
120 270 cmartin
        return this.group;
121 168 cmartin
    }
122
123 270 cmartin
    /*
124
     * (non-Javadoc)
125
     *
126
     * @see
127 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#isReadOnly()
128 168 cmartin
     */
129
    public boolean isReadOnly() {
130 270 cmartin
        return isReadOnly;
131 168 cmartin
    }
132
133 270 cmartin
    /*
134
     * (non-Javadoc)
135
     *
136
     * @see
137 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#setGroup(java
138 270 cmartin
     * .lang.String)
139 168 cmartin
     */
140
    public void setGroup(String group) {
141 270 cmartin
        this.group = group;
142 168 cmartin
    }
143
144 270 cmartin
    /*
145
     * (non-Javadoc)
146
     *
147
     * @see
148 273 cmartin
     * org.gvsig.tools.swing.api.dynobject.DynFieldModel#setReadOnly
149 270 cmartin
     * (boolean)
150 168 cmartin
     */
151
    public void setReadOnly(boolean isReadOnly) {
152 270 cmartin
        this.isReadOnly = isReadOnly;
153 168 cmartin
    }
154
}