Statistics
| Revision:

root / trunk / extensions / extOracleSpatial / src / es / prodevelop / cit / gvsig / jdbc_spatial / gui / jdbcwizard / RepeatedChooseGeometryTypePanel.java @ 18370

History | View | Annotate | Download (7.79 KB)

1
package es.prodevelop.cit.gvsig.jdbc_spatial.gui.jdbcwizard;
2

    
3
import javax.swing.ButtonGroup;
4
import javax.swing.ImageIcon;
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 com.hardcode.driverManager.Driver;
16
import com.iver.andami.PluginServices;
17
import com.iver.cit.gvsig.fmap.core.FShape;
18
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
19
import com.iver.cit.gvsig.fmap.edition.IWriteable;
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 RepeatedChooseGeometryTypePanel 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 RepeatedChooseGeometryTypePanel(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 setDriver(Driver driver) {
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) driver;
191
                ISpatialWriter writer = (ISpatialWriter) aux.getWriter(); 
192
                
193
                driverName = driver.getName();
194
                getJRadioButtonPoint().setEnabled(writer.canWriteGeometry(FShape.POINT));
195
                getJRadioButtonMultiPoint().setEnabled(writer.canWriteGeometry(FShape.MULTIPOINT));
196
                getJRadioButtonLine().setEnabled(writer.canWriteGeometry(FShape.LINE));
197
                getJRadioButtonPolygon().setEnabled(writer.canWriteGeometry(FShape.POLYGON));
198
                getJRadioButtonMulti().setEnabled(writer.canWriteGeometry(FShape.MULTI));
199
        }
200

    
201
        public int getSelectedGeometryType()
202
        {
203
                if (getJRadioButtonPoint().isSelected())
204
                        return FShape.POINT;
205
                if (getJRadioButtonMultiPoint().isSelected())
206
                        return FShape.MULTIPOINT;
207
                if (getJRadioButtonLine().isSelected())
208
                        return FShape.LINE;
209
                if (getJRadioButtonPolygon().isSelected())
210
                        return FShape.POLYGON;
211
                if (getJRadioButtonMulti().isSelected())
212
                        return FShape.MULTI;
213

    
214
                return -1;
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,20));
226
                        jTextFieldLayerName.setText("layer1"); //PluginServices.getText(this,"new_layer"));
227
                        jTextFieldLayerName.setHorizontalAlignment(javax.swing.JTextField.LEFT);
228
                        jTextFieldLayerName.addCaretListener(new MyInputEventListener());
229
                }
230
                return jTextFieldLayerName;
231
        }
232

    
233
        public String getLayerName() {
234
                return getJTextFieldLayerName().getText();
235
        }
236

    
237
        public String getSelectedDriver() {
238
                return driverName;
239
        }
240
        
241
}  //  @jve:decl-index=0:visual-constraint="10,10"