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 | 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 | 41633 | jjdelcerro | import java.awt.Dimension; |
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 | 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 | 40435 | jjdelcerro | |
37 | import org.slf4j.Logger; |
||
38 | import org.slf4j.LoggerFactory; |
||
39 | |||
40 | |||
41 | |||
42 | 41633 | jjdelcerro | |
43 | public class VectorialDBConnectionParamsDialog extends VectorialDBConnectionParamsDialogLayout { |
||
44 | |||
45 | 40435 | jjdelcerro | private static final long serialVersionUID = -5493563028200403559L; |
46 | |||
47 | private static final Logger LOG = LoggerFactory |
||
48 | 41633 | jjdelcerro | .getLogger(VectorialDBConnectionParamsDialog.class); |
49 | 40435 | jjdelcerro | |
50 | 41633 | jjdelcerro | private boolean isCanceled = false; |
51 | 40435 | jjdelcerro | |
52 | public VectorialDBConnectionParamsDialog() {
|
||
53 | 41633 | jjdelcerro | initComponents(); |
54 | 40435 | jjdelcerro | } |
55 | 41633 | jjdelcerro | |
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 | 40435 | jjdelcerro | } |
63 | 41633 | jjdelcerro | }); |
64 | this.butAcept.setText(i18nManager.getTranslation("ok")); |
||
65 | this.butAcept.addActionListener(new ActionListener() { |
||
66 | public void actionPerformed(ActionEvent ae) { |
||
67 | doAcept(); |
||
68 | 41627 | jjdelcerro | } |
69 | 41633 | jjdelcerro | }); |
70 | this.butCancel.setText(i18nManager.getTranslation("cancel")); |
||
71 | this.butCancel.addActionListener(new ActionListener() { |
||
72 | public void actionPerformed(ActionEvent ae) { |
||
73 | doCancel(); |
||
74 | 40435 | jjdelcerro | } |
75 | 41633 | jjdelcerro | }); |
76 | this.setPreferredSize(new Dimension(550, 250)); |
||
77 | 40435 | jjdelcerro | } |
78 | 41633 | jjdelcerro | |
79 | protected void doAdvanced() { |
||
80 | JDBCServerExplorerParameters myParams = this.getServerExplorerParameters();
|
||
81 | 40435 | jjdelcerro | try {
|
82 | myParams.validate(); |
||
83 | } catch (Exception e) { |
||
84 | // ignore... only for fill default values
|
||
85 | } |
||
86 | 41633 | jjdelcerro | |
87 | 40435 | jjdelcerro | try {
|
88 | DynObjectEditor editor = new DynObjectEditor(myParams);
|
||
89 | editor.editObject(true);
|
||
90 | 41633 | jjdelcerro | this.jdbcServerExplorer.setServerExplorerParameters(myParams);
|
91 | 40435 | jjdelcerro | } catch (ServiceException ex) {
|
92 | LOG.error("Error creating a Swing component for the DynObject: "
|
||
93 | 41627 | jjdelcerro | + myParams, ex); |
94 | 40435 | jjdelcerro | } |
95 | } |
||
96 | 41633 | jjdelcerro | |
97 | protected void doAcept() { |
||
98 | this.isCanceled = false; |
||
99 | this.setVisible(false); |
||
100 | 40435 | jjdelcerro | } |
101 | 41633 | jjdelcerro | |
102 | protected void doCancel() { |
||
103 | this.isCanceled = true; |
||
104 | this.setVisible(false); |
||
105 | 40435 | jjdelcerro | } |
106 | 41633 | jjdelcerro | |
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 | 40435 | jjdelcerro | } |
116 | 41633 | jjdelcerro | |
117 | public boolean isCanceled() { |
||
118 | return this.isCanceled; |
||
119 | 40435 | jjdelcerro | } |
120 | 41633 | jjdelcerro | |
121 | public JDBCServerExplorerParameters getServerExplorerParameters() {
|
||
122 | return this.jdbcServerExplorer.getServerExplorerParameters(); |
||
123 | 40435 | jjdelcerro | } |
124 | 41633 | jjdelcerro | |
125 | 40435 | jjdelcerro | public String getConnectionName() { |
126 | 41633 | jjdelcerro | return this.jdbcServerExplorer.getConnectionName(); |
127 | 40435 | jjdelcerro | } |
128 | 41633 | jjdelcerro | |
129 | } |