svn-gvsig-desktop / tags / v2_0_0_Build_2030 / applications / appgvSIG / src / org / gvsig / app / tools / swing / serv / field / crs / JCRSDynFieldComponent.java @ 35872
History | View | Annotate | Download (5.76 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.app.tools.swing.serv.field.crs; |
35 |
|
36 |
import java.awt.event.ActionEvent; |
37 |
import java.awt.event.ActionListener; |
38 |
|
39 |
import javax.swing.JButton; |
40 |
import javax.swing.JComponent; |
41 |
|
42 |
import org.cresques.cts.IProjection; |
43 |
import org.gvsig.andami.PluginServices; |
44 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
45 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
46 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
47 |
import org.gvsig.tools.dynobject.DynField; |
48 |
import org.gvsig.tools.service.ServiceException; |
49 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent; |
50 |
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField; |
51 |
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponent; |
52 |
|
53 |
/**
|
54 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a>
|
55 |
*
|
56 |
*/
|
57 |
public class JCRSDynFieldComponent extends AbstractJDynFieldComponent implements |
58 |
JDynFieldComponent, IWindow, ActionListener {
|
59 |
|
60 |
private CRSSelectPanel panel;
|
61 |
private JButton button; |
62 |
|
63 |
/**
|
64 |
* @param proj
|
65 |
*/
|
66 |
|
67 |
public JCRSDynFieldComponent(DynField definition, ValueField value, boolean writeable) |
68 |
throws ServiceException {
|
69 |
super(definition, value, writeable);
|
70 |
} |
71 |
/*
|
72 |
* (non-Javadoc)
|
73 |
*
|
74 |
* @see
|
75 |
*
|
76 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#saveStatus
|
77 |
* ()
|
78 |
*/
|
79 |
public void saveStatus() { |
80 |
setFieldValue(this.getValue());
|
81 |
} |
82 |
|
83 |
/*
|
84 |
* (non-Javadoc)
|
85 |
*
|
86 |
* @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue()
|
87 |
*/
|
88 |
public Object getValue() { |
89 |
return this.getCurProj(); |
90 |
} |
91 |
|
92 |
/*
|
93 |
* (non-Javadoc)
|
94 |
*
|
95 |
* @see
|
96 |
* org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java
|
97 |
* .lang.Object)
|
98 |
*/
|
99 |
public void setNullValue() { |
100 |
this.setCurProj(null); |
101 |
} |
102 |
|
103 |
public void setNonNullValue(Object value) { |
104 |
if (value instanceof IProjection) { |
105 |
setCurProj((IProjection) value); |
106 |
} else {
|
107 |
setNullValue(); |
108 |
} |
109 |
} |
110 |
|
111 |
public void setCurProj(IProjection projection) { |
112 |
panel.setCurProj(projection); |
113 |
} |
114 |
|
115 |
public IProjection getCurProj() {
|
116 |
return panel.getCurProj();
|
117 |
} |
118 |
|
119 |
/*
|
120 |
* (non-Javadoc)
|
121 |
*
|
122 |
* @see
|
123 |
* org.gvsig.tools.swing.api.dynobject.dynfield.JComponent#getComponent()
|
124 |
*/
|
125 |
public Object getComponent() { |
126 |
return panel;
|
127 |
} |
128 |
|
129 |
@Override
|
130 |
protected void setJDynFieldComponentListeners() { |
131 |
|
132 |
} |
133 |
|
134 |
@Override
|
135 |
protected void afterUI() { |
136 |
this.panel.getJLabel().setVisible(false); |
137 |
} |
138 |
|
139 |
@Override
|
140 |
protected void initData() { |
141 |
} |
142 |
|
143 |
@Override
|
144 |
protected void initUI() { |
145 |
IProjection proj = (IProjection) this.getFieldValue();
|
146 |
if (proj==null){ |
147 |
proj = (IProjection) this.getDefaultFieldValue();
|
148 |
} |
149 |
panel = initJPanelProj(proj); |
150 |
} |
151 |
|
152 |
protected void setReadOnly() { |
153 |
this.button.setVisible(false); |
154 |
} |
155 |
|
156 |
public void requestFocus() { |
157 |
this.panel.requestFocus();
|
158 |
} |
159 |
|
160 |
public void setEnabled(boolean isEnabled) { |
161 |
this.panel.setEnabled(isEnabled);
|
162 |
} |
163 |
|
164 |
public void actionPerformed(ActionEvent e) { |
165 |
setValue(panel.getCurProj()); |
166 |
} |
167 |
|
168 |
|
169 |
public WindowInfo getWindowInfo() {
|
170 |
WindowInfo m_ViewInfo = |
171 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
172 |
m_ViewInfo.setTitle(PluginServices.getText(this, "acerca_de")); |
173 |
|
174 |
return m_ViewInfo;
|
175 |
} |
176 |
|
177 |
public Object getWindowProfile() { |
178 |
return WindowInfo.DIALOG_PROFILE;
|
179 |
} |
180 |
|
181 |
@Override
|
182 |
public void setValue(Object value) { |
183 |
if (value instanceof IProjection) |
184 |
setCurProj((IProjection) value); |
185 |
else
|
186 |
setNullValue(); |
187 |
} |
188 |
|
189 |
public JComponent asJComponent() { |
190 |
return panel;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* This method initializes jPanel4
|
195 |
*
|
196 |
* @return javax.swing.JPanel
|
197 |
*/
|
198 |
private CRSSelectPanel initJPanelProj(IProjection proj) {
|
199 |
if (panel == null) { |
200 |
panel = CRSSelectPanel.getPanel(proj); |
201 |
panel.setTransPanelActive(true);
|
202 |
panel.setPreferredSize(new java.awt.Dimension(330,35)); |
203 |
panel.addActionListener(new java.awt.event.ActionListener() {
|
204 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
205 |
if (panel.isOkPressed()) {
|
206 |
setValue(panel.getCurProj()); |
207 |
} |
208 |
} |
209 |
}); |
210 |
} |
211 |
return panel;
|
212 |
} |
213 |
|
214 |
} |