Revision 35044
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/ExtDB_Spatial.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package org.gvsig.geodb; |
|
44 |
|
|
45 |
import org.gvsig.about.AboutManager; |
|
46 |
import org.gvsig.about.AboutParticipant; |
|
47 |
import org.gvsig.andami.plugins.Extension; |
|
48 |
import org.gvsig.app.ApplicationLocator; |
|
49 |
import org.gvsig.app.ApplicationManager; |
|
50 |
import org.gvsig.app.extension.AddLayer; |
|
51 |
import org.gvsig.geodb.vectorialdb.wizard.WizardDB; |
|
52 |
import org.gvsig.geodb.vectorialdb.wizard.WizardVectorialDB; |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
/** |
|
57 |
* This extension adds the export-to-oracle button. |
|
58 |
* |
|
59 |
* @author jldominguez |
|
60 |
* |
|
61 |
*/ |
|
62 |
public class ExtDB_Spatial extends Extension { |
|
63 |
|
|
64 |
public void initialize() { |
|
65 |
//do nothing |
|
66 |
} |
|
67 |
|
|
68 |
public void execute(String actionCommand) { |
|
69 |
//do nothing |
|
70 |
} |
|
71 |
|
|
72 |
public boolean isEnabled() { |
|
73 |
return isVisible(); |
|
74 |
|
|
75 |
// return true; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Is visible when there is one vector layer selected |
|
80 |
*/ |
|
81 |
public boolean isVisible() { |
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public void postInitialize() { |
|
87 |
super.postInitialize(); |
|
88 |
addAboutInfo(); |
|
89 |
|
|
90 |
ApplicationLocator.getManager().registerAddTableWizard("DB", |
|
91 |
"DB Tables", WizardDB.class); |
|
92 |
AddLayer.addWizard(WizardVectorialDB.class); |
|
93 |
} |
|
94 |
|
|
95 |
private void addAboutInfo() { |
|
96 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
97 |
|
|
98 |
AboutManager about = application.getAbout(); |
|
99 |
about.addDeveloper("PRODEVELOP", getClass().getClassLoader() |
|
100 |
.getResource("prodevelop.html"), 2); |
|
101 |
|
|
102 |
AboutParticipant participant = about.getDeveloper("PRODEVELOP"); |
|
103 |
participant.addContribution( |
|
104 |
"GeoDB", |
|
105 |
"Soporte para pool de conexiones con BBDD", |
|
106 |
2006,1,1, |
|
107 |
2007,12,31 |
|
108 |
); |
|
109 |
} |
|
110 |
|
|
111 |
} |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/ConnectionSettings.java | ||
---|---|---|
1 |
package org.gvsig.geodb.vectorialdb; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DALLocator; |
|
4 |
import org.gvsig.fmap.dal.DataManager; |
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
7 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
|
8 |
|
|
9 |
|
|
10 |
/** |
|
11 |
* @author Fernando Gonz?lez Cort?s |
|
12 |
*/ |
|
13 |
public class ConnectionSettings { |
|
14 |
private String host; |
|
15 |
private String port; |
|
16 |
private String db; |
|
17 |
private String schema; |
|
18 |
private String driver; |
|
19 |
private String user; |
|
20 |
private String name; |
|
21 |
private String passw; |
|
22 |
|
|
23 |
public String getDb() { |
|
24 |
return db; |
|
25 |
} |
|
26 |
public void setDb(String db) { |
|
27 |
this.db = db; |
|
28 |
} |
|
29 |
public String getDriver() { |
|
30 |
return driver; |
|
31 |
} |
|
32 |
public void setDriver(String driver) { |
|
33 |
this.driver = driver; |
|
34 |
} |
|
35 |
public String getHost() { |
|
36 |
return host; |
|
37 |
} |
|
38 |
public void setHost(String host) { |
|
39 |
this.host = host; |
|
40 |
} |
|
41 |
public String getPort() { |
|
42 |
return port; |
|
43 |
} |
|
44 |
public void setPort(String port) { |
|
45 |
this.port = port; |
|
46 |
} |
|
47 |
public String getUser() { |
|
48 |
return user; |
|
49 |
} |
|
50 |
public void setUser(String user) { |
|
51 |
this.user = user; |
|
52 |
} |
|
53 |
public void setName(String name) { |
|
54 |
this.name = name; |
|
55 |
} |
|
56 |
public String getName() { |
|
57 |
return name; |
|
58 |
} |
|
59 |
|
|
60 |
public String toString(){ |
|
61 |
return host+","+port+","+db+","+driver+","+user+","+name; |
|
62 |
} |
|
63 |
|
|
64 |
public void setFromString(String str) { |
|
65 |
String[] values = str.split(","); |
|
66 |
host = values[0]; |
|
67 |
port = values[1]; |
|
68 |
db = values[2]; |
|
69 |
driver = values[3]; |
|
70 |
user = values[4]; |
|
71 |
name = values[5]; |
|
72 |
if (values.length == 7) { |
|
73 |
passw = values[6]; |
|
74 |
} |
|
75 |
} |
|
76 |
public String getPassw() { |
|
77 |
return passw; |
|
78 |
} |
|
79 |
public void setPassw(String passw) { |
|
80 |
this.passw = passw; |
|
81 |
} |
|
82 |
public String getConnectionString(){ |
|
83 |
DataManager dm=DALLocator.getDataManager(); |
|
84 |
try { |
|
85 |
DBParameters dsp=(DBParameters)dm.createStoreParameters(getDriver()); |
|
86 |
} catch (InitializeException e) { |
|
87 |
// TODO Auto-generated catch block |
|
88 |
e.printStackTrace(); |
|
89 |
} catch (ProviderNotRegisteredException e) { |
|
90 |
// TODO Auto-generated catch block |
|
91 |
e.printStackTrace(); |
|
92 |
} |
|
93 |
|
|
94 |
String connectionString = "";//vecDriver.getConnectionStringBeginning() + "//" + getHost(); |
|
95 |
|
|
96 |
connectionString += (":" + getPort()); |
|
97 |
|
|
98 |
connectionString += ("/" + getDb()); |
|
99 |
|
|
100 |
return connectionString; |
|
101 |
} |
|
102 |
public String getSchema() { |
|
103 |
return schema; |
|
104 |
} |
|
105 |
public void setSchema(String schema) { |
|
106 |
this.schema = schema; |
|
107 |
} |
|
108 |
} |
|
0 | 109 |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/FieldsListItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
44 |
|
|
45 |
import javax.swing.JCheckBox; |
|
46 |
|
|
47 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* Used to instantiate field list items. Shows the database dependent type name. |
|
52 |
* |
|
53 |
* @author jldominguez |
|
54 |
* |
|
55 |
*/ |
|
56 |
public class FieldsListItem extends JCheckBox { |
|
57 |
private String name = "[No name]"; |
|
58 |
private String type = "[No type]"; |
|
59 |
|
|
60 |
public FieldsListItem(FeatureAttributeDescriptor descriptor) { |
|
61 |
|
|
62 |
name = descriptor.getName(); |
|
63 |
type = descriptor.getDataTypeName(); |
|
64 |
setText(toString()); |
|
65 |
setSelected(true); |
|
66 |
} |
|
67 |
|
|
68 |
public String toString() { |
|
69 |
return name + " [" + type + "]"; |
|
70 |
} |
|
71 |
|
|
72 |
public String getName() { |
|
73 |
return name; |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/FieldComboItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* Utility class to deal with combo boxes. |
|
48 |
* |
|
49 |
* @author jldominguez |
|
50 |
* |
|
51 |
*/ |
|
52 |
public class FieldComboItem { |
|
53 |
private String name = ""; |
|
54 |
|
|
55 |
public FieldComboItem(String _name) { |
|
56 |
name = _name; |
|
57 |
} |
|
58 |
|
|
59 |
public String toString() { |
|
60 |
return name; |
|
61 |
} |
|
62 |
} |
|
0 | 63 |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/VectorialDBConnectionParamsDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
44 |
|
|
45 |
import java.awt.Color; |
|
46 |
import java.awt.event.ActionEvent; |
|
47 |
import java.awt.event.ActionListener; |
|
48 |
import java.awt.event.KeyEvent; |
|
49 |
import java.awt.event.KeyListener; |
|
50 |
import java.util.Iterator; |
|
51 |
import java.util.List; |
|
52 |
|
|
53 |
import javax.swing.JButton; |
|
54 |
import javax.swing.JCheckBox; |
|
55 |
import javax.swing.JComboBox; |
|
56 |
import javax.swing.JLabel; |
|
57 |
import javax.swing.JPanel; |
|
58 |
import javax.swing.JPasswordField; |
|
59 |
import javax.swing.JTextField; |
|
60 |
|
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 |
|
|
64 |
import org.gvsig.andami.PluginServices; |
|
65 |
import org.gvsig.andami.messages.NotificationManager; |
|
66 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
67 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
68 |
import org.gvsig.fmap.dal.DALLocator; |
|
69 |
import org.gvsig.fmap.dal.DataManager; |
|
70 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
71 |
import org.gvsig.fmap.dal.exception.DataException; |
|
72 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
73 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
74 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor; |
|
75 |
import org.gvsig.tools.service.ServiceException; |
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
/** |
|
80 |
* Lets the user input the connection parameters. |
|
81 |
* |
|
82 |
* @author jldominguez |
|
83 |
* |
|
84 |
*/ |
|
85 |
public class VectorialDBConnectionParamsDialog extends JPanel implements IWindow, |
|
86 |
ActionListener, KeyListener { |
|
87 |
|
|
88 |
private static final long serialVersionUID = -5493563028200403559L; |
|
89 |
|
|
90 |
private static final Logger LOG = LoggerFactory |
|
91 |
.getLogger(VectorialDBConnectionParamsDialog.class); |
|
92 |
|
|
93 |
private WindowInfo winfo = new WindowInfo(8); // MODAL only |
|
94 |
private JButton cancelButton = null; |
|
95 |
private JButton okButton = null; |
|
96 |
private JButton advancedButton = null; |
|
97 |
private JPanel paramsPanel = null; |
|
98 |
private JComboBox driverComboBox = null; |
|
99 |
private JTextField portTextField = null; |
|
100 |
private JTextField dbTextField = null; |
|
101 |
private JTextField userTextField = null; |
|
102 |
private JPasswordField passwordField = null; |
|
103 |
private JLabel driverLabel = null; |
|
104 |
private JLabel portLabel = null; |
|
105 |
private JLabel dbLabel = null; |
|
106 |
private JLabel dbLabelWarning = null; |
|
107 |
private JLabel userLabel = null; |
|
108 |
private JLabel pwLabel = null; |
|
109 |
private boolean okPressed = false; |
|
110 |
private JTextField urlTextField = null; |
|
111 |
private JLabel urlLabel = null; |
|
112 |
private JCheckBox connectedCheckBox = null; |
|
113 |
private JLabel connectedLabel = null; |
|
114 |
private JLabel connNameLabel = null; |
|
115 |
private JTextField connNameTextField = null; |
|
116 |
|
|
117 |
private DBServerExplorerParameters params = null; |
|
118 |
|
|
119 |
/** |
|
120 |
* This method initializes |
|
121 |
* |
|
122 |
*/ |
|
123 |
public VectorialDBConnectionParamsDialog() { |
|
124 |
super(); |
|
125 |
initialize(); |
|
126 |
} |
|
127 |
|
|
128 |
public void showDialog() { |
|
129 |
PluginServices.getMDIManager().addWindow(this); |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* This method initializes this |
|
134 |
* |
|
135 |
*/ |
|
136 |
private void initialize() { |
|
137 |
winfo.setWidth(370); |
|
138 |
winfo.setHeight(317 - 25); |
|
139 |
winfo.setTitle(PluginServices.getText(this, "connection_parameters")); |
|
140 |
|
|
141 |
this.setSize(new java.awt.Dimension(360, 329)); |
|
142 |
this.setLayout(null); |
|
143 |
this.add(getCancelButton(), null); |
|
144 |
this.add(getOkButton(), null); |
|
145 |
this.add(getAdvancedButton(), null); |
|
146 |
this.add(getParamsPanel(), null); |
|
147 |
} |
|
148 |
|
|
149 |
public WindowInfo getWindowInfo() { |
|
150 |
return winfo; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* This method initializes cancelButton |
|
155 |
* |
|
156 |
* @return javax.swing.JButton |
|
157 |
*/ |
|
158 |
private JButton getCancelButton() { |
|
159 |
if (cancelButton == null) { |
|
160 |
cancelButton = new JButton(); |
|
161 |
cancelButton.setText(PluginServices.getText(this, "cancel")); |
|
162 |
cancelButton.addActionListener(this); |
|
163 |
cancelButton.setBounds(new java.awt.Rectangle(124, 292, 90, 26)); |
|
164 |
} |
|
165 |
|
|
166 |
return cancelButton; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* This method initializes okButton |
|
171 |
* |
|
172 |
* @return javax.swing.JButton |
|
173 |
*/ |
|
174 |
private JButton getOkButton() { |
|
175 |
if (okButton == null) { |
|
176 |
okButton = new JButton(); |
|
177 |
okButton.setText(PluginServices.getText(this, "ok")); |
|
178 |
okButton.addActionListener(this); |
|
179 |
okButton.setBounds(new java.awt.Rectangle(30, 292, 90, 26)); |
|
180 |
} |
|
181 |
|
|
182 |
return okButton; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* This method initializes okButton |
|
187 |
* |
|
188 |
* @return javax.swing.JButton |
|
189 |
*/ |
|
190 |
private JButton getAdvancedButton() { |
|
191 |
if (advancedButton == null) { |
|
192 |
advancedButton = new JButton(); |
|
193 |
advancedButton.setText(PluginServices.getText(this, "advanced")); |
|
194 |
advancedButton.addActionListener(this); |
|
195 |
advancedButton.setBounds(new java.awt.Rectangle(218, 292, 90, 26)); |
|
196 |
} |
|
197 |
|
|
198 |
return advancedButton; |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* This method initializes paramsPanel |
|
203 |
* |
|
204 |
* @return javax.swing.JPanel |
|
205 |
*/ |
|
206 |
private JPanel getParamsPanel() { |
|
207 |
if (paramsPanel == null) { |
|
208 |
connNameLabel = new JLabel(); |
|
209 |
connNameLabel.setBounds(new java.awt.Rectangle(10, 30, 141, 21)); |
|
210 |
connNameLabel.setText(PluginServices.getText(this, "connection_name") + |
|
211 |
":"); |
|
212 |
connectedLabel = new JLabel(); |
|
213 |
connectedLabel.setBounds(new java.awt.Rectangle(10, 247, 141, 21)); |
|
214 |
connectedLabel.setText(PluginServices.getText(this, "connected") + |
|
215 |
":"); |
|
216 |
urlLabel = new JLabel(); |
|
217 |
urlLabel.setBounds(new java.awt.Rectangle(10, 80, 141, 21)); |
|
218 |
urlLabel.setText(PluginServices.getText(this, "server_url") + ":"); |
|
219 |
pwLabel = new JLabel(); |
|
220 |
pwLabel.setBounds(new java.awt.Rectangle(10, 222, 141, 21)); |
|
221 |
pwLabel.setText(PluginServices.getText(this, "password") + ":"); |
|
222 |
userLabel = new JLabel(); |
|
223 |
userLabel.setBounds(new java.awt.Rectangle(10, 197, 141, 21)); |
|
224 |
userLabel.setText(PluginServices.getText(this, "user") + ":"); |
|
225 |
dbLabel = new JLabel(); |
|
226 |
dbLabel.setBounds(new java.awt.Rectangle(10, 130, 141, 21)); |
|
227 |
dbLabel.setText(PluginServices.getText(this, "database_name") + |
|
228 |
":"); |
|
229 |
dbLabelWarning = new JLabel(); |
|
230 |
dbLabelWarning.setBounds(new java.awt.Rectangle(10, 155, 310, 41)); |
|
231 |
dbLabelWarning.setText(PluginServices.getText(this, "warning_you_must_input_the_exact_name_this_difference_between_capital_letters_and_small_letters") |
|
232 |
); |
|
233 |
|
|
234 |
portLabel = new JLabel(); |
|
235 |
portLabel.setBounds(new java.awt.Rectangle(10, 105, 141, 21)); |
|
236 |
portLabel.setText(PluginServices.getText(this, "port") + ":"); |
|
237 |
driverLabel = new JLabel(); |
|
238 |
driverLabel.setBounds(new java.awt.Rectangle(10, 55, 141, 21)); |
|
239 |
driverLabel.setText(PluginServices.getText(this, "driver") + ":"); |
|
240 |
paramsPanel = new JPanel(); |
|
241 |
paramsPanel.setBounds(new java.awt.Rectangle(10, 10, 336, 273)); |
|
242 |
paramsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
|
243 |
null, PluginServices.getText(this, "connection_params"), |
|
244 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
245 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
246 |
paramsPanel.setLayout(null); |
|
247 |
paramsPanel.add(getPortTextField(), null); |
|
248 |
paramsPanel.add(getDriverComboBox(), null); |
|
249 |
paramsPanel.add(getDbTextField(), null); |
|
250 |
paramsPanel.add(getUserTextField(), null); |
|
251 |
paramsPanel.add(getPasswordField(), null); |
|
252 |
paramsPanel.add(driverLabel, null); |
|
253 |
paramsPanel.add(portLabel, null); |
|
254 |
paramsPanel.add(dbLabel, null); |
|
255 |
paramsPanel.add(dbLabelWarning, null); |
|
256 |
paramsPanel.add(userLabel, null); |
|
257 |
paramsPanel.add(pwLabel, null); |
|
258 |
paramsPanel.add(getUrlTextArea(), null); |
|
259 |
paramsPanel.add(urlLabel, null); |
|
260 |
paramsPanel.add(getConnectedCheckBox(), null); |
|
261 |
paramsPanel.add(connectedLabel, null); |
|
262 |
paramsPanel.add(connNameLabel, null); |
|
263 |
paramsPanel.add(getConnNameTextField(), null); |
|
264 |
} |
|
265 |
|
|
266 |
return paramsPanel; |
|
267 |
} |
|
268 |
|
|
269 |
/** |
|
270 |
* This method initializes driverComboBox |
|
271 |
* |
|
272 |
* @return javax.swing.JComboBox |
|
273 |
*/ |
|
274 |
private JComboBox getDriverComboBox() { |
|
275 |
if (driverComboBox == null) { |
|
276 |
driverComboBox = new JComboBox(); |
|
277 |
driverComboBox.addActionListener(this); |
|
278 |
DataManager dm = DALLocator.getDataManager(); |
|
279 |
List<String> explorers = dm.getExplorerProviders(); |
|
280 |
Iterator<String> iter = explorers.iterator(); |
|
281 |
String expName; |
|
282 |
|
|
283 |
DataServerExplorerParameters params; |
|
284 |
while (iter.hasNext()) { |
|
285 |
expName = iter.next(); |
|
286 |
try { |
|
287 |
params = dm.createServerExplorerParameters(expName); |
|
288 |
} catch (DataException e) { |
|
289 |
NotificationManager.addWarning(PluginServices.getText(null, |
|
290 |
"DataExplorer_parameters_error") |
|
291 |
+ ": " + expName, e); |
|
292 |
continue; |
|
293 |
} |
|
294 |
if (params instanceof DBServerExplorerParameters) { |
|
295 |
DBServerExplorerParameters dbParams = (DBServerExplorerParameters) params; |
|
296 |
driverComboBox.addItem(new DriverComboBoxItem( |
|
297 |
dbParams)); |
|
298 |
} |
|
299 |
|
|
300 |
} |
|
301 |
|
|
302 |
driverComboBox.setBounds(new java.awt.Rectangle(155, 55, 166, 21)); |
|
303 |
|
|
304 |
} |
|
305 |
|
|
306 |
return driverComboBox; |
|
307 |
} |
|
308 |
|
|
309 |
private class DriverComboBoxItem { |
|
310 |
private DBServerExplorerParameters params; |
|
311 |
|
|
312 |
public DriverComboBoxItem(DBServerExplorerParameters dbParams) { |
|
313 |
this.params = dbParams; |
|
314 |
} |
|
315 |
|
|
316 |
public String toString() { |
|
317 |
// FIXME |
|
318 |
return params.getExplorerName(); |
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* This method initializes portTextField |
|
324 |
* |
|
325 |
* @return javax.swing.JTextField |
|
326 |
*/ |
|
327 |
private JTextField getPortTextField() { |
|
328 |
if (portTextField == null) { |
|
329 |
portTextField = new JTextField(); |
|
330 |
portTextField.addKeyListener(this); |
|
331 |
portTextField.setBounds(new java.awt.Rectangle(155, 105, 166, 21)); |
|
332 |
} |
|
333 |
|
|
334 |
return portTextField; |
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* This method initializes dbTextField |
|
339 |
* |
|
340 |
* @return javax.swing.JTextField |
|
341 |
*/ |
|
342 |
private JTextField getDbTextField() { |
|
343 |
if (dbTextField == null) { |
|
344 |
dbTextField = new JTextField(); |
|
345 |
dbTextField.addKeyListener(this); |
|
346 |
dbTextField.setBounds(new java.awt.Rectangle(155, 130, 166, 21)); |
|
347 |
} |
|
348 |
|
|
349 |
return dbTextField; |
|
350 |
} |
|
351 |
|
|
352 |
/** |
|
353 |
* This method initializes userTextField |
|
354 |
* |
|
355 |
* @return javax.swing.JTextField |
|
356 |
*/ |
|
357 |
private JTextField getUserTextField() { |
|
358 |
if (userTextField == null) { |
|
359 |
userTextField = new JTextField(); |
|
360 |
userTextField.addKeyListener(this); |
|
361 |
userTextField.setBounds(new java.awt.Rectangle(155, 197, 166, 21)); |
|
362 |
} |
|
363 |
|
|
364 |
return userTextField; |
|
365 |
} |
|
366 |
|
|
367 |
/** |
|
368 |
* This method initializes passwordField |
|
369 |
* |
|
370 |
* @return javax.swing.JPasswordField |
|
371 |
*/ |
|
372 |
private JPasswordField getPasswordField() { |
|
373 |
if (passwordField == null) { |
|
374 |
passwordField = new JPasswordField(); |
|
375 |
passwordField.addKeyListener(this); |
|
376 |
passwordField.setBounds(new java.awt.Rectangle(155, 222, 166, 21)); |
|
377 |
} |
|
378 |
|
|
379 |
return passwordField; |
|
380 |
} |
|
381 |
|
|
382 |
// private String[] getDriverNames() { |
|
383 |
// Class[] classes = new Class[] { IVectorialDatabaseDriver.class }; |
|
384 |
// |
|
385 |
// ArrayList ret = new ArrayList(); |
|
386 |
// String[] driverNames = LayerFactory.getDM().getDriverNames(); |
|
387 |
// |
|
388 |
// for (int i = 0; i < driverNames.length; i++) { |
|
389 |
// for (int j = 0; j < classes.length; j++) { |
|
390 |
// if (LayerFactory.getDM().isA(driverNames[i], classes[j])) { |
|
391 |
// ret.add(driverNames[i]); |
|
392 |
// } |
|
393 |
// } |
|
394 |
// } |
|
395 |
// |
|
396 |
// return (String[]) ret.toArray(new String[0]); |
|
397 |
// } |
|
398 |
|
|
399 |
public void actionPerformed(ActionEvent arg0) { |
|
400 |
Object src = arg0.getSource(); |
|
401 |
|
|
402 |
if (src == connectedCheckBox) { |
|
403 |
if (connectedCheckBox.isSelected()) { |
|
404 |
passwordField.setEnabled(true); |
|
405 |
passwordField.setBackground(Color.WHITE); |
|
406 |
} |
|
407 |
else { |
|
408 |
passwordField.setText(""); |
|
409 |
passwordField.setEnabled(false); |
|
410 |
passwordField.setBackground(Color.LIGHT_GRAY); |
|
411 |
} |
|
412 |
} |
|
413 |
|
|
414 |
if (src == okButton) { |
|
415 |
okPressed = true; |
|
416 |
PluginServices.getMDIManager().closeWindow(this); |
|
417 |
|
|
418 |
return; |
|
419 |
} |
|
420 |
|
|
421 |
if (src == cancelButton) { |
|
422 |
okPressed = false; |
|
423 |
PluginServices.getMDIManager().closeWindow(this); |
|
424 |
|
|
425 |
return; |
|
426 |
} |
|
427 |
|
|
428 |
if (src == advancedButton) { |
|
429 |
DBServerExplorerParameters myParams = getParameters(); |
|
430 |
try { |
|
431 |
myParams.validate(); |
|
432 |
} catch (Exception e) { |
|
433 |
// ignore... only for fill default values |
|
434 |
} |
|
435 |
try { |
|
436 |
DynObjectEditor editor = new DynObjectEditor(myParams); |
|
437 |
editor.editObject(true); |
|
438 |
} catch (ServiceException ex) { |
|
439 |
LOG.error( |
|
440 |
"Error creating a Swing component for the DynObject: " |
|
441 |
+ myParams, ex); |
|
442 |
} |
|
443 |
|
|
444 |
return; |
|
445 |
} |
|
446 |
|
|
447 |
if (src == driverComboBox) { |
|
448 |
DBServerExplorerParameters params = ((DriverComboBoxItem) driverComboBox |
|
449 |
.getSelectedItem()).params; |
|
450 |
try { |
|
451 |
params.validate(); |
|
452 |
} catch (ValidateDataParametersException e) { |
|
453 |
} |
|
454 |
|
|
455 |
// try { |
|
456 |
// DataManager dm=DataManager.getManager(); |
|
457 |
// featureStore = (FeatureStore) dm.createDataStore()LayerFactory.getDM() |
|
458 |
// .getDriver(driverName); |
|
459 |
if (params.getPort() != null) { |
|
460 |
portTextField.setText(params.getPort() + ""); |
|
461 |
} else { |
|
462 |
portTextField.setText(""); |
|
463 |
} |
|
464 |
// } |
|
465 |
// catch (DriverLoadException e1) { |
|
466 |
// portTextField.setText(""); |
|
467 |
// } |
|
468 |
|
|
469 |
return; |
|
470 |
} |
|
471 |
} |
|
472 |
|
|
473 |
public boolean isOkPressed() { |
|
474 |
return okPressed; |
|
475 |
} |
|
476 |
|
|
477 |
public boolean hasToBeConnected() { |
|
478 |
return connectedCheckBox.isSelected(); |
|
479 |
} |
|
480 |
|
|
481 |
public String getConnectionDriverName() { |
|
482 |
return ((DriverComboBoxItem) driverComboBox.getSelectedItem()).params |
|
483 |
.getExplorerName(); |
|
484 |
} |
|
485 |
|
|
486 |
public String getConnectionServerUrl() { |
|
487 |
return urlTextField.getText(); |
|
488 |
} |
|
489 |
|
|
490 |
public String getConnectionPort() { |
|
491 |
return portTextField.getText(); |
|
492 |
} |
|
493 |
|
|
494 |
public String getConnectionDBName() { |
|
495 |
return dbTextField.getText(); |
|
496 |
} |
|
497 |
|
|
498 |
public String getConnectionUser() { |
|
499 |
return userTextField.getText(); |
|
500 |
} |
|
501 |
|
|
502 |
public String getConnectionPassword() { |
|
503 |
String resp = new String(passwordField.getPassword()); |
|
504 |
|
|
505 |
return resp; |
|
506 |
} |
|
507 |
|
|
508 |
private JTextField getUrlTextArea() { |
|
509 |
if (urlTextField == null) { |
|
510 |
urlTextField = new JTextField(); |
|
511 |
urlTextField.addKeyListener(this); |
|
512 |
urlTextField.setBounds(new java.awt.Rectangle(155, 80, 166, 21)); |
|
513 |
} |
|
514 |
|
|
515 |
return urlTextField; |
|
516 |
} |
|
517 |
|
|
518 |
/** |
|
519 |
* This method initializes connectedCheckBox |
|
520 |
* |
|
521 |
* @return javax.swing.JCheckBox |
|
522 |
*/ |
|
523 |
private JCheckBox getConnectedCheckBox() { |
|
524 |
if (connectedCheckBox == null) { |
|
525 |
connectedCheckBox = new JCheckBox(); |
|
526 |
connectedCheckBox.setSelected(true); |
|
527 |
connectedCheckBox.addActionListener(this); |
|
528 |
connectedCheckBox.setBounds(new java.awt.Rectangle(155, 247, 26, 21)); |
|
529 |
} |
|
530 |
|
|
531 |
return connectedCheckBox; |
|
532 |
} |
|
533 |
|
|
534 |
public String getConnectionName() { |
|
535 |
return getConnNameTextField().getText(); |
|
536 |
} |
|
537 |
|
|
538 |
/** |
|
539 |
* This method initializes connNameTextField |
|
540 |
* |
|
541 |
* @return javax.swing.JTextField |
|
542 |
*/ |
|
543 |
private JTextField getConnNameTextField() { |
|
544 |
if (connNameTextField == null) { |
|
545 |
connNameTextField = new JTextField(); |
|
546 |
connNameTextField.addKeyListener(this); |
|
547 |
connNameTextField.setBounds(new java.awt.Rectangle(155, 30, 166, 21)); |
|
548 |
} |
|
549 |
|
|
550 |
return connNameTextField; |
|
551 |
} |
|
552 |
|
|
553 |
public void keyPressed(KeyEvent e) { |
|
554 |
} |
|
555 |
|
|
556 |
public void keyReleased(KeyEvent e) { |
|
557 |
if (e.getKeyChar() != '\n') { |
|
558 |
return; |
|
559 |
} |
|
560 |
|
|
561 |
Object src = e.getSource(); |
|
562 |
|
|
563 |
if (src == passwordField) { |
|
564 |
ActionEvent aevt = new ActionEvent(okButton, |
|
565 |
ActionEvent.ACTION_PERFORMED, ""); |
|
566 |
actionPerformed(aevt); |
|
567 |
} |
|
568 |
else { |
|
569 |
if (src instanceof JTextField) { |
|
570 |
((JTextField) src).transferFocus(); |
|
571 |
} |
|
572 |
} |
|
573 |
} |
|
574 |
|
|
575 |
public void keyTyped(KeyEvent e) { |
|
576 |
} |
|
577 |
|
|
578 |
public void loadValues(DBServerExplorerParameters cwp) { |
|
579 |
if (cwp.getPort() != null){ |
|
580 |
getPortTextField().setText(cwp.getPort().toString()); |
|
581 |
} else{ |
|
582 |
getPortTextField().setText(""); |
|
583 |
} |
|
584 |
selectThisInDriverCombo(cwp.getExplorerName()); |
|
585 |
getDbTextField().setText(cwp.getDBName()); |
|
586 |
getUserTextField().setText(cwp.getUser()); |
|
587 |
|
|
588 |
if (cwp.getPassword() == null) { |
|
589 |
getPasswordField().setText(""); |
|
590 |
} |
|
591 |
else { |
|
592 |
getPasswordField().setText(cwp.getPassword()); |
|
593 |
} |
|
594 |
|
|
595 |
getUrlTextArea().setText(cwp.getHost()); |
|
596 |
|
|
597 |
// boolean connected = false; |
|
598 |
// |
|
599 |
// try { |
|
600 |
// connected = (cwp.getConnection() != null) && |
|
601 |
// (!cwp.getConnection().isClosed()); |
|
602 |
// } |
|
603 |
// catch (DBException e) { |
|
604 |
// LOG.error("While checking connection: " + e.getMessage()); |
|
605 |
// connected = false; |
|
606 |
// } |
|
607 |
|
|
608 |
// getConnectedCheckBox().setSelected(connected); |
|
609 |
getConnNameTextField().setText(cwp.getExplorerName()); |
|
610 |
} |
|
611 |
|
|
612 |
private void selectThisInDriverCombo(String drvName) { |
|
613 |
int size = getDriverComboBox().getItemCount(); |
|
614 |
int curSel = getDriverComboBox().getSelectedIndex(); |
|
615 |
|
|
616 |
for (int i = 0; i < size; i++) { |
|
617 |
DriverComboBoxItem item = (DriverComboBoxItem) getDriverComboBox() |
|
618 |
.getItemAt(i); |
|
619 |
|
|
620 |
if (item.params.getExplorerName().compareToIgnoreCase(drvName) == 0) { |
|
621 |
getDriverComboBox().setSelectedIndex(i); |
|
622 |
if (curSel != i) { |
|
623 |
this.params = null; |
|
624 |
} |
|
625 |
|
|
626 |
return; |
|
627 |
} |
|
628 |
} |
|
629 |
} |
|
630 |
|
|
631 |
public Object getWindowProfile() { |
|
632 |
return WindowInfo.DIALOG_PROFILE; |
|
633 |
} |
|
634 |
|
|
635 |
public DBServerExplorerParameters getParameters(){ |
|
636 |
if (params == null) { |
|
637 |
DriverComboBoxItem item = (DriverComboBoxItem) getDriverComboBox() |
|
638 |
.getItemAt(getDriverComboBox().getSelectedIndex()); |
|
639 |
params = (DBServerExplorerParameters) item.params.getCopy(); |
|
640 |
|
|
641 |
|
|
642 |
} |
|
643 |
String _host = getConnectionServerUrl(); |
|
644 |
String _port = getConnectionPort(); |
|
645 |
String _dbname = getConnectionDBName(); |
|
646 |
String _user = getConnectionUser(); |
|
647 |
String _pw = getConnectionPassword(); |
|
648 |
|
|
649 |
params.setHost(_host); |
|
650 |
if (_port.trim().length() != 0) { |
|
651 |
try { |
|
652 |
params.setPort(Integer.parseInt(_port)); |
|
653 |
} catch (NumberFormatException e) { |
|
654 |
NotificationManager.addError("Invalid port", e); |
|
655 |
} |
|
656 |
} |
|
657 |
params.setDBName(_dbname); |
|
658 |
params.setUser(_user); |
|
659 |
params.setPassword(_pw); |
|
660 |
|
|
661 |
return params; |
|
662 |
} |
|
663 |
|
|
664 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
0 | 665 |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/TablesListItem.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
44 |
|
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Iterator; |
|
47 |
|
|
48 |
import javax.swing.JCheckBox; |
|
49 |
|
|
50 |
import org.cresques.cts.IProjection; |
|
51 |
import org.gvsig.andami.messages.NotificationManager; |
|
52 |
import org.gvsig.app.addlayer.AddLayerDialog; |
|
53 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
|
54 |
import org.gvsig.fmap.dal.exception.DataException; |
|
55 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
56 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
57 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
58 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* Utility class that represents a table list item as a selectable check box. |
|
64 |
* |
|
65 |
* @author jldominguez |
|
66 |
* |
|
67 |
*/ |
|
68 |
public class TablesListItem extends JCheckBox { |
|
69 |
protected String tableName = ""; |
|
70 |
private UserSelectedFieldsPanel selectedFieldsPanel = null; |
|
71 |
protected WizardDB parent = null; |
|
72 |
private boolean activated = false; |
|
73 |
private CRSSelectPanel jPanelProj; |
|
74 |
protected DBStoreParameters parameters; |
|
75 |
protected DBServerExplorer explorer; |
|
76 |
protected UserTableSettingsPanel tableSettingsPanel = null; |
|
77 |
|
|
78 |
public TablesListItem(DBServerExplorer explorer, |
|
79 |
DBStoreParameters param, |
|
80 |
WizardDB _parent) { |
|
81 |
tableName = param.getTable(); |
|
82 |
setText(tableName); |
|
83 |
this.parameters = param; |
|
84 |
this.explorer=explorer; |
|
85 |
parent = _parent; |
|
86 |
} |
|
87 |
|
|
88 |
public void activate() { |
|
89 |
activated = true; |
|
90 |
selectedFieldsPanel.loadValues(); |
|
91 |
tableSettingsPanel.loadValues(); |
|
92 |
} |
|
93 |
|
|
94 |
public boolean isActivated() { |
|
95 |
return activated; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Tells whether this item prevents the wizard from being in a valid final state. |
|
100 |
* @return whether this item prevents the wizard from being in a valid final state. |
|
101 |
*/ |
|
102 |
public boolean disturbsWizardValidity() { |
|
103 |
if (isSelected()) { |
|
104 |
return (!hasValidValues()); |
|
105 |
} |
|
106 |
else { |
|
107 |
return false; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
private boolean hasValidValues() { |
|
112 |
return tableSettingsPanel.hasValidValues(); |
|
113 |
} |
|
114 |
|
|
115 |
public String toString() { |
|
116 |
return tableName; |
|
117 |
} |
|
118 |
|
|
119 |
public String getTableName() { |
|
120 |
return tableName; |
|
121 |
} |
|
122 |
|
|
123 |
public void setEnabledPanels(boolean b) { |
|
124 |
selectedFieldsPanel.enableControls(b); |
|
125 |
tableSettingsPanel.enableAlphaControls(b); |
|
126 |
tableSettingsPanel.enableSpatialControls(b); |
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
public UserSelectedFieldsPanel getUserSelectedFieldsPanel() { |
|
131 |
if (selectedFieldsPanel == null) { |
|
132 |
FeatureType ft=null; |
|
133 |
try { |
|
134 |
ft = explorer.getFeatureType(parameters); |
|
135 |
} catch (DataException e) { |
|
136 |
NotificationManager.addError(e); |
|
137 |
return null; |
|
138 |
} |
|
139 |
ArrayList<FeatureAttributeDescriptor> attList = new ArrayList<FeatureAttributeDescriptor>(); |
|
140 |
|
|
141 |
Iterator<FeatureAttributeDescriptor> iter = ft.iterator(); |
|
142 |
while (iter.hasNext()) { |
|
143 |
attList.add(iter.next()); |
|
144 |
} |
|
145 |
|
|
146 |
FeatureAttributeDescriptor[] allf = attList |
|
147 |
.toArray(new FeatureAttributeDescriptor[0]); |
|
148 |
|
|
149 |
|
|
150 |
selectedFieldsPanel = new UserSelectedFieldsPanel(allf, false, |
|
151 |
parent); |
|
152 |
} |
|
153 |
|
|
154 |
return selectedFieldsPanel; |
|
155 |
} |
|
156 |
|
|
157 |
public UserTableSettingsPanel getUserTableSettingsPanel() { |
|
158 |
if (tableSettingsPanel == null) { |
|
159 |
|
|
160 |
String[] ids = new String[0]; |
|
161 |
FeatureType ft = null; |
|
162 |
|
|
163 |
try { |
|
164 |
ft = explorer.getFeatureType(parameters); |
|
165 |
} catch (DataException e) { |
|
166 |
NotificationManager.addError(e); |
|
167 |
return null; |
|
168 |
} |
|
169 |
|
|
170 |
ArrayList auxAll = new ArrayList(); |
|
171 |
ArrayList auxId = new ArrayList(); |
|
172 |
Iterator iter = ft.iterator(); |
|
173 |
while (iter.hasNext()) { |
|
174 |
FeatureAttributeDescriptor dbattr = (FeatureAttributeDescriptor) iter |
|
175 |
.next(); |
|
176 |
if (dbattr.isPrimaryKey()) { |
|
177 |
auxId.add(dbattr.getName()); |
|
178 |
} |
|
179 |
auxAll.add(dbattr.getName()); |
|
180 |
|
|
181 |
} |
|
182 |
|
|
183 |
if (auxId.size() > 0) { |
|
184 |
StringBuilder strb = new StringBuilder(); |
|
185 |
strb.append('{'); |
|
186 |
for (int i = 0; i < auxId.size()-1; i++) { |
|
187 |
strb.append(((FeatureAttributeDescriptor) auxId.get(i)) |
|
188 |
.getName()); |
|
189 |
strb.append(','); |
|
190 |
} |
|
191 |
strb.append(auxId.get(auxId.size() - 1)); |
|
192 |
|
|
193 |
strb.append('}'); |
|
194 |
if (auxId.size() == 1) { |
|
195 |
auxAll.remove(auxId.get(0)); |
|
196 |
} |
|
197 |
auxAll.add(0, strb.toString()); |
|
198 |
} |
|
199 |
ids = (String[]) auxAll.toArray(new String[auxAll.size()]); |
|
200 |
int ids_size = ids.length; |
|
201 |
FieldComboItem[] ids_ci = new FieldComboItem[ids_size]; |
|
202 |
|
|
203 |
for (int i = 0; i < ids_size; i++) { |
|
204 |
ids_ci[i] = new FieldComboItem(ids[i]); |
|
205 |
} |
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
tableSettingsPanel = new UserTableSettingsPanel(ids_ci, tableName, |
|
210 |
true, parent, getParameters()); |
|
211 |
} |
|
212 |
|
|
213 |
return tableSettingsPanel; |
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
public IProjection currentProjection(String espView, |
|
218 |
FieldComboItem[] ids_ci, FieldComboItem[] geos_ci) { |
|
219 |
IProjection proj = AddLayerDialog.getLastProjection(); |
|
220 |
try { |
|
221 |
ArrayList list = new ArrayList(1); |
|
222 |
list.add(espView); |
|
223 |
FeatureType ft = null; |
|
224 |
try { |
|
225 |
ft = explorer.getFeatureType(parameters); |
|
226 |
} catch (DataException e) { |
|
227 |
// TODO Auto-generated catch block |
|
228 |
e.printStackTrace(); |
|
229 |
} |
|
230 |
} catch (Exception e) { |
|
231 |
NotificationManager.addInfo("Incorrect projection", e); |
|
232 |
} |
|
233 |
return proj; |
|
234 |
} |
|
235 |
|
|
236 |
public DBStoreParameters getParameters() { |
|
237 |
return parameters; |
|
238 |
} |
|
239 |
} |
|
0 | 240 |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/MyExplorer.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
5 |
* of the Valencian Government (CIT) |
|
6 |
* |
|
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 |
|
10 |
* of the License, or (at your option) any later version. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
21 |
* |
|
22 |
*/ |
|
23 |
|
|
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* ${year} IVER T.I. S.A. {{Task}} |
|
27 |
*/ |
|
28 |
|
|
29 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
30 |
|
|
31 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* DOCUMENT ME! |
|
36 |
* |
|
37 |
* @author Vicente Caballero Navarro |
|
38 |
*/ |
|
39 |
public class MyExplorer { |
|
40 |
private DBServerExplorerParameters dbExplorerParameters; |
|
41 |
private String name; |
|
42 |
|
|
43 |
/** |
|
44 |
* DOCUMENT ME! |
|
45 |
* |
|
46 |
* @return DOCUMENT ME! |
|
47 |
*/ |
|
48 |
public DBServerExplorerParameters getDbSeverExplorerParameters() { |
|
49 |
return dbExplorerParameters; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* DOCUMENT ME! |
|
54 |
* |
|
55 |
* @param dbExplorerParameters DOCUMENT ME! |
|
56 |
*/ |
|
57 |
public void setDbExplorerParameters( |
|
58 |
DBServerExplorerParameters dbExplorerParameters) { |
|
59 |
this.dbExplorerParameters = dbExplorerParameters; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* DOCUMENT ME! |
|
64 |
* |
|
65 |
* @return DOCUMENT ME! |
|
66 |
*/ |
|
67 |
public String getName() { |
|
68 |
return name; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* DOCUMENT ME! |
|
73 |
* |
|
74 |
* @param name DOCUMENT ME! |
|
75 |
*/ |
|
76 |
public void setName(String name) { |
|
77 |
this.name = name; |
|
78 |
} |
|
79 |
|
|
80 |
public String toString() { |
|
81 |
return getName(); |
|
82 |
} |
|
83 |
|
|
84 |
} |
tags/v2_0_0_Build_2025/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/WizardDB.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.geodb.vectorialdb.wizard; |
|
29 |
|
|
30 |
import java.awt.BorderLayout; |
|
31 |
import java.awt.Window; |
|
32 |
import java.awt.event.ActionEvent; |
|
33 |
import java.awt.event.ActionListener; |
|
34 |
import java.util.ArrayList; |
|
35 |
import java.util.Iterator; |
|
36 |
import java.util.List; |
|
37 |
import java.util.Map; |
|
38 |
import java.util.Map.Entry; |
|
39 |
|
|
40 |
import javax.swing.DefaultListModel; |
|
41 |
import javax.swing.ImageIcon; |
|
42 |
import javax.swing.JComboBox; |
|
43 |
import javax.swing.JOptionPane; |
|
44 |
import javax.swing.JPanel; |
|
45 |
import javax.swing.JScrollPane; |
|
46 |
import javax.swing.ListSelectionModel; |
|
47 |
import javax.swing.event.ListSelectionEvent; |
|
48 |
import javax.swing.event.ListSelectionListener; |
|
49 |
|
|
50 |
import org.apache.commons.collections.map.HashedMap; |
|
51 |
import org.gvsig.andami.PluginServices; |
|
52 |
import org.gvsig.andami.PluginsLocator; |
|
53 |
import org.gvsig.andami.PluginsManager; |
|
54 |
import org.gvsig.andami.messages.NotificationManager; |
|
55 |
import org.gvsig.app.ApplicationLocator; |
|
56 |
import org.gvsig.app.ApplicationManager; |
|
57 |
import org.gvsig.app.gui.WizardPanel; |
|
58 |
import org.gvsig.app.prepareAction.PrepareContext; |
|
59 |
import org.gvsig.app.project.Project; |
|
60 |
import org.gvsig.app.project.ProjectManager; |
|
61 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
62 |
import org.gvsig.app.project.documents.table.TableManager; |
|
63 |
import org.gvsig.fmap.dal.DALLocator; |
|
64 |
import org.gvsig.fmap.dal.DataManager; |
|
65 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
66 |
import org.gvsig.fmap.dal.exception.DataException; |
|
67 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
68 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
69 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
70 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
|
71 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
|
72 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
|
73 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
74 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
75 |
import org.gvsig.geodb.ExtDB_Spatial; |
|
76 |
import org.gvsig.gui.beans.swing.JButton; |
|
77 |
import org.gvsig.tools.dynobject.DynObject; |
|
78 |
import org.slf4j.Logger; |
Also available in: Unified diff