Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / gui / RepeatedChooseGeometryTypePanel.java @ 29865

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
/**
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 static final long serialVersionUID = 1L;
27

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

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

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

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

    
74
                return -1;
75
        }
76

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

    
97
        }
98

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

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

    
135
                }
136
                return jPanelGeometryTypeOptions;
137
        }
138

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

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

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

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

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

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

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

    
248
                }
249

    
250
        }
251

    
252
}