svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extOracleSpatial / src / org / gvsig / oraclespatial / gui / OracleConnectionChooserPanel.java @ 29544
History | View | Annotate | Download (5.81 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 |
package org.gvsig.oraclespatial.gui; |
28 |
|
29 |
import java.awt.event.ActionEvent; |
30 |
import java.awt.event.ActionListener; |
31 |
import java.awt.event.ItemEvent; |
32 |
import java.awt.event.ItemListener; |
33 |
import java.awt.event.KeyEvent; |
34 |
import java.awt.event.KeyListener; |
35 |
import java.beans.PropertyChangeEvent; |
36 |
import java.beans.PropertyChangeListener; |
37 |
|
38 |
import javax.swing.JButton; |
39 |
import javax.swing.JPanel; |
40 |
|
41 |
import org.slf4j.Logger; |
42 |
import org.slf4j.LoggerFactory; |
43 |
|
44 |
import com.iver.andami.PluginServices; |
45 |
import com.iver.andami.ui.mdiManager.IWindow; |
46 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
47 |
import com.prodevelop.cit.gvsig.vectorialdb.wizard.MyExplorer; |
48 |
|
49 |
/**
|
50 |
* This dialog lets the user choose an available connection.
|
51 |
*
|
52 |
* @author jldominguez, vsanjaime
|
53 |
*
|
54 |
*/
|
55 |
public class OracleConnectionChooserPanel extends JPanel implements IWindow, |
56 |
ActionListener, ItemListener, KeyListener { |
57 |
|
58 |
@SuppressWarnings("unused") |
59 |
private static Logger logger = LoggerFactory |
60 |
.getLogger(OracleConnectionChooserPanel.class.getName()); |
61 |
|
62 |
private JButton okButton = null; |
63 |
private ConnectionChooserPanel connectionPanel = null; |
64 |
private JButton cancelButton = null; |
65 |
|
66 |
private MyExplorer selectedExplorerParams = null; |
67 |
|
68 |
private boolean okPressed = false; |
69 |
WindowInfo winfo = null;
|
70 |
|
71 |
/**
|
72 |
* This method initializes
|
73 |
*
|
74 |
*/
|
75 |
public OracleConnectionChooserPanel() {
|
76 |
super();
|
77 |
initialize(); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* get window info
|
82 |
*/
|
83 |
public WindowInfo getWindowInfo() {
|
84 |
return winfo;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* get window profile
|
89 |
*/
|
90 |
public Object getWindowProfile() { |
91 |
return WindowInfo.DIALOG_PROFILE;
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* Create a explorer parameters with name of selected explorer
|
96 |
*
|
97 |
* @return
|
98 |
*/
|
99 |
public MyExplorer getSelectedServerExplorer() {
|
100 |
|
101 |
return selectedExplorerParams;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* is ok button pressed
|
106 |
*
|
107 |
* @return
|
108 |
*/
|
109 |
public boolean isOkPressed() { |
110 |
return okPressed;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Action Performed event
|
115 |
*/
|
116 |
public void actionPerformed(ActionEvent arg0) { |
117 |
// ok button
|
118 |
if (arg0.getSource() == okButton) {
|
119 |
okPressed = true;
|
120 |
MyExplorer selExplorer = connectionPanel |
121 |
.getSelectedServerExplorer(); |
122 |
|
123 |
if (selExplorer == null) { |
124 |
okButton.setEnabled(false);
|
125 |
selectedExplorerParams = null;
|
126 |
return;
|
127 |
} else {
|
128 |
selectedExplorerParams = selExplorer; |
129 |
okButton.setEnabled(true);
|
130 |
okButton.requestFocus(); |
131 |
} |
132 |
PluginServices.getMDIManager().closeWindow(this);
|
133 |
} |
134 |
// cancel button
|
135 |
if (arg0.getSource() == cancelButton) {
|
136 |
okPressed = false;
|
137 |
selectedExplorerParams = null;
|
138 |
PluginServices.getMDIManager().closeWindow(this);
|
139 |
} |
140 |
} |
141 |
|
142 |
/**
|
143 |
* Change combo selected element
|
144 |
*/
|
145 |
public void itemStateChanged(ItemEvent arg0) { |
146 |
// combo explorers
|
147 |
if (arg0.getSource() == connectionPanel) {
|
148 |
|
149 |
MyExplorer selExplorer = connectionPanel |
150 |
.getSelectedServerExplorer(); |
151 |
|
152 |
if (selExplorer == null) { |
153 |
okButton.setEnabled(false);
|
154 |
selectedExplorerParams = null;
|
155 |
return;
|
156 |
} else {
|
157 |
selectedExplorerParams = selExplorer; |
158 |
okButton.setEnabled(true);
|
159 |
okButton.requestFocus(); |
160 |
} |
161 |
} |
162 |
} |
163 |
|
164 |
/**
|
165 |
* Key pressed event
|
166 |
*/
|
167 |
public void keyPressed(KeyEvent e) { |
168 |
Object src = e.getSource();
|
169 |
|
170 |
if ((src == okButton) || (src == cancelButton)) {
|
171 |
ActionEvent aux = new ActionEvent(src, |
172 |
ActionEvent.ACTION_PERFORMED, ""); |
173 |
actionPerformed(aux); |
174 |
} |
175 |
} |
176 |
|
177 |
/**
|
178 |
* Key released event
|
179 |
*/
|
180 |
public void keyReleased(KeyEvent e) { |
181 |
// nothing to do
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* Key typed event
|
186 |
*/
|
187 |
public void keyTyped(KeyEvent e) { |
188 |
// nothing to do
|
189 |
} |
190 |
|
191 |
/**
|
192 |
* This method initializes this
|
193 |
*
|
194 |
*/
|
195 |
private void initialize() { |
196 |
winfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
197 |
winfo.setHeight(119 - 70); |
198 |
winfo.setWidth(395);
|
199 |
winfo.setTitle(PluginServices.getText(this, "choose_connection")); |
200 |
|
201 |
connectionPanel = new ConnectionChooserPanel();
|
202 |
|
203 |
this.setLayout(null); |
204 |
this.setSize(new java.awt.Dimension(395, 89)); |
205 |
this.add(connectionPanel, null); |
206 |
this.add(getOkButton(), null); |
207 |
this.add(getCancelButton(), null); |
208 |
} |
209 |
|
210 |
/**
|
211 |
* This method initializes okButton
|
212 |
*
|
213 |
* @return JButton
|
214 |
*/
|
215 |
private JButton getOkButton() { |
216 |
if (okButton == null) { |
217 |
okButton = new JButton(PluginServices.getText(this, "ok")); |
218 |
okButton.addActionListener(this);
|
219 |
okButton.addKeyListener(this);
|
220 |
okButton.setBounds(new java.awt.Rectangle(90, 50, 106, 26)); |
221 |
} |
222 |
return okButton;
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* This method initializes cancelButton
|
227 |
*
|
228 |
* @return JButton
|
229 |
*/
|
230 |
private JButton getCancelButton() { |
231 |
if (cancelButton == null) { |
232 |
cancelButton = new JButton(PluginServices.getText(this, "cancel")); |
233 |
cancelButton.addActionListener(this);
|
234 |
cancelButton.addKeyListener(this);
|
235 |
cancelButton.setBounds(new java.awt.Rectangle(200, 50, 106, 26)); |
236 |
} |
237 |
return cancelButton;
|
238 |
} |
239 |
|
240 |
} |