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 @ 44297
History | View | Annotate | Download (5.16 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | 41633 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
11 | 41633 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
16 | 41633 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
21 | 41633 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.geodb.vectorialdb.wizard; |
||
25 | |||
26 | 42616 | jjdelcerro | import java.awt.BorderLayout; |
27 | 40435 | jjdelcerro | import java.awt.event.ActionEvent; |
28 | import java.awt.event.ActionListener; |
||
29 | 41633 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
30 | 42616 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
31 | import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
||
32 | 41633 | jjdelcerro | 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 | 40435 | jjdelcerro | |
39 | import org.slf4j.Logger; |
||
40 | import org.slf4j.LoggerFactory; |
||
41 | |||
42 | |||
43 | |||
44 | 41633 | jjdelcerro | |
45 | 42616 | jjdelcerro | public class VectorialDBConnectionParamsDialog extends VectorialDBConnectionParamsDialogView { |
46 | 41633 | jjdelcerro | |
47 | 40435 | jjdelcerro | private static final long serialVersionUID = -5493563028200403559L; |
48 | |||
49 | private static final Logger LOG = LoggerFactory |
||
50 | 41633 | jjdelcerro | .getLogger(VectorialDBConnectionParamsDialog.class); |
51 | 40435 | jjdelcerro | |
52 | 41633 | jjdelcerro | private boolean isCanceled = false; |
53 | 42616 | jjdelcerro | private JDBCConnectionPanel jdbcServerExplorer;
|
54 | 40435 | jjdelcerro | |
55 | public VectorialDBConnectionParamsDialog() {
|
||
56 | 41633 | jjdelcerro | initComponents(); |
57 | 40435 | jjdelcerro | } |
58 | 41633 | jjdelcerro | |
59 | private void initComponents() { |
||
60 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
61 | 42616 | jjdelcerro | this.btnAdvanced.setText(i18nManager.getTranslation("advanced")); |
62 | this.btnAdvanced.addActionListener(new ActionListener() { |
||
63 | @Override
|
||
64 | 41633 | jjdelcerro | public void actionPerformed(ActionEvent ae) { |
65 | doAdvanced(); |
||
66 | 40435 | jjdelcerro | } |
67 | 41633 | jjdelcerro | }); |
68 | 42616 | jjdelcerro | this.btnAcept.setText(i18nManager.getTranslation("ok")); |
69 | this.btnAcept.addActionListener(new ActionListener() { |
||
70 | @Override
|
||
71 | 41633 | jjdelcerro | public void actionPerformed(ActionEvent ae) { |
72 | doAcept(); |
||
73 | 41627 | jjdelcerro | } |
74 | 41633 | jjdelcerro | }); |
75 | 42616 | jjdelcerro | this.btnCancel.setText(i18nManager.getTranslation("cancel")); |
76 | this.btnCancel.addActionListener(new ActionListener() { |
||
77 | @Override
|
||
78 | 41633 | jjdelcerro | public void actionPerformed(ActionEvent ae) { |
79 | doCancel(); |
||
80 | 40435 | jjdelcerro | } |
81 | 41633 | jjdelcerro | }); |
82 | 42046 | jbadia | |
83 | 42616 | jjdelcerro | this.btnDelete.setText(i18nManager.getTranslation("del")); |
84 | this.btnDelete.addActionListener(new ActionListener() { |
||
85 | @Override
|
||
86 | 42046 | jbadia | public void actionPerformed(ActionEvent ae) { |
87 | doDelete(); |
||
88 | } |
||
89 | }); |
||
90 | 42616 | jjdelcerro | this.jdbcServerExplorer = DALSwingLocator.getSwingManager().createJDBCConnectionPanel();
|
91 | this.containerJDBCConnectionPanel.setLayout(new BorderLayout()); |
||
92 | this.containerJDBCConnectionPanel.add(
|
||
93 | this.jdbcServerExplorer.asJComponent(),
|
||
94 | BorderLayout.CENTER
|
||
95 | ); |
||
96 | 40435 | jjdelcerro | } |
97 | 41633 | jjdelcerro | |
98 | protected void doAdvanced() { |
||
99 | JDBCServerExplorerParameters myParams = this.getServerExplorerParameters();
|
||
100 | 40435 | jjdelcerro | try {
|
101 | myParams.validate(); |
||
102 | } catch (Exception e) { |
||
103 | // ignore... only for fill default values
|
||
104 | } |
||
105 | 41633 | jjdelcerro | |
106 | 40435 | jjdelcerro | try {
|
107 | DynObjectEditor editor = new DynObjectEditor(myParams);
|
||
108 | editor.editObject(true);
|
||
109 | 41633 | jjdelcerro | this.jdbcServerExplorer.setServerExplorerParameters(myParams);
|
110 | 40435 | jjdelcerro | } catch (ServiceException ex) {
|
111 | LOG.error("Error creating a Swing component for the DynObject: "
|
||
112 | 41627 | jjdelcerro | + myParams, ex); |
113 | 40435 | jjdelcerro | } |
114 | } |
||
115 | 41633 | jjdelcerro | |
116 | protected void doAcept() { |
||
117 | this.isCanceled = false; |
||
118 | this.setVisible(false); |
||
119 | 40435 | jjdelcerro | } |
120 | 41633 | jjdelcerro | |
121 | protected void doCancel() { |
||
122 | this.isCanceled = true; |
||
123 | this.setVisible(false); |
||
124 | 40435 | jjdelcerro | } |
125 | 41633 | jjdelcerro | |
126 | 42046 | jbadia | protected void doDelete() { |
127 | 43377 | jjdelcerro | this.jdbcServerExplorer.delete();
|
128 | 42046 | jbadia | this.jdbcServerExplorer.clear();
|
129 | } |
||
130 | |||
131 | 41633 | jjdelcerro | 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 | 40435 | jjdelcerro | } |
140 | 41633 | jjdelcerro | |
141 | public boolean isCanceled() { |
||
142 | return this.isCanceled; |
||
143 | 40435 | jjdelcerro | } |
144 | 41633 | jjdelcerro | |
145 | public JDBCServerExplorerParameters getServerExplorerParameters() {
|
||
146 | return this.jdbcServerExplorer.getServerExplorerParameters(); |
||
147 | 40435 | jjdelcerro | } |
148 | 41633 | jjdelcerro | |
149 | 40435 | jjdelcerro | public String getConnectionName() { |
150 | 41633 | jjdelcerro | return this.jdbcServerExplorer.getConnectionName(); |
151 | 40435 | jjdelcerro | } |
152 | 41633 | jjdelcerro | |
153 | } |