svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / wizard / VectorialDBConnectionParamsDialog.java @ 41633
History | View | Annotate | Download (4.29 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.geodb.vectorialdb.wizard; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
30 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
31 |
import org.gvsig.tools.ToolsLocator; |
32 |
import org.gvsig.tools.i18n.I18nManager; |
33 |
import org.gvsig.tools.service.ServiceException; |
34 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
35 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
36 |
|
37 |
import org.slf4j.Logger; |
38 |
import org.slf4j.LoggerFactory; |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
public class VectorialDBConnectionParamsDialog extends VectorialDBConnectionParamsDialogLayout { |
44 |
|
45 |
private static final long serialVersionUID = -5493563028200403559L; |
46 |
|
47 |
private static final Logger LOG = LoggerFactory |
48 |
.getLogger(VectorialDBConnectionParamsDialog.class); |
49 |
|
50 |
private boolean isCanceled = false; |
51 |
|
52 |
public VectorialDBConnectionParamsDialog() {
|
53 |
initComponents(); |
54 |
} |
55 |
|
56 |
private void initComponents() { |
57 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
58 |
this.butAdvanced.setText(i18nManager.getTranslation("advanced")); |
59 |
this.butAdvanced.addActionListener(new ActionListener() { |
60 |
public void actionPerformed(ActionEvent ae) { |
61 |
doAdvanced(); |
62 |
} |
63 |
}); |
64 |
this.butAcept.setText(i18nManager.getTranslation("ok")); |
65 |
this.butAcept.addActionListener(new ActionListener() { |
66 |
public void actionPerformed(ActionEvent ae) { |
67 |
doAcept(); |
68 |
} |
69 |
}); |
70 |
this.butCancel.setText(i18nManager.getTranslation("cancel")); |
71 |
this.butCancel.addActionListener(new ActionListener() { |
72 |
public void actionPerformed(ActionEvent ae) { |
73 |
doCancel(); |
74 |
} |
75 |
}); |
76 |
this.setPreferredSize(new Dimension(550, 250)); |
77 |
} |
78 |
|
79 |
protected void doAdvanced() { |
80 |
JDBCServerExplorerParameters myParams = this.getServerExplorerParameters();
|
81 |
try {
|
82 |
myParams.validate(); |
83 |
} catch (Exception e) { |
84 |
// ignore... only for fill default values
|
85 |
} |
86 |
|
87 |
try {
|
88 |
DynObjectEditor editor = new DynObjectEditor(myParams);
|
89 |
editor.editObject(true);
|
90 |
this.jdbcServerExplorer.setServerExplorerParameters(myParams);
|
91 |
} catch (ServiceException ex) {
|
92 |
LOG.error("Error creating a Swing component for the DynObject: "
|
93 |
+ myParams, ex); |
94 |
} |
95 |
} |
96 |
|
97 |
protected void doAcept() { |
98 |
this.isCanceled = false; |
99 |
this.setVisible(false); |
100 |
} |
101 |
|
102 |
protected void doCancel() { |
103 |
this.isCanceled = true; |
104 |
this.setVisible(false); |
105 |
} |
106 |
|
107 |
public void showDialog() { |
108 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
109 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
110 |
winmgr.showWindow( |
111 |
this,
|
112 |
i18nManager.getTranslation("_Connection_parameters"),
|
113 |
WindowManager.MODE.DIALOG |
114 |
); |
115 |
} |
116 |
|
117 |
public boolean isCanceled() { |
118 |
return this.isCanceled; |
119 |
} |
120 |
|
121 |
public JDBCServerExplorerParameters getServerExplorerParameters() {
|
122 |
return this.jdbcServerExplorer.getServerExplorerParameters(); |
123 |
} |
124 |
|
125 |
public String getConnectionName() { |
126 |
return this.jdbcServerExplorer.getConnectionName(); |
127 |
} |
128 |
|
129 |
} |
130 |
|