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