Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / MappingFieldsToAnotation.java @ 4455

History | View | Annotate | Download (10.1 KB)

1
package com.iver.cit.gvsig.gui.Panels;
2

    
3
import java.sql.Types;
4

    
5
import javax.swing.JPanel;
6

    
7
import com.hardcode.gdbms.engine.data.driver.DriverException;
8
import com.iver.andami.PluginServices;
9
import com.iver.andami.ui.mdiManager.View;
10
import com.iver.andami.ui.mdiManager.ViewInfo;
11
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
12
import com.iver.cit.gvsig.fmap.layers.MappingAnnotation;
13
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
14

    
15
import javax.swing.ButtonGroup;
16
import javax.swing.JComboBox;
17
import javax.swing.JLabel;
18
import javax.swing.JButton;
19
import javax.swing.JTextField;
20
import javax.swing.JCheckBox;
21
import javax.swing.JRadioButton;
22

    
23
public class MappingFieldsToAnotation extends JPanel implements View{
24

    
25
        private JComboBox cmbText = null;
26
        private JComboBox cmbAngle = null;
27
        private JLabel jLabel = null;
28
        private JLabel jLabel1 = null;
29
        private JLabel jLabel2 = null;
30
        private JComboBox cmbColor = null;
31
        private JLabel jLabel3 = null;
32
        private JComboBox cmbHeight = null;
33
        private JLabel jLabel4 = null;
34
        private JComboBox cmbFont = null;
35
        private JButton bOk = null;
36
        private JButton bCancel = null;
37
        private SelectableDataSource sds=null;
38
        private FLyrAnnotation la;
39
        private int[] mapText;
40
        private int[] mapAngle;
41
        private int[] mapColor;
42
        private int[] mapHeight;
43
        private int[] mapFont;
44
        private JPanel jPanel = null;
45
        private JLabel jLabel5 = null;
46
        private JTextField txtName = null;
47
        //private JCheckBox chbPixels = null;
48
        private JRadioButton rbMapUnits = null;
49
        private JRadioButton rbPixels = null;
50
        /**
51
         * This is the default constructor
52
         */
53
        public MappingFieldsToAnotation(FLyrAnnotation la) {
54
                super();
55
                this.la=la;
56
                try {
57
                        this.sds=la.getRecordset();
58
                        initialize();
59
                } catch (com.iver.cit.gvsig.fmap.DriverException e) {
60
                        // TODO Auto-generated catch block
61
                        e.printStackTrace();
62
                }
63
                        
64
        }
65

    
66
        /**
67
         * This method initializes this
68
         *
69
         * @return void
70
         */
71
        private void initialize() {
72
                jLabel4 = new JLabel();
73
                jLabel4.setBounds(new java.awt.Rectangle(15,259,166,20));
74
                jLabel4.setText("fuente");
75
                jLabel3 = new JLabel();
76
                jLabel3.setBounds(new java.awt.Rectangle(15,197,166,20));
77
                jLabel3.setText("alto");
78
                jLabel2 = new JLabel();
79
                jLabel2.setBounds(new java.awt.Rectangle(15,135,166,20));
80
                jLabel2.setText("color");
81
                jLabel1 = new JLabel();
82
                jLabel1.setBounds(new java.awt.Rectangle(15,73,166,20));
83
                jLabel1.setText("angulo");
84
                jLabel = new JLabel();
85
                jLabel.setBounds(new java.awt.Rectangle(15,11,166,20));
86
                jLabel.setText("texto");
87
                this.setLayout(null);
88
                this.setSize(544, 368);
89
                this.add(getCmbText(), null);
90
                this.add(getCmbAngle(), null);
91
                this.add(jLabel, null);
92
                this.add(jLabel1, null);
93
                this.add(jLabel2, null);
94
                this.add(getCmbColor(), null);
95
                this.add(jLabel3, null);
96
                this.add(getCmbHeight(), null);
97
                this.add(jLabel4, null);
98
                this.add(getCmbFont(), null);
99
                this.add(getBOk(), null);
100
                this.add(getBCancel(), null);
101
                this.add(getJPanel(), null);
102
        }
103

    
104
        public ViewInfo getViewInfo() {
105
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
106
                m_viewinfo.setTitle(PluginServices.getText(this,
107
                                "indexar_campos"));
108

    
109
                return m_viewinfo;
110
        }
111

    
112
        /**
113
         * This method initializes cmbOrigin
114
         *
115
         * @return javax.swing.JComboBox
116
         */
117
        private JComboBox getCmbText() {
118
                if (cmbText == null) {
119
                        cmbText = new JComboBox();
120
                        try {
121
                                mapText=new int[sds.getFieldCount()];
122
                                int num=-1;
123
                                for (int i = 0; i < sds.getFieldCount(); i++) {
124
                                        cmbText.addItem(sds.getFieldName(i));
125
                                        num++;
126
                                        mapText[i]=num;
127
                                }
128
                                //cmbText.addItem("- Defaulf -");
129
                        } catch (DriverException e) {
130
                                e.printStackTrace();
131
                        }
132
                        cmbText.setBounds(new java.awt.Rectangle(15,42,166,20));
133

    
134
                }
135
                return cmbText;
136
        }
137

    
138
        /**
139
         * This method initializes cmbEnd
140
         *
141
         * @return javax.swing.JComboBox
142
         */
143
        private JComboBox getCmbAngle() {
144
                if (cmbAngle == null) {
145
                        cmbAngle = new JComboBox();
146
                        try {
147
                                mapAngle=new int[sds.getFieldCount()];
148
                                int num=-1;
149
                        for (int i = 0; i < sds.getFieldCount(); i++) {
150
                                if (sds.getFieldType(i) == Types.DOUBLE){
151
                                        cmbAngle.addItem(sds.getFieldName(i));
152
                                        num++;
153
                                        mapAngle[i]=num;
154
                                }
155
                        }
156
                        cmbAngle.addItem("- Default -");
157
                        cmbAngle.setSelectedItem("- Default -");
158
                        } catch (DriverException e) {
159
                                e.printStackTrace();
160
                        }
161
                        cmbAngle.setBounds(new java.awt.Rectangle(15,104,166,20));
162
                }
163
                return cmbAngle;
164
        }
165

    
166
        /**
167
         * This method initializes cmbColor
168
         *
169
         * @return javax.swing.JComboBox
170
         */
171
        private JComboBox getCmbColor() {
172
                if (cmbColor == null) {
173
                        cmbColor = new JComboBox();
174
                        cmbColor.setBounds(new java.awt.Rectangle(15,166,166,20));
175
                        try {
176
                                mapColor=new int[sds.getFieldCount()];
177
                                int num=-1;
178
                                for (int i = 0; i < sds.getFieldCount(); i++) {
179
                                        if (sds.getFieldType(i) == Types.DOUBLE){
180
                                                cmbColor.addItem(sds.getFieldName(i));
181
                                                num++;
182
                                                mapColor[i]=num;
183
                                        }
184
                                }
185
                                cmbColor.addItem("- Default -");
186
                                cmbColor.setSelectedItem("- Default -");
187
                        } catch (DriverException e) {
188
                                e.printStackTrace();
189
                        }
190
                }
191
                return cmbColor;
192
        }
193

    
194
        /**
195
         * This method initializes cmbHeight
196
         *
197
         * @return javax.swing.JComboBox
198
         */
199
        private JComboBox getCmbHeight() {
200
                if (cmbHeight == null) {
201
                        cmbHeight = new JComboBox();
202
                        try {
203
                                mapHeight=new int[sds.getFieldCount()];
204
                                int num=-1;
205
                                for (int i = 0; i < sds.getFieldCount(); i++) {
206
                                        if (sds.getFieldType(i) == Types.DOUBLE){
207
                                                cmbHeight.addItem(sds.getFieldName(i));
208
                                                num++;
209
                                                mapHeight[i]=num;
210
                                        }
211
                                }
212
                                cmbHeight.addItem("- Default -");
213
                                cmbHeight.setSelectedItem("- Default -");
214
                        } catch (DriverException e) {
215
                                e.printStackTrace();
216
                        }
217
                        cmbHeight.setBounds(new java.awt.Rectangle(15,228,166,20));
218
                }
219
                return cmbHeight;
220
        }
221

    
222
        /**
223
         * This method initializes cmbFont
224
         *
225
         * @return javax.swing.JComboBox
226
         */
227
        private JComboBox getCmbFont() {
228
                if (cmbFont == null) {
229
                        cmbFont = new JComboBox();
230
                        try {
231
                                mapFont=new int[sds.getFieldCount()];
232
                                int num=-1;
233
                                for (int i = 0; i < sds.getFieldCount(); i++) {
234
                                        if (sds.getFieldType(i) == Types.VARCHAR){
235
                                                cmbFont.addItem(sds.getFieldName(i));
236
                                                num++;
237
                                                mapFont[i]=num;
238
                                        }
239
                                }
240
                                cmbFont.addItem("- Default -");
241
                                cmbFont.setSelectedItem("- Default -");
242
                        } catch (DriverException e) {
243
                                e.printStackTrace();
244
                        }
245
                        cmbFont.setBounds(new java.awt.Rectangle(15,290,166,20));
246
                }
247
                return cmbFont;
248
        }
249

    
250
        /**
251
         * This method initializes bOk
252
         *
253
         * @return javax.swing.JButton
254
         */
255
        private JButton getBOk() {
256
                if (bOk == null) {
257
                        bOk = new JButton();
258
                        bOk.setBounds(new java.awt.Rectangle(119,326,92,24));
259
                        bOk.setText("Aceptar");
260
                        bOk.addActionListener(new java.awt.event.ActionListener() {
261
                                public void actionPerformed(java.awt.event.ActionEvent e) {
262
                                        MappingAnnotation mapping=new MappingAnnotation();
263
                                        if (getCmbText().getSelectedItem().equals(""))
264
                                                mapping.setColumnText(-1);
265
                                        else
266
                                                mapping.setColumnText(mapText[getCmbText().getSelectedIndex()]);
267
                                        if (!getCmbAngle().getSelectedItem().equals("- Default -"))
268
                                                mapping.setColumnRotate(mapAngle[getCmbAngle().getSelectedIndex()]);
269
                                        if (!getCmbColor().getSelectedItem().equals("- Default -"))
270
                                                mapping.setColumnColor(mapColor[getCmbColor().getSelectedIndex()]);
271
                                        if (!getCmbHeight().getSelectedItem().equals("- Default -"))
272
                                                mapping.setColumnHeight(mapHeight[getCmbHeight().getSelectedIndex()]);
273
                                        if (!getCmbFont().getSelectedItem().equals("- Default -"))
274
                                                mapping.setColumnTypeFont(mapFont[getCmbFont().getSelectedIndex()]);
275
                                        //Falta el estilo, si es necesario.
276
                                        la.setInPixels(rbPixels.isSelected());
277
                                        la.setMapping(mapping);
278
                                        la.setName(getTxtName().getText());
279
                                        PluginServices.getMDIManager().closeView(MappingFieldsToAnotation.this);
280
                                }
281
                        });
282
                }
283
                return bOk;
284
        }
285

    
286
        /**
287
         * This method initializes bCancel
288
         *
289
         * @return javax.swing.JButton
290
         */
291
        private JButton getBCancel() {
292
                if (bCancel == null) {
293
                        bCancel = new JButton();
294
                        bCancel.setBounds(new java.awt.Rectangle(330,325,93,25));
295
                        bCancel.setText("cancelar");
296
                        bCancel.addActionListener(new java.awt.event.ActionListener() {
297
                                public void actionPerformed(java.awt.event.ActionEvent e) {
298
                                        PluginServices.getMDIManager().closeView(MappingFieldsToAnotation.this);
299
                                }
300
                        });
301
                }
302
                return bCancel;
303
        }
304

    
305
        /**
306
         * This method initializes jPanel
307
         *
308
         * @return javax.swing.JPanel
309
         */
310
        private JPanel getJPanel() {
311
                if (jPanel == null) {
312
                        jLabel5 = new JLabel();
313
                        jLabel5.setBounds(new java.awt.Rectangle(15,10,228,22));
314
                        jLabel5.setText("nombre");
315
                        jPanel = new JPanel();
316
                        jPanel.setLayout(null);
317
                        jPanel.setBounds(new java.awt.Rectangle(234,14,251,141));
318
                        jPanel.add(jLabel5, null);
319
                        jPanel.add(getTxtName(), null);
320
                        //jPanel.add(getChbPixels(), null);
321
                        jPanel.add(getRbMapUnits(), null);
322
                        jPanel.add(getRbPixels(), null);
323
                        ButtonGroup bg=new ButtonGroup();
324
                        bg.add(getRbMapUnits());
325
                        bg.add(getRbPixels());
326
                }
327
                return jPanel;
328
        }
329

    
330
        /**
331
         * This method initializes txtName
332
         *
333
         * @return javax.swing.JTextField
334
         */
335
        private JTextField getTxtName() {
336
                if (txtName == null) {
337
                        txtName = new JTextField();
338
                        //txtName.setText(la.get.getName());
339
                        txtName.setBounds(new java.awt.Rectangle(15,42,227,22));
340
                }
341
                return txtName;
342
        }
343

    
344
        /**
345
         * This method initializes chbPixels
346
         *
347
         * @return javax.swing.JCheckBox
348
         */
349
        /*private JCheckBox getChbPixels() {
350
                if (chbPixels == null) {
351
                        chbPixels = new JCheckBox();
352
                        chbPixels.setBounds(new java.awt.Rectangle(15,138,226,25));
353
                        chbPixels.setText("pixels");
354
                }
355
                return chbPixels;
356
        }
357
*/
358
        /**
359
         * This method initializes rbMapUnits
360
         *
361
         * @return javax.swing.JRadioButton
362
         */
363
        private JRadioButton getRbMapUnits() {
364
                if (rbMapUnits == null) {
365
                        rbMapUnits = new JRadioButton();
366
                        rbMapUnits.setBounds(new java.awt.Rectangle(15,74,167,22));
367
                        rbMapUnits.setText("unidades_mapa");
368
                }
369
                return rbMapUnits;
370
        }
371

    
372
        /**
373
         * This method initializes rbPixels
374
         *
375
         * @return javax.swing.JRadioButton
376
         */
377
        private JRadioButton getRbPixels() {
378
                if (rbPixels == null) {
379
                        rbPixels = new JRadioButton();
380
                        rbPixels.setBounds(new java.awt.Rectangle(15,106,167,22));
381
                        rbPixels.setText("pixels");
382
                        rbPixels.setSelected(true);
383
                }
384
                return rbPixels;
385
        }
386

    
387
}  //  @jve:decl-index=0:visual-constraint="-150,10"