Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extOracleSpatial / src / org / gvsig / oraclespatial / gui / RepeatedChooseGeometryTypePanel.java @ 29544

History | View | Annotate | Download (7.08 KB)

1
package org.gvsig.oraclespatial.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.fmap.geom.Geometry;
15

    
16
import com.iver.andami.PluginServices;
17

    
18
/**
19
 * @author fjp
20
 * 
21
 *         Panel para que el usuario seleccione el tipo de geometr?a de la capa.
22
 * 
23
 */
24
public class RepeatedChooseGeometryTypePanel extends JWizardPanel {
25

    
26
        private JLabel lblSelecGeometryType = null;
27
        private JPanel jPanelGeometryTypeOptions = null;
28
        private JRadioButton jRadioButtonPoint = null;
29
        private JRadioButton jRadioButtonLine = null;
30
        private JRadioButton jRadioButtonPolygon = null;
31
        private JRadioButton jRadioButtonMulti = null;
32
        private JRadioButton jRadioButtonMultiPoint = null;
33
        private JTextField jTextFieldLayerName = null;
34
        private JLabel jLabelLayerName = null;
35

    
36
        /**
37
         * Constructor
38
         * 
39
         * @param wizardComponents
40
         */
41
        public RepeatedChooseGeometryTypePanel(JWizardComponents wizardComponents) {
42
                super(wizardComponents);
43
                initialize();
44
        }
45

    
46
        /**
47
         * get layer name
48
         * 
49
         * @return
50
         */
51
        public String getLayerName() {
52
                return getJTextFieldLayerName().getText();
53
        }
54

    
55
        /**
56
         * get selected geometry
57
         * 
58
         * @return
59
         */
60
        public int getSelectedGeometryType() {
61
                if (getJRadioButtonPoint().isSelected())
62
                        return Geometry.TYPES.POINT;
63
                if (getJRadioButtonMultiPoint().isSelected())
64
                        return Geometry.TYPES.MULTIPOINT;
65
                if (getJRadioButtonLine().isSelected())
66
                        return Geometry.TYPES.ARC;
67
                if (getJRadioButtonPolygon().isSelected())
68
                        return Geometry.TYPES.SURFACE;
69
                if (getJRadioButtonMulti().isSelected())
70
                        return Geometry.TYPES.AGGREGATE;
71

    
72
                return -1;
73
        }
74

    
75
        /**
76
         * This method initializes this
77
         * 
78
         */
79
        private void initialize() {
80
                jLabelLayerName = new JLabel();
81
                jLabelLayerName.setBounds(new java.awt.Rectangle(14, 9, 321, 22));
82
                jLabelLayerName.setText(PluginServices
83
                                .getText(this, "enter_layer_name"));
84
                lblSelecGeometryType = new JLabel();
85
                lblSelecGeometryType.setText(PluginServices.getText(this,
86
                                "select_geometry_type"));
87
                lblSelecGeometryType.setBounds(new java.awt.Rectangle(13, 63, 329, 15));
88
                this.setLayout(null);
89
                this.setSize(new java.awt.Dimension(358, 263));
90
                this.add(lblSelecGeometryType, null);
91
                this.add(getJPanelGeometryTypeOptions(), null);
92
                this.add(getJTextFieldLayerName(), null);
93
                this.add(jLabelLayerName, null);
94

    
95
        }
96

    
97
        /**
98
         * This method initializes jPanelGeometryTypeOptions
99
         * 
100
         * @return javax.swing.JPanel
101
         */
102
        private JPanel getJPanelGeometryTypeOptions() {
103
                if (jPanelGeometryTypeOptions == null) {
104
                        jPanelGeometryTypeOptions = new JPanel();
105
                        jPanelGeometryTypeOptions.setLayout(null);
106
                        jPanelGeometryTypeOptions
107
                                        .setBorder(javax.swing.BorderFactory
108
                                                        .createTitledBorder(
109
                                                                        null,
110
                                                                        PluginServices.getText(this,
111
                                                                                        "Geometry_types"),
112
                                                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
113
                                                                        javax.swing.border.TitledBorder.DEFAULT_POSITION,
114
                                                                        null, null));
115
                        jPanelGeometryTypeOptions.setPreferredSize(new java.awt.Dimension(
116
                                        300, 400));
117
                        jPanelGeometryTypeOptions.setBounds(new java.awt.Rectangle(14, 82,
118
                                        326, 172));
119
                        jPanelGeometryTypeOptions.add(getJRadioButtonPoint(), null);
120
                        jPanelGeometryTypeOptions.add(getJRadioButtonLine(), null);
121
                        jPanelGeometryTypeOptions.add(getJRadioButtonPolygon(), null);
122
                        jPanelGeometryTypeOptions.add(getJRadioButtonMulti(), null);
123
                        jPanelGeometryTypeOptions.add(getJRadioButtonMultiPoint(), null);
124

    
125
                        // Group the radio buttons.
126
                        ButtonGroup group = new ButtonGroup();
127
                        group.add(getJRadioButtonPoint());
128
                        group.add(getJRadioButtonLine());
129
                        group.add(getJRadioButtonPolygon());
130
                        group.add(getJRadioButtonMulti());
131
                        group.add(getJRadioButtonMultiPoint());
132

    
133
                }
134
                return jPanelGeometryTypeOptions;
135
        }
136

    
137
        /**
138
         * This method initializes jRadioButtonPoint
139
         * 
140
         * @return javax.swing.JRadioButton
141
         */
142
        private JRadioButton getJRadioButtonPoint() {
143
                if (jRadioButtonPoint == null) {
144
                        jRadioButtonPoint = new JRadioButton();
145
                        jRadioButtonPoint.setText(PluginServices
146
                                        .getText(this, "point_type"));
147
                        jRadioButtonPoint
148
                                        .setBounds(new java.awt.Rectangle(19, 31, 297, 23));
149
                }
150
                return jRadioButtonPoint;
151
        }
152

    
153
        /**
154
         * This method initializes jRadioButtonLine
155
         * 
156
         * @return javax.swing.JRadioButton
157
         */
158
        private JRadioButton getJRadioButtonLine() {
159
                if (jRadioButtonLine == null) {
160
                        jRadioButtonLine = new JRadioButton();
161
                        jRadioButtonLine.setText(PluginServices.getText(this, "line_type"));
162
                        jRadioButtonLine.setSelected(true);
163
                        jRadioButtonLine.setBounds(new java.awt.Rectangle(19, 81, 297, 23));
164
                }
165
                return jRadioButtonLine;
166
        }
167

    
168
        /**
169
         * This method initializes jRadioButtonPolygon
170
         * 
171
         * @return javax.swing.JRadioButton
172
         */
173
        private JRadioButton getJRadioButtonPolygon() {
174
                if (jRadioButtonPolygon == null) {
175
                        jRadioButtonPolygon = new JRadioButton();
176
                        jRadioButtonPolygon.setText(PluginServices.getText(this,
177
                                        "polygon_type"));
178
                        jRadioButtonPolygon.setBounds(new java.awt.Rectangle(19, 106, 297,
179
                                        23));
180
                }
181
                return jRadioButtonPolygon;
182
        }
183

    
184
        /**
185
         * This method initializes jRadioButtonMulti
186
         * 
187
         * @return javax.swing.JRadioButton
188
         */
189
        private JRadioButton getJRadioButtonMulti() {
190
                if (jRadioButtonMulti == null) {
191
                        jRadioButtonMulti = new JRadioButton();
192
                        jRadioButtonMulti.setText(PluginServices
193
                                        .getText(this, "multi_type"));
194
                        jRadioButtonMulti
195
                                        .setBounds(new java.awt.Rectangle(19, 131, 297, 23));
196
                }
197
                return jRadioButtonMulti;
198
        }
199

    
200
        /**
201
         * This method initializes jRadioButton
202
         * 
203
         * @return javax.swing.JRadioButton
204
         */
205
        private JRadioButton getJRadioButtonMultiPoint() {
206
                if (jRadioButtonMultiPoint == null) {
207
                        jRadioButtonMultiPoint = new JRadioButton();
208
                        jRadioButtonMultiPoint.setText(PluginServices.getText(this,
209
                                        "multipoint_type"));
210
                        jRadioButtonMultiPoint.setBounds(new java.awt.Rectangle(19, 56,
211
                                        297, 23));
212
                }
213
                return jRadioButtonMultiPoint;
214
        }
215

    
216
        /**
217
         * This method initializes jTextLayerName
218
         * 
219
         * @return javax.swing.JTextField
220
         */
221
        private JTextField getJTextFieldLayerName() {
222
                if (jTextFieldLayerName == null) {
223
                        jTextFieldLayerName = new JTextField();
224
                        jTextFieldLayerName.setBounds(new java.awt.Rectangle(13, 36, 323,
225
                                        20));
226
                        jTextFieldLayerName.setText("layer1"); // PluginServices.getText(this,"new_layer"));
227
                        jTextFieldLayerName
228
                                        .setHorizontalAlignment(javax.swing.JTextField.LEFT);
229
                        jTextFieldLayerName.addCaretListener(new MyInputEventListener());
230
                }
231
                return jTextFieldLayerName;
232
        }
233

    
234
        /**
235
         * 
236
         * @author fjp
237
         * 
238
         */
239
        private class MyInputEventListener implements CaretListener {
240
                public void caretUpdate(CaretEvent arg0) {
241
                        if (jTextFieldLayerName.getText().length() > 0)
242
                                setNextButtonEnabled(true);
243
                        else
244
                                setNextButtonEnabled(false);
245

    
246
                }
247

    
248
        }
249

    
250
}