svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / gui / RepeatedChooseGeometryTypePanel.java @ 30231
History | View | Annotate | Download (7.13 KB)
1 |
package org.gvsig.oracle.gui; |
---|---|
2 |
|
3 |
import javax.swing.ButtonGroup; |
4 |
import javax.swing.JLabel; |
5 |
import javax.swing.JPanel; |
6 |
import javax.swing.JRadioButton; |
7 |
import javax.swing.JTextField; |
8 |
import javax.swing.event.CaretEvent; |
9 |
import javax.swing.event.CaretListener; |
10 |
|
11 |
import jwizardcomponent.JWizardComponents; |
12 |
import jwizardcomponent.JWizardPanel; |
13 |
|
14 |
import org.gvsig.andami.PluginServices; |
15 |
import org.gvsig.fmap.geom.Geometry; |
16 |
|
17 |
/**
|
18 |
* @author fjp
|
19 |
*
|
20 |
* Panel para que el usuario seleccione el tipo de geometr?a de la capa.
|
21 |
*
|
22 |
*/
|
23 |
public class RepeatedChooseGeometryTypePanel extends JWizardPanel { |
24 |
|
25 |
private static final long serialVersionUID = 1L; |
26 |
|
27 |
private JLabel lblSelecGeometryType = null; |
28 |
private JPanel jPanelGeometryTypeOptions = null; |
29 |
private JRadioButton jRadioButtonPoint = null; |
30 |
private JRadioButton jRadioButtonLine = null; |
31 |
private JRadioButton jRadioButtonPolygon = null; |
32 |
private JRadioButton jRadioButtonMulti = null; |
33 |
private JRadioButton jRadioButtonMultiPoint = null; |
34 |
private JTextField jTextFieldLayerName = null; |
35 |
private JLabel jLabelLayerName = null; |
36 |
|
37 |
/**
|
38 |
* Constructor
|
39 |
*
|
40 |
* @param wizardComponents
|
41 |
*/
|
42 |
public RepeatedChooseGeometryTypePanel(JWizardComponents wizardComponents) {
|
43 |
super(wizardComponents);
|
44 |
initialize(); |
45 |
} |
46 |
|
47 |
/**
|
48 |
* get layer name
|
49 |
*
|
50 |
* @return
|
51 |
*/
|
52 |
public String getLayerName() { |
53 |
return getJTextFieldLayerName().getText();
|
54 |
} |
55 |
|
56 |
/**
|
57 |
* get selected geometry
|
58 |
*
|
59 |
* @return
|
60 |
*/
|
61 |
public int getSelectedGeometryType() { |
62 |
if (getJRadioButtonPoint().isSelected())
|
63 |
return Geometry.TYPES.POINT;
|
64 |
if (getJRadioButtonMultiPoint().isSelected())
|
65 |
return Geometry.TYPES.MULTIPOINT;
|
66 |
if (getJRadioButtonLine().isSelected())
|
67 |
return Geometry.TYPES.CURVE;
|
68 |
if (getJRadioButtonPolygon().isSelected())
|
69 |
return Geometry.TYPES.SURFACE;
|
70 |
if (getJRadioButtonMulti().isSelected())
|
71 |
return Geometry.TYPES.AGGREGATE;
|
72 |
|
73 |
return -1; |
74 |
} |
75 |
|
76 |
/**
|
77 |
* This method initializes this
|
78 |
*
|
79 |
*/
|
80 |
private void initialize() { |
81 |
jLabelLayerName = new JLabel(); |
82 |
jLabelLayerName.setBounds(new java.awt.Rectangle(14, 9, 321, 22)); |
83 |
jLabelLayerName.setText(PluginServices |
84 |
.getText(this, "enter_layer_name")); |
85 |
lblSelecGeometryType = new JLabel(); |
86 |
lblSelecGeometryType.setText(PluginServices.getText(this,
|
87 |
"select_geometry_type"));
|
88 |
lblSelecGeometryType.setBounds(new java.awt.Rectangle(13, 63, 329, 15)); |
89 |
this.setLayout(null); |
90 |
this.setSize(new java.awt.Dimension(358, 263)); |
91 |
this.add(lblSelecGeometryType, null); |
92 |
this.add(getJPanelGeometryTypeOptions(), null); |
93 |
this.add(getJTextFieldLayerName(), null); |
94 |
this.add(jLabelLayerName, null); |
95 |
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* This method initializes jPanelGeometryTypeOptions
|
100 |
*
|
101 |
* @return javax.swing.JPanel
|
102 |
*/
|
103 |
private JPanel getJPanelGeometryTypeOptions() { |
104 |
if (jPanelGeometryTypeOptions == null) { |
105 |
jPanelGeometryTypeOptions = new JPanel(); |
106 |
jPanelGeometryTypeOptions.setLayout(null);
|
107 |
jPanelGeometryTypeOptions |
108 |
.setBorder(javax.swing.BorderFactory |
109 |
.createTitledBorder( |
110 |
null,
|
111 |
PluginServices.getText(this,
|
112 |
"Geometry_types"),
|
113 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
114 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, |
115 |
null, null)); |
116 |
jPanelGeometryTypeOptions.setPreferredSize(new java.awt.Dimension(
|
117 |
300, 400)); |
118 |
jPanelGeometryTypeOptions.setBounds(new java.awt.Rectangle(14, 82, |
119 |
326, 172)); |
120 |
jPanelGeometryTypeOptions.add(getJRadioButtonPoint(), null);
|
121 |
jPanelGeometryTypeOptions.add(getJRadioButtonLine(), null);
|
122 |
jPanelGeometryTypeOptions.add(getJRadioButtonPolygon(), null);
|
123 |
jPanelGeometryTypeOptions.add(getJRadioButtonMulti(), null);
|
124 |
jPanelGeometryTypeOptions.add(getJRadioButtonMultiPoint(), null);
|
125 |
|
126 |
// Group the radio buttons.
|
127 |
ButtonGroup group = new ButtonGroup(); |
128 |
group.add(getJRadioButtonPoint()); |
129 |
group.add(getJRadioButtonLine()); |
130 |
group.add(getJRadioButtonPolygon()); |
131 |
group.add(getJRadioButtonMulti()); |
132 |
group.add(getJRadioButtonMultiPoint()); |
133 |
|
134 |
} |
135 |
return jPanelGeometryTypeOptions;
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* This method initializes jRadioButtonPoint
|
140 |
*
|
141 |
* @return javax.swing.JRadioButton
|
142 |
*/
|
143 |
private JRadioButton getJRadioButtonPoint() { |
144 |
if (jRadioButtonPoint == null) { |
145 |
jRadioButtonPoint = new JRadioButton(); |
146 |
jRadioButtonPoint.setText(PluginServices |
147 |
.getText(this, "point_type")); |
148 |
jRadioButtonPoint |
149 |
.setBounds(new java.awt.Rectangle(19, 31, 297, 23)); |
150 |
} |
151 |
return jRadioButtonPoint;
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* This method initializes jRadioButtonLine
|
156 |
*
|
157 |
* @return javax.swing.JRadioButton
|
158 |
*/
|
159 |
private JRadioButton getJRadioButtonLine() { |
160 |
if (jRadioButtonLine == null) { |
161 |
jRadioButtonLine = new JRadioButton(); |
162 |
jRadioButtonLine.setText(PluginServices.getText(this, "line_type")); |
163 |
jRadioButtonLine.setSelected(true);
|
164 |
jRadioButtonLine.setBounds(new java.awt.Rectangle(19, 81, 297, 23)); |
165 |
} |
166 |
return jRadioButtonLine;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* This method initializes jRadioButtonPolygon
|
171 |
*
|
172 |
* @return javax.swing.JRadioButton
|
173 |
*/
|
174 |
private JRadioButton getJRadioButtonPolygon() { |
175 |
if (jRadioButtonPolygon == null) { |
176 |
jRadioButtonPolygon = new JRadioButton(); |
177 |
jRadioButtonPolygon.setText(PluginServices.getText(this,
|
178 |
"polygon_type"));
|
179 |
jRadioButtonPolygon.setBounds(new java.awt.Rectangle(19, 106, 297, |
180 |
23));
|
181 |
} |
182 |
return jRadioButtonPolygon;
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes jRadioButtonMulti
|
187 |
*
|
188 |
* @return javax.swing.JRadioButton
|
189 |
*/
|
190 |
private JRadioButton getJRadioButtonMulti() { |
191 |
if (jRadioButtonMulti == null) { |
192 |
jRadioButtonMulti = new JRadioButton(); |
193 |
jRadioButtonMulti.setText(PluginServices |
194 |
.getText(this, "multi_type")); |
195 |
jRadioButtonMulti |
196 |
.setBounds(new java.awt.Rectangle(19, 131, 297, 23)); |
197 |
} |
198 |
return jRadioButtonMulti;
|
199 |
} |
200 |
|
201 |
/**
|
202 |
* This method initializes jRadioButton
|
203 |
*
|
204 |
* @return javax.swing.JRadioButton
|
205 |
*/
|
206 |
private JRadioButton getJRadioButtonMultiPoint() { |
207 |
if (jRadioButtonMultiPoint == null) { |
208 |
jRadioButtonMultiPoint = new JRadioButton(); |
209 |
jRadioButtonMultiPoint.setText(PluginServices.getText(this,
|
210 |
"multipoint_type"));
|
211 |
jRadioButtonMultiPoint.setBounds(new java.awt.Rectangle(19, 56, |
212 |
297, 23)); |
213 |
} |
214 |
return jRadioButtonMultiPoint;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* This method initializes jTextLayerName
|
219 |
*
|
220 |
* @return javax.swing.JTextField
|
221 |
*/
|
222 |
private JTextField getJTextFieldLayerName() { |
223 |
if (jTextFieldLayerName == null) { |
224 |
jTextFieldLayerName = new JTextField(); |
225 |
jTextFieldLayerName.setBounds(new java.awt.Rectangle(13, 36, 323, |
226 |
20));
|
227 |
jTextFieldLayerName.setText("layer1"); // PluginServices.getText(this,"new_layer")); |
228 |
jTextFieldLayerName |
229 |
.setHorizontalAlignment(javax.swing.JTextField.LEFT); |
230 |
jTextFieldLayerName.addCaretListener(new MyInputEventListener());
|
231 |
} |
232 |
return jTextFieldLayerName;
|
233 |
} |
234 |
|
235 |
/**
|
236 |
*
|
237 |
* @author fjp
|
238 |
*
|
239 |
*/
|
240 |
private class MyInputEventListener implements CaretListener { |
241 |
public void caretUpdate(CaretEvent arg0) { |
242 |
if (jTextFieldLayerName.getText().length() > 0) |
243 |
setNextButtonEnabled(true);
|
244 |
else
|
245 |
setNextButtonEnabled(false);
|
246 |
|
247 |
} |
248 |
|
249 |
} |
250 |
|
251 |
} |