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 @ 42046
History | View | Annotate | Download (4.66 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 |
|
77 |
this.butDelete.setText(i18nManager.getTranslation("del")); |
78 |
this.butDelete.addActionListener(new ActionListener() { |
79 |
public void actionPerformed(ActionEvent ae) { |
80 |
doDelete(); |
81 |
} |
82 |
}); |
83 |
this.setPreferredSize(new Dimension(550, 250)); |
84 |
} |
85 |
|
86 |
protected void doAdvanced() { |
87 |
JDBCServerExplorerParameters myParams = this.getServerExplorerParameters();
|
88 |
try {
|
89 |
myParams.validate(); |
90 |
} catch (Exception e) { |
91 |
// ignore... only for fill default values
|
92 |
} |
93 |
|
94 |
try {
|
95 |
DynObjectEditor editor = new DynObjectEditor(myParams);
|
96 |
editor.editObject(true);
|
97 |
this.jdbcServerExplorer.setServerExplorerParameters(myParams);
|
98 |
} catch (ServiceException ex) {
|
99 |
LOG.error("Error creating a Swing component for the DynObject: "
|
100 |
+ myParams, ex); |
101 |
} |
102 |
} |
103 |
|
104 |
protected void doAcept() { |
105 |
this.isCanceled = false; |
106 |
this.setVisible(false); |
107 |
} |
108 |
|
109 |
protected void doCancel() { |
110 |
this.isCanceled = true; |
111 |
this.setVisible(false); |
112 |
} |
113 |
|
114 |
protected void doDelete() { |
115 |
this.jdbcServerExplorer.clear();
|
116 |
this.jdbcServerExplorer.delete();
|
117 |
} |
118 |
|
119 |
public void showDialog() { |
120 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
121 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
122 |
winmgr.showWindow( |
123 |
this,
|
124 |
i18nManager.getTranslation("_Connection_parameters"),
|
125 |
WindowManager.MODE.DIALOG |
126 |
); |
127 |
} |
128 |
|
129 |
public boolean isCanceled() { |
130 |
return this.isCanceled; |
131 |
} |
132 |
|
133 |
public JDBCServerExplorerParameters getServerExplorerParameters() {
|
134 |
return this.jdbcServerExplorer.getServerExplorerParameters(); |
135 |
} |
136 |
|
137 |
public String getConnectionName() { |
138 |
return this.jdbcServerExplorer.getConnectionName(); |
139 |
} |
140 |
|
141 |
} |
142 |
|