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 @ 43377
History | View | Annotate | Download (5.16 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.BorderLayout; |
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.dal.swing.DALSwingLocator; |
31 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
32 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
33 |
import org.gvsig.tools.ToolsLocator; |
34 |
import org.gvsig.tools.i18n.I18nManager; |
35 |
import org.gvsig.tools.service.ServiceException; |
36 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
37 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
38 |
|
39 |
import org.slf4j.Logger; |
40 |
import org.slf4j.LoggerFactory; |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
public class VectorialDBConnectionParamsDialog extends VectorialDBConnectionParamsDialogView { |
46 |
|
47 |
private static final long serialVersionUID = -5493563028200403559L; |
48 |
|
49 |
private static final Logger LOG = LoggerFactory |
50 |
.getLogger(VectorialDBConnectionParamsDialog.class); |
51 |
|
52 |
private boolean isCanceled = false; |
53 |
private JDBCConnectionPanel jdbcServerExplorer;
|
54 |
|
55 |
public VectorialDBConnectionParamsDialog() {
|
56 |
initComponents(); |
57 |
} |
58 |
|
59 |
private void initComponents() { |
60 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
61 |
this.btnAdvanced.setText(i18nManager.getTranslation("advanced")); |
62 |
this.btnAdvanced.addActionListener(new ActionListener() { |
63 |
@Override
|
64 |
public void actionPerformed(ActionEvent ae) { |
65 |
doAdvanced(); |
66 |
} |
67 |
}); |
68 |
this.btnAcept.setText(i18nManager.getTranslation("ok")); |
69 |
this.btnAcept.addActionListener(new ActionListener() { |
70 |
@Override
|
71 |
public void actionPerformed(ActionEvent ae) { |
72 |
doAcept(); |
73 |
} |
74 |
}); |
75 |
this.btnCancel.setText(i18nManager.getTranslation("cancel")); |
76 |
this.btnCancel.addActionListener(new ActionListener() { |
77 |
@Override
|
78 |
public void actionPerformed(ActionEvent ae) { |
79 |
doCancel(); |
80 |
} |
81 |
}); |
82 |
|
83 |
this.btnDelete.setText(i18nManager.getTranslation("del")); |
84 |
this.btnDelete.addActionListener(new ActionListener() { |
85 |
@Override
|
86 |
public void actionPerformed(ActionEvent ae) { |
87 |
doDelete(); |
88 |
} |
89 |
}); |
90 |
this.jdbcServerExplorer = DALSwingLocator.getSwingManager().createJDBCConnectionPanel();
|
91 |
this.containerJDBCConnectionPanel.setLayout(new BorderLayout()); |
92 |
this.containerJDBCConnectionPanel.add(
|
93 |
this.jdbcServerExplorer.asJComponent(),
|
94 |
BorderLayout.CENTER
|
95 |
); |
96 |
} |
97 |
|
98 |
protected void doAdvanced() { |
99 |
JDBCServerExplorerParameters myParams = this.getServerExplorerParameters();
|
100 |
try {
|
101 |
myParams.validate(); |
102 |
} catch (Exception e) { |
103 |
// ignore... only for fill default values
|
104 |
} |
105 |
|
106 |
try {
|
107 |
DynObjectEditor editor = new DynObjectEditor(myParams);
|
108 |
editor.editObject(true);
|
109 |
this.jdbcServerExplorer.setServerExplorerParameters(myParams);
|
110 |
} catch (ServiceException ex) {
|
111 |
LOG.error("Error creating a Swing component for the DynObject: "
|
112 |
+ myParams, ex); |
113 |
} |
114 |
} |
115 |
|
116 |
protected void doAcept() { |
117 |
this.isCanceled = false; |
118 |
this.setVisible(false); |
119 |
} |
120 |
|
121 |
protected void doCancel() { |
122 |
this.isCanceled = true; |
123 |
this.setVisible(false); |
124 |
} |
125 |
|
126 |
protected void doDelete() { |
127 |
this.jdbcServerExplorer.delete();
|
128 |
this.jdbcServerExplorer.clear();
|
129 |
} |
130 |
|
131 |
public void showDialog() { |
132 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
133 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
134 |
winmgr.showWindow( |
135 |
this,
|
136 |
i18nManager.getTranslation("_Connection_parameters"),
|
137 |
WindowManager.MODE.DIALOG |
138 |
); |
139 |
} |
140 |
|
141 |
public boolean isCanceled() { |
142 |
return this.isCanceled; |
143 |
} |
144 |
|
145 |
public JDBCServerExplorerParameters getServerExplorerParameters() {
|
146 |
return this.jdbcServerExplorer.getServerExplorerParameters(); |
147 |
} |
148 |
|
149 |
public String getConnectionName() { |
150 |
return this.jdbcServerExplorer.getConnectionName(); |
151 |
} |
152 |
|
153 |
} |
154 |
|