Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / cad / panels / ChooseWriteDriver.java @ 40557

History | View | Annotate | Download (4.73 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.editing.gui.cad.panels;
25

    
26
import javax.swing.JComboBox;
27
import javax.swing.JLabel;
28
import javax.swing.JTextField;
29
import javax.swing.event.CaretEvent;
30
import javax.swing.event.CaretListener;
31

    
32
import jwizardcomponent.JWizardComponents;
33
import jwizardcomponent.JWizardPanel;
34

    
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.messages.NotificationManager;
37
import org.gvsig.fmap.dal.DALLocator;
38
import org.gvsig.fmap.dal.DataManager;
39
import org.gvsig.fmap.dal.DataStoreParameters;
40
import org.gvsig.fmap.dal.feature.FeatureStore;
41

    
42

    
43
/**
44
 * @author fjp
45
 *
46
 * Panel para que el usuario seleccione el driver que va a utilizar para
47
 * crear un tema desde cero.
48
 *
49
 */
50
public class ChooseWriteDriver extends JWizardPanel {
51

    
52
        private JLabel lblSelecDriver = null;
53
        private JComboBox jCmbBoxDrivers = null;
54
        private String[] driverNames;
55
        private JLabel jLabel = null;
56
        private JTextField jTextLayerName = null;
57

    
58
        private class MyInputEventListener implements CaretListener
59
        {
60
                public void caretUpdate(CaretEvent arg0) {
61
                        if (jTextLayerName.getText().length() > 0)
62
                                setNextButtonEnabled(true);
63
                        else
64
                                setNextButtonEnabled(false);
65

    
66
                }
67

    
68
        }
69

    
70
        public ChooseWriteDriver(JWizardComponents wizardComponents, String title, String[] driverNames) {
71
                super(wizardComponents, title);
72
                this.driverNames = driverNames;
73
                initialize();
74
                // TODO Auto-generated constructor stub
75

    
76
        }
77

    
78
        public String getSelectedDriver()
79
        {
80
                return (String) jCmbBoxDrivers.getSelectedItem();
81
        }
82

    
83
        /**
84
         * This method initializes this
85
         *
86
         */
87
        private void initialize() {
88
        jLabel = new JLabel();
89
        jLabel.setText(PluginServices.getText(this,"enter_layer_name"));
90
        jLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
91
        jLabel.setBounds(new java.awt.Rectangle(15,7,241,15));
92
        lblSelecDriver = new JLabel();
93
        lblSelecDriver.setText(PluginServices.getText(this,"select_driver"));
94
        lblSelecDriver.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
95
        lblSelecDriver.setBounds(new java.awt.Rectangle(15,68,245,15));
96
        this.setLayout(null);
97
        this.setSize(new java.awt.Dimension(274,167));
98
        this.add(jLabel, null);
99
        this.add(lblSelecDriver, null);
100
        this.add(getJCmbBoxDrivers(), null);
101
        this.add(getJTextLayerName(), null);
102

    
103

    
104
        }
105

    
106
        /**
107
         * This method initializes jCmbBoxDrivers
108
         *
109
         * @return javax.swing.JComboBox
110
         */
111
        private JComboBox getJCmbBoxDrivers() {
112
                if (jCmbBoxDrivers == null) {
113
                        jCmbBoxDrivers = new JComboBox(driverNames);
114
                        jCmbBoxDrivers.setBounds(new java.awt.Rectangle(15,93,240,19));
115
                }
116
                return jCmbBoxDrivers;
117
        }
118

    
119
        /* (non-Javadoc)
120
         * @see jwizardcomponent.JWizardPanel#next()
121
         */
122
        public void next() {
123
                super.next();
124
                try {
125
                        JWizardPanel nextPanel =  getWizardComponents().getCurrentPanel();
126
                        if (nextPanel instanceof ChooseGeometryType)
127
                        {
128
                                ChooseGeometryType panel = (ChooseGeometryType) nextPanel;
129
                                DataManager DM=DALLocator.getDataManager();
130
                                DataStoreParameters dsp=DM.createStoreParameters(getSelectedDriver());
131

    
132
                                FeatureStore store =(FeatureStore) DM.createStore(dsp);
133
                                panel.setFeatureStore(store);
134
                        }
135
                } catch (Exception e) {
136
                        NotificationManager.addError(e.getMessage(),e);
137
                }
138
        }
139

    
140
        public String getLayerName() {
141
                return jTextLayerName.getText();
142
        }
143

    
144
        /**
145
         * This method initializes jTextLayerName
146
         *
147
         * @return javax.swing.JTextField
148
         */
149
        private JTextField getJTextLayerName() {
150
                if (jTextLayerName == null) {
151
                        jTextLayerName = new JTextField();
152
                        jTextLayerName.setBounds(new java.awt.Rectangle(15,30,244,20));
153
                        jTextLayerName.setText(PluginServices.getText(this,"new_layer"));
154
                        jTextLayerName.setHorizontalAlignment(javax.swing.JTextField.LEFT);
155
                        jTextLayerName.addCaretListener(new MyInputEventListener());
156
                }
157
                return jTextLayerName;
158
        }
159

    
160

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