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