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