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 / dynfield / JDynObjectDynFieldComponent.java @ 168
History | View | Annotate | Download (5.87 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
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 |
/*
|
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.dynfield; |
35 |
|
36 |
|
37 |
import java.awt.Component; |
38 |
|
39 |
import org.gvsig.tools.dynobject.DynField; |
40 |
import org.gvsig.tools.dynobject.DynObject; |
41 |
import org.gvsig.tools.service.Manager; |
42 |
import org.gvsig.tools.service.ServiceException; |
43 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
44 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
45 |
import org.gvsig.tools.swing.api.dynobject.ValueChangedListener; |
46 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
47 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
48 |
|
49 |
/**
|
50 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a>
|
51 |
*
|
52 |
*/
|
53 |
public class JDynObjectDynFieldComponent implements JDynFieldComponent{ |
54 |
|
55 |
private JDynObjectComponent jDynObjectComponent;
|
56 |
private DynObject dynObject;
|
57 |
private DynField dynField;
|
58 |
private Component component; |
59 |
|
60 |
/**
|
61 |
* @param dynField
|
62 |
* @param dynObject
|
63 |
* @throws ServiceException
|
64 |
*/
|
65 |
public JDynObjectDynFieldComponent(DynField dynField, ValueField dynObjectValue) throws ServiceException { |
66 |
this.dynField = dynField;
|
67 |
this.dynObject = (DynObject) dynObjectValue.getValue();
|
68 |
this.jDynObjectComponent = ToolsSwingLocator.getDynObjectSwingManager().createJDynObjectComponent(getDynObjectValue());
|
69 |
this.component = (Component) this.jDynObjectComponent.getComponent(); |
70 |
} |
71 |
|
72 |
|
73 |
/* (non-Javadoc)
|
74 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#addValueChangedListener(org.gvsig.tools.swing.api.dynobject.ValueChangedListener)
|
75 |
*/
|
76 |
public void addValueChangedListener(ValueChangedListener listener) { |
77 |
// TODO Auto-generated method stub
|
78 |
} |
79 |
|
80 |
|
81 |
/* (non-Javadoc)
|
82 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#fireValueChangedEvent()
|
83 |
*/
|
84 |
public void fireValueChangedEvent() { |
85 |
// TODO Auto-generated method stub
|
86 |
} |
87 |
|
88 |
|
89 |
/* (non-Javadoc)
|
90 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JComponent#getComponent()
|
91 |
*/
|
92 |
public Object getComponent() { |
93 |
return this.jDynObjectComponent.getComponent(); |
94 |
} |
95 |
|
96 |
|
97 |
/* (non-Javadoc)
|
98 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getDefaultValue()
|
99 |
*/
|
100 |
public Object getDefaultValue() { |
101 |
return this.dynField.getDefaultValue(); |
102 |
} |
103 |
|
104 |
/* (non-Javadoc)
|
105 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#getDynField()
|
106 |
*/
|
107 |
public DynField getDynField() {
|
108 |
return this.dynField; |
109 |
} |
110 |
|
111 |
|
112 |
private DynObject getDynObjectValue(){
|
113 |
if (this.dynObject == null) |
114 |
this.dynObject = (DynObject) getFieldValue();
|
115 |
return this.dynObject; |
116 |
} |
117 |
|
118 |
|
119 |
/* (non-Javadoc)
|
120 |
* @see org.gvsig.tools.swing.spi.DelegatedJFieldComponent#getFieldValue()
|
121 |
*/
|
122 |
public Object getFieldValue() { |
123 |
return this.dynObject; |
124 |
} |
125 |
|
126 |
/* (non-Javadoc)
|
127 |
* @see org.gvsig.tools.service.Service#getManager()
|
128 |
*/
|
129 |
public Manager getManager() {
|
130 |
// TODO Auto-generated method stub
|
131 |
return null; |
132 |
} |
133 |
|
134 |
|
135 |
/* (non-Javadoc)
|
136 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue()
|
137 |
*/
|
138 |
public Object getValue() { |
139 |
return getDynObjectValue();
|
140 |
} |
141 |
|
142 |
|
143 |
/* (non-Javadoc)
|
144 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isMandatory()
|
145 |
*/
|
146 |
public boolean isMandatory() { |
147 |
return this.dynField.isMandatory(); |
148 |
} |
149 |
|
150 |
|
151 |
/* (non-Javadoc)
|
152 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#isValid()
|
153 |
*/
|
154 |
public boolean isValid() { |
155 |
return this.jDynObjectComponent.isValid(); |
156 |
} |
157 |
|
158 |
|
159 |
/* (non-Javadoc)
|
160 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#requestFocus()
|
161 |
*/
|
162 |
public void requestFocus() { |
163 |
this.component.requestFocus();
|
164 |
|
165 |
} |
166 |
|
167 |
|
168 |
/* (non-Javadoc)
|
169 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#saveStatus()
|
170 |
*/
|
171 |
public void saveStatus() { |
172 |
this.jDynObjectComponent.saveStatus();
|
173 |
} |
174 |
|
175 |
|
176 |
/* (non-Javadoc)
|
177 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#setEnabled(boolean)
|
178 |
*/
|
179 |
public void setEnabled(boolean isEnabled) { |
180 |
component.setEnabled(isEnabled); |
181 |
} |
182 |
|
183 |
|
184 |
/* (non-Javadoc)
|
185 |
* @see org.gvsig.tools.swing.spi.DelegatedJFieldComponent#setFieldValue(java.lang.Object)
|
186 |
*/
|
187 |
public void setFieldValue(Object value) { |
188 |
if (value instanceof DynObject){ |
189 |
this.dynObject = (DynObject) value;
|
190 |
} |
191 |
} |
192 |
|
193 |
|
194 |
/* (non-Javadoc)
|
195 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java.lang.Object)
|
196 |
*/
|
197 |
public void setValue(Object value) { |
198 |
if (this.dynObject!=null) |
199 |
this.dynObject = (DynObject) value;
|
200 |
} |
201 |
|
202 |
} |