Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / gui / NewOracleTableWizard.java @ 30231

History | View | Annotate | Download (3.96 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.oracle.gui;
29

    
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.event.ItemEvent;
33
import java.awt.event.ItemListener;
34
import java.beans.PropertyChangeEvent;
35
import java.beans.PropertyChangeListener;
36

    
37
import jwizardcomponent.JWizardComponents;
38
import jwizardcomponent.JWizardPanel;
39

    
40
import org.gvsig.geodb.vectorialdb.wizard.MyExplorer;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

    
44
/**
45
 * New oracle spatial table wizard
46
 * 
47
 * @author jldominguez, vsanjaime
48
 * 
49
 */
50

    
51
public class NewOracleTableWizard extends JWizardPanel implements ItemListener,
52
                PropertyChangeListener {
53

    
54
        private static final long serialVersionUID = 1L;
55
        @SuppressWarnings("unused")
56
        private static final Logger logger = LoggerFactory
57
                        .getLogger(NewOracleTableWizard.class);
58
        private ConnectionChooserPanel connectionPanel = null;
59
        private MyExplorer selExplorer = null;
60

    
61
        /**
62
         * Constructor
63
         * 
64
         * @param wizardComponents
65
         */
66
        public NewOracleTableWizard(JWizardComponents wizardComponents) {
67
                super(wizardComponents);
68
                wizardComponents.addPropertyChangeListener(this);
69
                initialize();
70
        }
71

    
72
        /**
73
         * Events over panel
74
         */
75
        public void itemStateChanged(ItemEvent e) {
76

    
77
                // Combo
78
                if (e.getSource() == connectionPanel.availableConnectionsComboBox) {
79

    
80
                        MyExplorer selExp = connectionPanel.getSelectedServerExplorer();
81

    
82
                        if (selExp == null) {
83
                                getWizardComponents().getFinishButton().setEnabled(false);
84
                                selExplorer = null;
85
                                return;
86
                        }
87
                        getWizardComponents().getFinishButton().setEnabled(true);
88
                        selExplorer = selExp;
89
                }
90
        }
91

    
92
        /**
93
         * Property change event
94
         */
95
        public void propertyChange(PropertyChangeEvent evt) {
96

    
97
                if (evt.getPropertyName().compareToIgnoreCase(
98
                                JWizardComponents.CURRENT_PANEL_PROPERTY) == 0) {
99

    
100
                        if (evt.getNewValue() == this) {
101
                                boolean valid_conn = !(selExplorer == null);
102
                                getWizardComponents().getFinishButton().setEnabled(valid_conn);
103
                        }
104
                }
105
        }
106

    
107
        /**
108
         * Create a explorer parameters with name of selected explorer
109
         * 
110
         * @return
111
         */
112
        public MyExplorer getSelectedServerExplorer() {
113

    
114
                Object obj = connectionPanel.getSelectedServerExplorer();
115
                if (obj == null || obj instanceof String) {
116
                        return null;
117
                }
118
                return (MyExplorer) obj;
119
        }
120

    
121
        /**
122
         * This method initializes this
123
         * 
124
         */
125
        private void initialize() {
126

    
127
                connectionPanel = new ConnectionChooserPanel();
128

    
129
                this.setLayout(new GridBagLayout());
130
                this.setSize(new java.awt.Dimension(358, 263));
131

    
132
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
133
                gridBagConstraints.gridx = 0;
134
                gridBagConstraints.gridy = 0;
135
                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
136
                gridBagConstraints.weightx = 1.0;
137
                gridBagConstraints.weighty = 1.0;
138
                this.add(connectionPanel, gridBagConstraints);
139

    
140
                connectionPanel.availableConnectionsComboBox.addItemListener(this);
141

    
142
                getWizardComponents().getFinishButton().setEnabled(false);
143
        }
144

    
145
}