root / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / gui / Annotation_FieldSelect.java @ 12436
History | View | Annotate | Download (7.38 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Ib??ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* IVER T.I. S.A
|
35 |
* Salamanca 50
|
36 |
* 46005 Valencia
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 963163400
|
40 |
* dac@iver.es
|
41 |
*/
|
42 |
|
43 |
package com.iver.cit.gvsig.project.documents.gui; |
44 |
|
45 |
import java.awt.Dimension; |
46 |
import java.awt.Rectangle; |
47 |
import java.awt.event.ItemEvent; |
48 |
import java.awt.event.ItemListener; |
49 |
|
50 |
import javax.swing.JComboBox; |
51 |
import javax.swing.JLabel; |
52 |
import javax.swing.event.CaretEvent; |
53 |
import javax.swing.event.CaretListener; |
54 |
|
55 |
import jwizardcomponent.JWizardComponents; |
56 |
import jwizardcomponent.JWizardPanel; |
57 |
|
58 |
import com.iver.andami.PluginServices; |
59 |
import com.iver.andami.messages.NotificationManager; |
60 |
import com.iver.cit.gvsig.fmap.DriverException; |
61 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
62 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
63 |
|
64 |
|
65 |
/**
|
66 |
* Panel to select the text field.
|
67 |
*
|
68 |
* @author Vicente Caballero Navarro
|
69 |
*/
|
70 |
public class Annotation_FieldSelect extends JWizardPanel { |
71 |
private static final Rectangle lblDescriptionPosition = new Rectangle(4, 14, |
72 |
355, 100); |
73 |
|
74 |
private static final Rectangle lblDuplicatePosition = new Rectangle(30, 115, |
75 |
355, 30); |
76 |
private static final Rectangle cmbDuplicatePosition = new Rectangle(30, |
77 |
150, 170, 18); |
78 |
private static final Rectangle lblStep2Position = new Rectangle(4, 170, 15, |
79 |
12);
|
80 |
private static final Rectangle lblFieldPosition = new Rectangle(30, 170, |
81 |
355, 30); |
82 |
private static final Rectangle cmbFieldPosition = new Rectangle(30, 204, |
83 |
170, 18); |
84 |
private Annotation_Layer layer;
|
85 |
private JLabel lblDescription = null; |
86 |
|
87 |
private JLabel lblStep2 = null; |
88 |
private JLabel lblField = null; |
89 |
|
90 |
private JComboBox cmbField = null; |
91 |
private EventsListener eventsListener = new EventsListener(); |
92 |
private JComboBox cmbDuplicate; |
93 |
private JLabel lblDuplicate = null; |
94 |
|
95 |
public Annotation_FieldSelect(JWizardComponents arg0, Annotation_Layer layer) {
|
96 |
super(arg0);
|
97 |
this.layer = layer;
|
98 |
this.initialize();
|
99 |
} |
100 |
|
101 |
/**
|
102 |
* DOCUMENT ME!
|
103 |
*/
|
104 |
private void updateButtonsState() { |
105 |
try {
|
106 |
if (getWizardComponents().getCurrentIndex() == 0) { |
107 |
setBackButtonEnabled(false);
|
108 |
|
109 |
boolean enabled = checkIsOkPanelData();
|
110 |
setNextButtonEnabled(enabled); |
111 |
setFinishButtonEnabled(enabled); |
112 |
} |
113 |
} catch (Exception e) { |
114 |
NotificationManager.addError(e); |
115 |
} |
116 |
} |
117 |
|
118 |
/**
|
119 |
* DOCUMENT ME!
|
120 |
*
|
121 |
* @return DOCUMENT ME!
|
122 |
*/
|
123 |
protected boolean checkIsOkPanelData() { |
124 |
if (((String) cmbField.getSelectedItem()).trim().length() < 1) { |
125 |
return false; |
126 |
} |
127 |
|
128 |
return true; |
129 |
} |
130 |
|
131 |
/**
|
132 |
* DOCUMENT ME!
|
133 |
*/
|
134 |
protected void initialize() { |
135 |
this.setLayout(null); |
136 |
this.setSize(new Dimension(358, 263)); |
137 |
this.addLabels();
|
138 |
|
139 |
this.add(getCmbField(), null); |
140 |
this.add(getCmbDuplicate(), null); |
141 |
checkIsOkPanelData(); |
142 |
} |
143 |
|
144 |
private JComboBox getCmbField() { |
145 |
if (this.cmbField == null) { |
146 |
this.cmbField = new JComboBox(); |
147 |
this.cmbField.setEditable(false); |
148 |
this.cmbField.setBounds(cmbFieldPosition);
|
149 |
this.cmbField.addItemListener(this.eventsListener); |
150 |
this.cmbField.addItem(""); |
151 |
|
152 |
try {
|
153 |
SelectableDataSource dataSource = this.layer.getRecordset();
|
154 |
|
155 |
String[] fieldsNames = dataSource.getFieldNames(); |
156 |
|
157 |
for (int i = 0; i < fieldsNames.length; i++) { |
158 |
this.cmbField.addItem(fieldsNames[i]);
|
159 |
} |
160 |
|
161 |
if (layer.getAnnotatonMapping() != null) { |
162 |
String fieldSelect = dataSource.getFieldName(layer.getAnnotatonMapping()
|
163 |
.getColumnText()); |
164 |
this.cmbField.setSelectedItem(fieldSelect);
|
165 |
setNextButtonEnabled(true);
|
166 |
} |
167 |
} catch (DriverException e) {
|
168 |
NotificationManager.addError(e); |
169 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
170 |
NotificationManager.addError(e); |
171 |
} |
172 |
} |
173 |
|
174 |
return this.cmbField; |
175 |
} |
176 |
|
177 |
/**
|
178 |
* DOCUMENT ME!
|
179 |
*
|
180 |
* @return DOCUMENT ME!
|
181 |
*/
|
182 |
private JComboBox getCmbDuplicate() { |
183 |
if (cmbDuplicate == null) { |
184 |
cmbDuplicate = new JComboBox(); |
185 |
cmbDuplicate.setBounds(cmbDuplicatePosition); |
186 |
cmbDuplicate.addItem(PluginServices.getText(this, "duplicate.none")); |
187 |
cmbDuplicate.addItem(PluginServices.getText(this, "centered")); |
188 |
cmbDuplicate.setSelectedItem(PluginServices.getText(this, "centered")); |
189 |
} |
190 |
|
191 |
return cmbDuplicate;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* DOCUMENT ME!
|
196 |
*
|
197 |
* @return DOCUMENT ME!
|
198 |
*/
|
199 |
public String getField() { |
200 |
return (String) this.getCmbField().getSelectedItem(); |
201 |
} |
202 |
|
203 |
/**
|
204 |
* DOCUMENT ME!
|
205 |
*
|
206 |
* @return DOCUMENT ME!
|
207 |
*/
|
208 |
public String getDuplicate() { |
209 |
return (String) this.getCmbDuplicate().getSelectedItem(); |
210 |
} |
211 |
|
212 |
/**
|
213 |
* DOCUMENT ME!
|
214 |
*/
|
215 |
protected void addLabels() { |
216 |
this.lblDescription = new JLabel(); |
217 |
|
218 |
this.lblStep2 = new JLabel(); |
219 |
this.lblField = new JLabel(); |
220 |
this.lblDuplicate = new JLabel(); |
221 |
|
222 |
this.lblDuplicate.setText(PluginServices.getText(this, "duplicate")); |
223 |
this.lblDuplicate.setBounds(lblDuplicatePosition);
|
224 |
this.lblDescription.setText(PluginServices.getText(this, |
225 |
"descripcion_de_crear_capa_de_anotaciones_nueva"));
|
226 |
|
227 |
this.lblField.setText(PluginServices.getText(this, |
228 |
"seleccione_el_campo_de_texto_que_desea_que_se_utilize_para_mostrar_la_nueva_capa"));
|
229 |
|
230 |
this.lblDescription.setBounds(lblDescriptionPosition);
|
231 |
this.lblStep2.setBounds(lblStep2Position);
|
232 |
this.lblField.setBounds(lblFieldPosition);
|
233 |
|
234 |
this.add(lblDescription, null); |
235 |
this.add(lblStep2, null); |
236 |
this.add(lblField, null); |
237 |
this.add(lblDuplicate, null); |
238 |
} |
239 |
|
240 |
private class EventsListener implements CaretListener, ItemListener { |
241 |
public void caretUpdate(CaretEvent arg0) { |
242 |
updateButtonsState(); |
243 |
} |
244 |
|
245 |
public void itemStateChanged(ItemEvent e) { |
246 |
updateButtonsState(); |
247 |
} |
248 |
} |
249 |
} |