Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extGPE-gvSIG / src / org / gvsig / gpe / gui / dialogs / SelectVersionPanel.java @ 18292

History | View | Annotate | Download (12.1 KB)

1
package org.gvsig.gpe.gui.dialogs;
2

    
3
import java.awt.Color;
4

    
5
import javax.swing.JPanel;
6

    
7
import org.gvsig.gpe.writers.GPEWriterHandler;
8

    
9
import com.iver.andami.PluginServices;
10

    
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id$
54
 * $Log$
55
 *
56
 */
57
/**
58
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
59
 */
60
public class SelectVersionPanel extends JPanel{
61
        private javax.swing.JPanel buttonsPanel;
62
        private javax.swing.JButton cancelButton;
63
        private javax.swing.JPanel componentsPanel;
64
        private javax.swing.JButton exportButton;
65
        private javax.swing.JButton fileButton;
66
        private javax.swing.JLabel fileLabel;
67
        private javax.swing.JTextField fileText;
68
        private javax.swing.JComboBox formatCombo;
69
        private javax.swing.JLabel formatLabel;
70
        private javax.swing.JButton schemaButton;
71
        private javax.swing.JCheckBox schemaCheck;
72
        private javax.swing.JLabel schemaLabel;
73
        private javax.swing.JTextField schemaText;
74
        private javax.swing.JComboBox versionCombo;
75
        private javax.swing.JLabel versionLabel;
76
        private javax.swing.JComboBox writerCombo;
77
        private javax.swing.JLabel writerLabel;
78

    
79

    
80
        public SelectVersionPanel(){
81
                initComponents();
82
                initLabels();
83
                initCombos();
84
        }
85

    
86
        /**
87
         * Initializes all the components
88
         */
89
        private void initComponents() {
90
                java.awt.GridBagConstraints gridBagConstraints;
91

    
92
                componentsPanel = new javax.swing.JPanel();
93
                versionCombo = new javax.swing.JComboBox();
94
                formatLabel = new javax.swing.JLabel();
95
                formatCombo = new javax.swing.JComboBox();
96
                versionLabel = new javax.swing.JLabel();
97
                writerLabel = new javax.swing.JLabel();
98
                writerCombo = new javax.swing.JComboBox();
99
                fileLabel = new javax.swing.JLabel();
100
                fileText = new javax.swing.JTextField();
101
                fileButton = new javax.swing.JButton();
102
                schemaLabel = new javax.swing.JLabel();
103
                schemaText = new javax.swing.JTextField();
104
                schemaButton = new javax.swing.JButton();
105
                schemaCheck = new javax.swing.JCheckBox();
106
                buttonsPanel = new javax.swing.JPanel();
107
                cancelButton = new javax.swing.JButton();
108
                exportButton = new javax.swing.JButton();
109

    
110
                setLayout(new java.awt.BorderLayout());
111

    
112
                componentsPanel.setLayout(new java.awt.GridBagLayout());
113

    
114
                versionCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Version 1" }));
115
                gridBagConstraints = new java.awt.GridBagConstraints();
116
                gridBagConstraints.gridx = 0;
117
                gridBagConstraints.gridy = 10;
118
                gridBagConstraints.gridwidth = 2;
119
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
120
                gridBagConstraints.weightx = 1.0;
121
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
122
                componentsPanel.add(versionCombo, gridBagConstraints);
123

    
124
                formatLabel.setText("Select the format");
125
                gridBagConstraints = new java.awt.GridBagConstraints();
126
                gridBagConstraints.gridx = 0;
127
                gridBagConstraints.gridy = 7;
128
                gridBagConstraints.gridwidth = 2;
129
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
130
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
131
                componentsPanel.add(formatLabel, gridBagConstraints);
132

    
133
                formatCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Format 1" }));
134
                gridBagConstraints = new java.awt.GridBagConstraints();
135
                gridBagConstraints.gridx = 0;
136
                gridBagConstraints.gridy = 8;
137
                gridBagConstraints.gridwidth = 2;
138
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
139
                gridBagConstraints.weightx = 1.0;
140
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
141
                componentsPanel.add(formatCombo, gridBagConstraints);
142

    
143
                versionLabel.setText("Select the version");
144
                gridBagConstraints = new java.awt.GridBagConstraints();
145
                gridBagConstraints.gridx = 0;
146
                gridBagConstraints.gridy = 9;
147
                gridBagConstraints.gridwidth = 2;
148
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
149
                gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
150
                componentsPanel.add(versionLabel, gridBagConstraints);
151

    
152
                writerLabel.setText("Select the writer");
153
                gridBagConstraints = new java.awt.GridBagConstraints();
154
                gridBagConstraints.gridx = 0;
155
                gridBagConstraints.gridy = 5;
156
                gridBagConstraints.gridwidth = 2;
157
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
158
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
159
                componentsPanel.add(writerLabel, gridBagConstraints);
160

    
161
                writerCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Writer 1" }));
162
                gridBagConstraints = new java.awt.GridBagConstraints();
163
                gridBagConstraints.gridx = 0;
164
                gridBagConstraints.gridy = 6;
165
                gridBagConstraints.gridwidth = 2;
166
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
167
                gridBagConstraints.weightx = 1.0;
168
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
169
                componentsPanel.add(writerCombo, gridBagConstraints);
170

    
171
                fileLabel.setText("Select the File");
172
                gridBagConstraints = new java.awt.GridBagConstraints();
173
                gridBagConstraints.gridx = 0;
174
                gridBagConstraints.gridy = 0;
175
                gridBagConstraints.gridwidth = 2;
176
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
177
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
178
                componentsPanel.add(fileLabel, gridBagConstraints);
179

    
180
                gridBagConstraints = new java.awt.GridBagConstraints();
181
                gridBagConstraints.gridx = 0;
182
                gridBagConstraints.gridy = 1;
183
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
184
                gridBagConstraints.weightx = 1.0;
185
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
186
                componentsPanel.add(fileText, gridBagConstraints);
187

    
188
                fileButton.setText("jButton1");
189
                fileButton.setMaximumSize(new java.awt.Dimension(25, 25));
190
                fileButton.setMinimumSize(new java.awt.Dimension(25, 25));
191
                fileButton.setPreferredSize(new java.awt.Dimension(25, 25));
192
                gridBagConstraints = new java.awt.GridBagConstraints();
193
                gridBagConstraints.gridx = 1;
194
                gridBagConstraints.gridy = 1;
195
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
196
                componentsPanel.add(fileButton, gridBagConstraints);
197

    
198
                schemaLabel.setText("Select a schema");
199
                gridBagConstraints = new java.awt.GridBagConstraints();
200
                gridBagConstraints.gridx = 0;
201
                gridBagConstraints.gridy = 2;
202
                gridBagConstraints.gridwidth = 2;
203
                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
204
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
205
                componentsPanel.add(schemaLabel, gridBagConstraints);
206

    
207
                gridBagConstraints = new java.awt.GridBagConstraints();
208
                gridBagConstraints.gridx = 0;
209
                gridBagConstraints.gridy = 4;
210
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
211
                gridBagConstraints.weightx = 1.0;
212
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
213
                componentsPanel.add(schemaText, gridBagConstraints);
214

    
215
                schemaButton.setPreferredSize(new java.awt.Dimension(25, 25));
216
                gridBagConstraints = new java.awt.GridBagConstraints();
217
                gridBagConstraints.gridx = 1;
218
                gridBagConstraints.gridy = 4;
219
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
220
                componentsPanel.add(schemaButton, gridBagConstraints);
221

    
222
                schemaCheck.setText("Generate the shema automatically");
223
                schemaCheck.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
224
                schemaCheck.setMargin(new java.awt.Insets(0, 0, 0, 0));
225
                gridBagConstraints = new java.awt.GridBagConstraints();
226
                gridBagConstraints.gridx = 0;
227
                gridBagConstraints.gridy = 3;
228
                gridBagConstraints.gridwidth = 2;
229
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
230
                gridBagConstraints.weightx = 1.0;
231
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
232
                componentsPanel.add(schemaCheck, gridBagConstraints);
233

    
234
                add(componentsPanel, java.awt.BorderLayout.CENTER);
235

    
236
                buttonsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
237

    
238
                cancelButton.setText("Cancel");
239
                buttonsPanel.add(cancelButton);
240

    
241
                exportButton.setText("Export");
242
                buttonsPanel.add(exportButton);
243

    
244
                add(buttonsPanel, java.awt.BorderLayout.SOUTH);
245

    
246
        }             
247

    
248
        /**
249
         * Initializes all the labels
250
         */
251
        private void initLabels(){
252
                //Labels
253
                versionLabel.setText(PluginServices.getText(this, "gpe_select_version") + ":");
254
                formatLabel.setText(PluginServices.getText(this, "gpe_select_format") + ":");
255
                writerLabel.setText(PluginServices.getText(this, "gpe_select_writer") + ":");
256
                schemaLabel.setText(PluginServices.getText(this, "gpe_select_schema") + ":");
257
                schemaCheck.setText(PluginServices.getText(this, "gpe_create_default_schema"));
258
                //Combo colors
259
                versionCombo.setBackground(Color.WHITE);
260
                formatCombo.setBackground(Color.WHITE);
261
                writerCombo.setBackground(Color.WHITE);
262
                //Buttons size
263
                fileButton.setText("...");
264
                schemaButton.setText("...");
265
                //images
266
                //fileButton.setIcon(PluginServices.getIconTheme().get("project-open"));
267
                //schemaButton.setIcon(PluginServices.getIconTheme().get("project-open"));
268
        }
269

    
270
        /**
271
         * removes all the items
272
         */
273
        private void initCombos(){
274
                versionCombo.removeAllItems();
275
                formatCombo.removeAllItems();
276
                writerCombo.removeAllItems();
277
        }
278

    
279
        /**
280
         * removes all the items
281
         */
282
        public void initializeSelection(){
283
                versionCombo.removeAllItems();
284
                formatCombo.removeAllItems();
285
        }
286

    
287
        /**
288
         * Sets the listener for the buttons
289
         * @param listener
290
         * The listener to set
291
         */
292
        public void addActionListener(SelectVersionListener listener){
293
                cancelButton.setActionCommand(listener.CANCEL_BUTTON);
294
                cancelButton.addActionListener(listener);
295
                exportButton.setActionCommand(listener.EXPORT_BUTTON);
296
                exportButton.addActionListener(listener);
297
                writerCombo.setActionCommand(listener.WRITER_COMBO);
298
                writerCombo.addActionListener(listener);
299
                fileButton.setActionCommand(listener.FILE_BUTTON);
300
                fileButton.addActionListener(listener);
301
                schemaButton.setActionCommand(listener.SCHEMA_BUTTON);
302
                schemaButton.addActionListener(listener);
303
        
304
        }
305

    
306
        /**
307
         * @return the selected writer
308
         */
309
        public GPEWriterHandler getSelectedWriter(){
310
                if (writerCombo.getItemCount() > 0){
311
                        return (GPEWriterHandler)writerCombo.getSelectedItem();
312
                }
313
                return null;
314
        }
315

    
316
        /**
317
         * @return the selected writer
318
         */
319
        public String getSelectedFile(){
320
                return fileText.getText();
321
        }
322

    
323
        /**
324
         * @return the selected version
325
         */
326
        public String getSelectedVersion(){
327
                if (versionCombo.getItemCount() > 0){
328
                        return (String)versionCombo.getSelectedItem();
329
                }
330
                return null;
331
        }
332

    
333
        /**
334
         * @return the selected format
335
         */
336
        public String getSelectedFormat(){
337
                if (formatCombo.getItemCount() > 0){
338
                        return (String)formatCombo.getSelectedItem();
339
                }
340
                return null;
341
        }
342

    
343
        /**
344
         * Select a version
345
         */
346
        public void setSelectedVersion(String version){
347
                versionCombo.setSelectedItem(version);
348
        }
349

    
350
        /**
351
         * Select a format
352
         */
353
        public void setSelectedFormat(String format){
354
                formatCombo.setSelectedItem(format);
355
        }
356

    
357
        /**
358
         * Sets a file
359
         */
360
        public void setFile(String file){
361
                fileText.setText(file);
362
        }
363

    
364
        /**
365
         * Adds a new writer
366
         * @param writer
367
         * The writer to add
368
         */
369
        public void addWriter(GPEWriterHandler writer){
370
                writerCombo.addItem(writer);
371
        }
372

    
373
        /**
374
         * Adds a new format
375
         * @param format
376
         * The format to add
377
         */
378
        public void addFormat(String format){
379
                formatCombo.addItem(format);
380
        }
381

    
382
        /**
383
         * Adds a new version
384
         * @param version
385
         * The version to add
386
         */
387
        public void addVersion(String version){
388
                versionCombo.addItem(version);
389
        }
390
}