svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / panels / annotation / SelectAnnotationLayerNameAndField.java @ 40558
History | View | Annotate | Download (5.71 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.app.gui.panels.annotation; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.Rectangle; |
28 |
import java.awt.event.ItemEvent; |
29 |
import java.awt.event.ItemListener; |
30 |
|
31 |
import javax.swing.JComboBox; |
32 |
import javax.swing.JLabel; |
33 |
import javax.swing.JTextField; |
34 |
import javax.swing.event.CaretEvent; |
35 |
import javax.swing.event.CaretListener; |
36 |
|
37 |
import org.gvsig.andami.PluginServices; |
38 |
|
39 |
import jwizardcomponent.JWizardComponents; |
40 |
import jwizardcomponent.JWizardPanel; |
41 |
|
42 |
|
43 |
//TODO comentado para que compile
|
44 |
public class SelectAnnotationLayerNameAndField extends JWizardPanel { |
45 |
// private FLyrAnnotation layer;
|
46 |
|
47 |
public SelectAnnotationLayerNameAndField(JWizardComponents wizardComponents) {
|
48 |
super(wizardComponents);
|
49 |
// TODO Auto-generated constructor stub
|
50 |
} |
51 |
|
52 |
|
53 |
private JLabel lblDescription = null; |
54 |
private JLabel lblStep1 = null; |
55 |
private JLabel lblNewLayerName = null; |
56 |
private JLabel lblStep2 = null; |
57 |
private JLabel lblField = null; |
58 |
|
59 |
private JTextField txtNewLayerName = null; |
60 |
private JComboBox cmbField = null; |
61 |
|
62 |
|
63 |
private static final Rectangle lblDescriptionPosition = new Rectangle(4,4,355,75); |
64 |
|
65 |
private static final Rectangle lblStep1Position = new Rectangle(4,90,15,15); |
66 |
private static final Rectangle lblNewLayerNamePosition = new Rectangle(30,90,355,15); |
67 |
private static final Rectangle txtNewLayerNamePosition = new Rectangle(30,109,250,18); |
68 |
|
69 |
|
70 |
private static final Rectangle lblStep2Position = new Rectangle(4,135,15,12); |
71 |
private static final Rectangle lblFieldPosition = new Rectangle(30,135,355,30); |
72 |
private static final Rectangle cmbFieldPosition = new Rectangle(30,169,170,18); |
73 |
|
74 |
|
75 |
|
76 |
|
77 |
private class EventsListener implements CaretListener,ItemListener |
78 |
{ |
79 |
public void caretUpdate(CaretEvent arg0) { |
80 |
updateButtonsState(); |
81 |
} |
82 |
|
83 |
public void itemStateChanged(ItemEvent e) { |
84 |
updateButtonsState(); |
85 |
} |
86 |
|
87 |
} |
88 |
|
89 |
|
90 |
private void updateButtonsState() { |
91 |
setBackButtonEnabled(false);
|
92 |
boolean enabled =checkIsOkPanelData();
|
93 |
setNextButtonEnabled(enabled); |
94 |
setFinishButtonEnabled(enabled); |
95 |
} |
96 |
|
97 |
|
98 |
private EventsListener eventsListener = new EventsListener(); |
99 |
|
100 |
|
101 |
protected boolean checkIsOkPanelData() { |
102 |
if (txtNewLayerName.getText().trim().length() < 1) { |
103 |
return false; |
104 |
} |
105 |
if (((String)cmbField.getSelectedItem()).trim().length() < 1) { |
106 |
return false; |
107 |
} |
108 |
return true; |
109 |
} |
110 |
|
111 |
|
112 |
// public SelectAnnotationLayerNameAndField(JWizardComponents arg0,FLyrAnnotation layer) {
|
113 |
// super(arg0);
|
114 |
// this.layer =layer;
|
115 |
// this.initialize();
|
116 |
// }
|
117 |
|
118 |
protected void initialize() { |
119 |
this.setLayout(null); |
120 |
this.setSize(new Dimension(358,263)); |
121 |
this.addLabels();
|
122 |
|
123 |
this.add(getTxtNewLayerName(),null); |
124 |
this.add(getCmbField(),null); |
125 |
|
126 |
checkIsOkPanelData(); |
127 |
} |
128 |
|
129 |
private JTextField getTxtNewLayerName() { |
130 |
if (this.txtNewLayerName == null) { |
131 |
this.txtNewLayerName = new JTextField(); |
132 |
this.txtNewLayerName.setBounds(txtNewLayerNamePosition);
|
133 |
this.txtNewLayerName.setText("NuevaCapa"); |
134 |
this.txtNewLayerName.addCaretListener(eventsListener);
|
135 |
} |
136 |
return this.txtNewLayerName; |
137 |
} |
138 |
|
139 |
public String getNewLayerName() { |
140 |
return this.getTxtNewLayerName().getText(); |
141 |
} |
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 |
|
153 |
// try {
|
154 |
// SelectableDataSource dataSource = this.layer.getRecordset();
|
155 |
//
|
156 |
// String[] fieldsNames = dataSource.getFieldNames();
|
157 |
//
|
158 |
// for (int i=0; i < fieldsNames.length; i++) {
|
159 |
// this.cmbField.addItem(fieldsNames[i]);
|
160 |
// }
|
161 |
//
|
162 |
// } catch (ReadDriverException e) {
|
163 |
// // TODO Auto-generated catch block
|
164 |
// e.printStackTrace();
|
165 |
// }
|
166 |
|
167 |
} |
168 |
return this.cmbField; |
169 |
} |
170 |
|
171 |
public String getField() { |
172 |
return (String)this.getCmbField().getSelectedItem(); |
173 |
} |
174 |
|
175 |
|
176 |
protected void addLabels() { |
177 |
this.lblDescription = new JLabel(); |
178 |
this.lblStep1 = new JLabel(); |
179 |
this.lblNewLayerName = new JLabel(); |
180 |
this.lblStep2 = new JLabel(); |
181 |
this.lblField= new JLabel(); |
182 |
|
183 |
this.lblDescription.setText(PluginServices.getText(this,"descripcion_de_crear_capa_de_anotaciones")); |
184 |
this.lblStep1.setText("1."); |
185 |
this.lblNewLayerName.setText(PluginServices.getText(this,"introduzca_el_nombre_de_la_nueva_capa_de_anotaciones")); |
186 |
this.lblStep2.setText("2."); |
187 |
this.lblField.setText(PluginServices.getText(this,"seleccione_el_campo_de_texto_que_desea_que_se_utilize_para_mostrar_la_nueva_capa_virtual")); |
188 |
|
189 |
this.lblDescription.setBounds(lblDescriptionPosition);
|
190 |
this.lblStep1.setBounds(lblStep1Position);
|
191 |
this.lblNewLayerName.setBounds(lblNewLayerNamePosition);
|
192 |
this.lblStep2.setBounds(lblStep2Position);
|
193 |
this.lblField.setBounds(lblFieldPosition);
|
194 |
|
195 |
|
196 |
this.add(lblDescription,null); |
197 |
this.add(lblStep1,null); |
198 |
this.add(lblNewLayerName,null); |
199 |
this.add(lblStep2,null); |
200 |
this.add(lblField,null); |
201 |
|
202 |
} |
203 |
|
204 |
|
205 |
|
206 |
} |