10 |
10 |
*
|
11 |
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
14 |
* GNU General Public License for more details.
|
15 |
15 |
*
|
16 |
16 |
* You should have received a copy of the GNU General Public License
|
17 |
17 |
* along with this program; if not, write to the Free Software
|
18 |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
|
* MA 02110-1301, USA.
|
|
19 |
* MA 02110-1301, USA.
|
20 |
20 |
*
|
21 |
21 |
* For any additional information, do not hesitate to contact us
|
22 |
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
23 |
*/
|
24 |
|
|
25 |
24 |
package org.gvsig.geodb.vectorialdb.wizard;
|
26 |
25 |
|
27 |
26 |
import java.awt.BorderLayout;
|
... | ... | |
65 |
64 |
import org.gvsig.app.project.documents.table.TableManager;
|
66 |
65 |
import org.gvsig.fmap.dal.DALLocator;
|
67 |
66 |
import org.gvsig.fmap.dal.DataManager;
|
|
67 |
import org.gvsig.fmap.dal.DataServerExplorerPool;
|
|
68 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry;
|
68 |
69 |
import org.gvsig.fmap.dal.DataStoreParameters;
|
69 |
70 |
import org.gvsig.fmap.dal.exception.DataException;
|
70 |
71 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
... | ... | |
78 |
79 |
import org.gvsig.i18n.Messages;
|
79 |
80 |
import org.gvsig.tools.dynobject.DynObject;
|
80 |
81 |
|
81 |
|
|
82 |
82 |
public class WizardDB extends WizardPanel implements ActionListener,
|
83 |
|
ListSelectionListener {
|
|
83 |
ListSelectionListener {
|
84 |
84 |
|
85 |
|
/**
|
86 |
|
*
|
|
85 |
/**
|
|
86 |
*
|
87 |
87 |
*/
|
88 |
88 |
private static final long serialVersionUID = -7045762275505941695L;
|
89 |
89 |
private static final String WIZARD_TAB_NAME = "DB";
|
90 |
|
private static Logger logger = LoggerFactory.getLogger(WizardDB.class
|
91 |
|
.getName());
|
|
90 |
private static Logger logger = LoggerFactory.getLogger(WizardDB.class
|
|
91 |
.getName());
|
92 |
92 |
|
93 |
93 |
private JPanel namePanel = null;
|
94 |
|
private JPanel tablesPanel = null;
|
95 |
|
private JScrollPane tablesScrollPane = null;
|
96 |
|
private AvailableTablesCheckBoxList tablesList = null;
|
97 |
|
private JComboBox datasourceComboBox = null;
|
98 |
|
private UserSelectedFieldsPanel fieldsPanel = null;
|
99 |
|
private UserSelectedFieldsPanel emptyFieldsPanel = null;
|
100 |
|
private JButton dbButton = null;
|
101 |
|
private DBServerExplorerParameters dbExplorerParameters;
|
102 |
|
private DBServerExplorer dbExplorer = null;
|
|
94 |
private JPanel tablesPanel = null;
|
|
95 |
private JScrollPane tablesScrollPane = null;
|
|
96 |
private AvailableTablesCheckBoxList tablesList = null;
|
|
97 |
private JComboBox datasourceComboBox = null;
|
|
98 |
private UserSelectedFieldsPanel fieldsPanel = null;
|
|
99 |
private UserSelectedFieldsPanel emptyFieldsPanel = null;
|
|
100 |
private JButton dbButton = null;
|
|
101 |
private DBServerExplorerParameters dbExplorerParameters;
|
|
102 |
private DBServerExplorer dbExplorer = null;
|
103 |
103 |
|
104 |
104 |
private UserTableSettingsPanel settingsPanel = null;
|
105 |
|
protected UserTableSettingsPanel emptySettingsPanel = null;
|
106 |
|
private PrepareContext prepareDSContext;
|
|
105 |
protected UserTableSettingsPanel emptySettingsPanel = null;
|
|
106 |
private PrepareContext prepareDSContext;
|
107 |
107 |
|
108 |
108 |
public WizardDB() {
|
109 |
|
super();
|
110 |
|
initialize();
|
111 |
|
this.addAncestorListener(new AncestorListener() {
|
112 |
|
public void ancestorAdded(AncestorEvent ae) {
|
113 |
|
}
|
114 |
|
public void ancestorRemoved(AncestorEvent ae) {
|
115 |
|
if( dbExplorer!= null ) {
|
116 |
|
dbExplorer.dispose();
|
117 |
|
dbExplorer = null;
|
118 |
|
}
|
119 |
|
}
|
120 |
|
public void ancestorMoved(AncestorEvent ae) {
|
121 |
|
}
|
122 |
|
});
|
123 |
|
}
|
|
109 |
super();
|
|
110 |
initialize();
|
|
111 |
this.addAncestorListener(new AncestorListener() {
|
|
112 |
public void ancestorAdded(AncestorEvent ae) {
|
|
113 |
}
|
124 |
114 |
|
|
115 |
public void ancestorRemoved(AncestorEvent ae) {
|
|
116 |
if ( dbExplorer != null ) {
|
|
117 |
dbExplorer.dispose();
|
|
118 |
dbExplorer = null;
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
public void ancestorMoved(AncestorEvent ae) {
|
|
123 |
}
|
|
124 |
});
|
|
125 |
}
|
|
126 |
|
125 |
127 |
public DBServerExplorer getServerExplorer() {
|
126 |
128 |
return this.dbExplorer;
|
127 |
129 |
}
|
128 |
|
|
129 |
|
protected void initialize() {
|
130 |
|
setTabName(WIZARD_TAB_NAME);
|
131 |
|
setLayout(null);
|
132 |
|
setSize(512, 478);
|
133 |
130 |
|
|
131 |
protected void initialize() {
|
|
132 |
setTabName(WIZARD_TAB_NAME);
|
|
133 |
setLayout(null);
|
|
134 |
setSize(512, 478);
|
134 |
135 |
|
|
136 |
emptyFieldsPanel = new UserSelectedFieldsPanel(null, true, this);
|
|
137 |
add(emptyFieldsPanel);
|
135 |
138 |
|
136 |
|
emptyFieldsPanel = new UserSelectedFieldsPanel(null, true, this);
|
137 |
|
add(emptyFieldsPanel);
|
138 |
|
|
139 |
139 |
add(getNamePanel(), null);
|
140 |
|
loadVectorialDBDatasourcesCombo(null);
|
|
140 |
loadVectorialDBDatasourcesCombo(null);
|
141 |
141 |
|
142 |
|
add(getTablesPanel(), null);
|
|
142 |
add(getTablesPanel(), null);
|
143 |
143 |
|
144 |
144 |
emptySettingsPanel = createSettingsPanel(null);
|
145 |
145 |
add(emptySettingsPanel);
|
146 |
146 |
|
147 |
|
}
|
|
147 |
}
|
148 |
148 |
|
149 |
|
|
150 |
149 |
@SuppressWarnings("rawtypes")
|
151 |
150 |
private void loadVectorialDBDatasourcesCombo(MyExplorer sel) {
|
152 |
|
|
153 |
|
PluginsManager manager = PluginsLocator.getManager();
|
154 |
|
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
155 |
|
Map connections = (Map) values.getDynValue("db_connections");
|
156 |
|
if (connections != null){
|
157 |
|
Iterator it = connections.entrySet().iterator();
|
158 |
|
getDatasourceComboBox().removeAllItems();
|
159 |
|
getDatasourceComboBox().addItem("");
|
160 |
|
while (it.hasNext()){
|
161 |
|
Map.Entry entry = (Entry) it.next();
|
162 |
|
MyExplorer myExplorer = new MyExplorer();
|
163 |
|
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getValue());
|
164 |
|
myExplorer.setName((String) entry.getKey());
|
165 |
|
getDatasourceComboBox().addItem(myExplorer);
|
166 |
|
if(sel!=null && sel.getName().equalsIgnoreCase(myExplorer.getName())){
|
167 |
|
getDatasourceComboBox().setSelectedItem(myExplorer);
|
168 |
|
}
|
|
151 |
DataManager dataManager = DALLocator.getDataManager();
|
|
152 |
DataServerExplorerPool explorersPool = dataManager.getDataServerExplorerPool();
|
|
153 |
Iterator it = explorersPool.iterator();
|
|
154 |
getDatasourceComboBox().removeAllItems();
|
|
155 |
getDatasourceComboBox().addItem("");
|
|
156 |
while ( it.hasNext() ) {
|
|
157 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next();
|
|
158 |
MyExplorer myExplorer = new MyExplorer();
|
|
159 |
myExplorer.setDbExplorerParameters((DBServerExplorerParameters) entry.getExplorerParameters());
|
|
160 |
myExplorer.setName(entry.getName());
|
|
161 |
getDatasourceComboBox().addItem(myExplorer);
|
|
162 |
if ( sel != null && sel.getName().equalsIgnoreCase(myExplorer.getName()) ) {
|
|
163 |
getDatasourceComboBox().setSelectedItem(myExplorer);
|
169 |
164 |
}
|
170 |
|
} else {
|
171 |
|
connections = new HashedMap();
|
172 |
|
values.setDynValue("db_connections", connections);
|
173 |
165 |
}
|
174 |
|
}
|
175 |
166 |
|
176 |
|
public void initWizard() {
|
177 |
|
}
|
|
167 |
}
|
178 |
168 |
|
|
169 |
public void initWizard() {
|
|
170 |
}
|
|
171 |
|
179 |
172 |
@Override
|
180 |
173 |
public void execute() {
|
181 |
174 |
executeWizard();
|
... | ... | |
183 |
176 |
|
184 |
177 |
@Override
|
185 |
178 |
public Object executeWizard() {
|
186 |
|
TablesListItem[] tables = getSelectedTables();
|
|
179 |
TablesListItem[] tables = getSelectedTables();
|
187 |
180 |
|
188 |
|
DataManager man = DALLocator.getDataManager();
|
189 |
|
FeatureStore store;
|
190 |
|
|
191 |
|
String docName;
|
192 |
|
TableDocument document;
|
193 |
|
Project project = ProjectManager.getInstance().getCurrentProject();
|
|
181 |
DataManager man = DALLocator.getDataManager();
|
|
182 |
FeatureStore store;
|
194 |
183 |
|
195 |
|
ApplicationManager appGvSIGMan = ApplicationLocator.getManager();
|
196 |
|
PrepareContext context = this.getPrepareDataStoreContext();
|
197 |
|
DBStoreParameters storeParams;
|
198 |
|
List<TableDocument> tabledocs =
|
199 |
|
new ArrayList<TableDocument>(tables.length);
|
200 |
|
for (TablesListItem table : tables) {
|
201 |
|
storeParams = getParameterForTable(table);
|
|
184 |
String docName;
|
|
185 |
TableDocument document;
|
|
186 |
Project project = ProjectManager.getInstance().getCurrentProject();
|
202 |
187 |
|
203 |
|
try {
|
204 |
|
storeParams = (DBStoreParameters) appGvSIGMan
|
205 |
|
.prepareOpenDataStoreParameters(storeParams, context);
|
206 |
|
} catch (Exception e2) {
|
207 |
|
NotificationManager.addError(e2);
|
208 |
|
continue;
|
209 |
|
}
|
|
188 |
ApplicationManager appGvSIGMan = ApplicationLocator.getManager();
|
|
189 |
PrepareContext context = this.getPrepareDataStoreContext();
|
|
190 |
DBStoreParameters storeParams;
|
|
191 |
List<TableDocument> tabledocs
|
|
192 |
= new ArrayList<TableDocument>(tables.length);
|
|
193 |
for ( TablesListItem table : tables ) {
|
|
194 |
storeParams = getParameterForTable(table);
|
210 |
195 |
|
211 |
|
UserTableSettingsPanel userTableSettingsPanel = table
|
212 |
|
.getUserTableSettingsPanel();
|
|
196 |
try {
|
|
197 |
storeParams = (DBStoreParameters) appGvSIGMan
|
|
198 |
.prepareOpenDataStoreParameters(storeParams, context);
|
|
199 |
} catch (Exception e2) {
|
|
200 |
NotificationManager.addError(e2);
|
|
201 |
continue;
|
|
202 |
}
|
213 |
203 |
|
214 |
|
docName = userTableSettingsPanel.getUserLayerName();
|
215 |
|
try {
|
216 |
|
store = (FeatureStore) man.openStore(storeParams.getDataStoreName(), storeParams);
|
217 |
|
} catch (Exception e) {
|
218 |
|
NotificationManager.addError(e);
|
|
204 |
UserTableSettingsPanel userTableSettingsPanel = table
|
|
205 |
.getUserTableSettingsPanel();
|
|
206 |
|
|
207 |
docName = userTableSettingsPanel.getUserLayerName();
|
|
208 |
try {
|
|
209 |
store = (FeatureStore) man.openStore(storeParams.getDataStoreName(), storeParams);
|
|
210 |
} catch (Exception e) {
|
|
211 |
NotificationManager.addError(e);
|
219 |
212 |
return null;
|
220 |
|
}
|
|
213 |
}
|
221 |
214 |
|
222 |
|
try {
|
223 |
|
appGvSIGMan.pepareOpenDataSource(
|
224 |
|
store, context);
|
225 |
|
} catch (Exception e) {
|
226 |
|
NotificationManager.addError(e);
|
227 |
|
store.dispose();
|
|
215 |
try {
|
|
216 |
appGvSIGMan.pepareOpenDataSource(
|
|
217 |
store, context);
|
|
218 |
} catch (Exception e) {
|
|
219 |
NotificationManager.addError(e);
|
|
220 |
store.dispose();
|
228 |
221 |
return null;
|
229 |
|
}
|
|
222 |
}
|
230 |
223 |
|
231 |
|
document = (TableDocument) ProjectManager.getInstance().createDocument(TableManager.TYPENAME, docName);
|
232 |
|
document.setStore(store);
|
|
224 |
document = (TableDocument) ProjectManager.getInstance().createDocument(TableManager.TYPENAME, docName);
|
|
225 |
document.setStore(store);
|
233 |
226 |
// project.add(document);
|
234 |
227 |
tabledocs.add(document);
|
235 |
|
}
|
|
228 |
}
|
236 |
229 |
return tabledocs;
|
237 |
|
}
|
|
230 |
}
|
238 |
231 |
|
239 |
|
protected DBStoreParameters getParameterForTable(TablesListItem table) {
|
240 |
|
DBStoreParameters parameters = table.getParameters();
|
|
232 |
protected DBStoreParameters getParameterForTable(TablesListItem table) {
|
|
233 |
DBStoreParameters parameters = table.getParameters();
|
241 |
234 |
|
242 |
|
UserTableSettingsPanel userTableSettingsPanel = table
|
243 |
|
.getUserTableSettingsPanel();
|
|
235 |
UserTableSettingsPanel userTableSettingsPanel = table
|
|
236 |
.getUserTableSettingsPanel();
|
244 |
237 |
|
|
238 |
String fidField = userTableSettingsPanel.getIdFieldName();
|
|
239 |
//IF is a multiple PK, remove the {} symbols
|
|
240 |
if ( fidField.startsWith("{") && fidField.endsWith("}") ) {
|
|
241 |
fidField = fidField.substring(1, fidField.length() - 1);
|
|
242 |
}
|
|
243 |
String[] pkFields = fidField.split(",");
|
245 |
244 |
|
|
245 |
String[] fields = table.getUserSelectedFieldsPanel()
|
|
246 |
.getUserSelectedFields(pkFields, null);
|
246 |
247 |
|
247 |
|
String fidField = userTableSettingsPanel.getIdFieldName();
|
248 |
|
//IF is a multiple PK, remove the {} symbols
|
249 |
|
if (fidField.startsWith("{") && fidField.endsWith("}")) {
|
250 |
|
fidField = fidField.substring(1, fidField.length()-1);
|
251 |
|
}
|
252 |
|
String[] pkFields = fidField.split(",");
|
253 |
|
|
254 |
|
String[] fields = table.getUserSelectedFieldsPanel()
|
255 |
|
.getUserSelectedFields(pkFields, null);
|
|
248 |
if ( userTableSettingsPanel.isSqlActive() ) {
|
|
249 |
String whereClause = userTableSettingsPanel
|
|
250 |
.getWhereClause();
|
|
251 |
parameters.setBaseFilter(whereClause);
|
|
252 |
} else {
|
|
253 |
parameters.setBaseFilter("");
|
|
254 |
}
|
256 |
255 |
|
257 |
|
if (userTableSettingsPanel.isSqlActive()) {
|
258 |
|
String whereClause = userTableSettingsPanel
|
259 |
|
.getWhereClause();
|
260 |
|
parameters.setBaseFilter(whereClause);
|
261 |
|
} else {
|
262 |
|
parameters.setBaseFilter("");
|
263 |
|
}
|
|
256 |
parameters.setFields(fields);
|
264 |
257 |
|
265 |
|
parameters.setFields(fields);
|
|
258 |
return parameters;
|
266 |
259 |
|
|
260 |
}
|
267 |
261 |
|
268 |
|
return parameters;
|
269 |
|
|
270 |
|
}
|
271 |
|
|
272 |
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
262 |
@SuppressWarnings({"rawtypes", "unchecked"})
|
273 |
263 |
protected TablesListItem[] getSelectedTables() {
|
274 |
|
int count = tablesList.getModel().getSize();
|
275 |
|
ArrayList resp = new ArrayList();
|
|
264 |
int count = tablesList.getModel().getSize();
|
|
265 |
ArrayList resp = new ArrayList();
|
276 |
266 |
|
277 |
|
for (int i = 0; i < count; i++) {
|
278 |
|
TablesListItem item = (TablesListItem) tablesList.getModel()
|
279 |
|
.getElementAt(i);
|
|
267 |
for ( int i = 0; i < count; i++ ) {
|
|
268 |
TablesListItem item = (TablesListItem) tablesList.getModel()
|
|
269 |
.getElementAt(i);
|
280 |
270 |
|
281 |
|
if (item.isSelected()) {
|
282 |
|
resp.add(item);
|
283 |
|
}
|
284 |
|
}
|
|
271 |
if ( item.isSelected() ) {
|
|
272 |
resp.add(item);
|
|
273 |
}
|
|
274 |
}
|
285 |
275 |
|
286 |
|
return (TablesListItem[]) resp.toArray(new TablesListItem[0]);
|
287 |
|
}
|
|
276 |
return (TablesListItem[]) resp.toArray(new TablesListItem[0]);
|
|
277 |
}
|
288 |
278 |
|
289 |
|
/**
|
290 |
|
* This method initializes namePanel
|
291 |
|
*
|
292 |
|
* @return javax.swing.JPanel
|
293 |
|
*/
|
294 |
|
private JPanel getNamePanel() {
|
295 |
|
if (namePanel == null) {
|
296 |
|
namePanel = new JPanel();
|
297 |
|
namePanel.setLayout(null);
|
298 |
|
namePanel.setBounds(new java.awt.Rectangle(5, 5, 501, 51));
|
299 |
|
namePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
300 |
|
null, PluginServices.getText(this, "choose_connection"),
|
301 |
|
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
302 |
|
javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
303 |
|
null));
|
304 |
|
namePanel.add(getDatasourceComboBox(), null);
|
305 |
|
namePanel.add(getJdbcButton(), null);
|
306 |
|
}
|
|
279 |
/**
|
|
280 |
* This method initializes namePanel
|
|
281 |
*
|
|
282 |
* @return javax.swing.JPanel
|
|
283 |
*/
|
|
284 |
private JPanel getNamePanel() {
|
|
285 |
if ( namePanel == null ) {
|
|
286 |
namePanel = new JPanel();
|
|
287 |
namePanel.setLayout(null);
|
|
288 |
namePanel.setBounds(new java.awt.Rectangle(5, 5, 501, 51));
|
|
289 |
namePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
|
290 |
null, PluginServices.getText(this, "choose_connection"),
|
|
291 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
292 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
|
293 |
null));
|
|
294 |
namePanel.add(getDatasourceComboBox(), null);
|
|
295 |
namePanel.add(getJdbcButton(), null);
|
|
296 |
}
|
307 |
297 |
|
308 |
|
return namePanel;
|
309 |
|
}
|
|
298 |
return namePanel;
|
|
299 |
}
|
310 |
300 |
|
311 |
|
/**
|
312 |
|
* This method initializes tablesPanel
|
313 |
|
*
|
314 |
|
* @return javax.swing.JPanel
|
315 |
|
*/
|
316 |
|
private JPanel getTablesPanel() {
|
317 |
|
if (tablesPanel == null) {
|
318 |
|
tablesPanel = new JPanel();
|
319 |
|
tablesPanel.setLayout(new BorderLayout());
|
320 |
|
tablesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
321 |
|
null, PluginServices.getText(this, "choose_table"),
|
322 |
|
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
323 |
|
javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
324 |
|
null));
|
325 |
|
tablesPanel.setBounds(new java.awt.Rectangle(5, 55, 246, 166));
|
326 |
|
tablesPanel
|
327 |
|
.add(getTablesScrollPane(), java.awt.BorderLayout.CENTER);
|
328 |
|
}
|
|
301 |
/**
|
|
302 |
* This method initializes tablesPanel
|
|
303 |
*
|
|
304 |
* @return javax.swing.JPanel
|
|
305 |
*/
|
|
306 |
private JPanel getTablesPanel() {
|
|
307 |
if ( tablesPanel == null ) {
|
|
308 |
tablesPanel = new JPanel();
|
|
309 |
tablesPanel.setLayout(new BorderLayout());
|
|
310 |
tablesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
|
311 |
null, PluginServices.getText(this, "choose_table"),
|
|
312 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
313 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
|
314 |
null));
|
|
315 |
tablesPanel.setBounds(new java.awt.Rectangle(5, 55, 246, 166));
|
|
316 |
tablesPanel
|
|
317 |
.add(getTablesScrollPane(), java.awt.BorderLayout.CENTER);
|
|
318 |
}
|
329 |
319 |
|
330 |
|
return tablesPanel;
|
331 |
|
}
|
|
320 |
return tablesPanel;
|
|
321 |
}
|
332 |
322 |
|
333 |
|
/**
|
334 |
|
* This method initializes settingsPanel
|
335 |
|
*
|
336 |
|
* @return javax.swing.JPanel
|
337 |
|
*/
|
|
323 |
/**
|
|
324 |
* This method initializes settingsPanel
|
|
325 |
*
|
|
326 |
* @return javax.swing.JPanel
|
|
327 |
*/
|
|
328 |
/**
|
|
329 |
* This method initializes tablesScrollPane
|
|
330 |
*
|
|
331 |
* @return javax.swing.JScrollPane
|
|
332 |
*/
|
|
333 |
private JScrollPane getTablesScrollPane() {
|
|
334 |
if ( tablesScrollPane == null ) {
|
|
335 |
tablesScrollPane = new JScrollPane();
|
|
336 |
tablesScrollPane.setViewportView(getTablesList());
|
|
337 |
}
|
338 |
338 |
|
339 |
|
/**
|
340 |
|
* This method initializes tablesScrollPane
|
341 |
|
*
|
342 |
|
* @return javax.swing.JScrollPane
|
343 |
|
*/
|
344 |
|
private JScrollPane getTablesScrollPane() {
|
345 |
|
if (tablesScrollPane == null) {
|
346 |
|
tablesScrollPane = new JScrollPane();
|
347 |
|
tablesScrollPane.setViewportView(getTablesList());
|
348 |
|
}
|
|
339 |
return tablesScrollPane;
|
|
340 |
}
|
349 |
341 |
|
350 |
|
return tablesScrollPane;
|
351 |
|
}
|
|
342 |
/**
|
|
343 |
* This method initializes tablesList
|
|
344 |
*
|
|
345 |
* @return javax.swing.JList
|
|
346 |
*/
|
|
347 |
protected AvailableTablesCheckBoxList getTablesList() {
|
|
348 |
if ( tablesList == null ) {
|
|
349 |
tablesList = new AvailableTablesCheckBoxList(this);
|
|
350 |
tablesList.addListSelectionListener(this);
|
|
351 |
tablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
352 |
}
|
352 |
353 |
|
353 |
|
/**
|
354 |
|
* This method initializes tablesList
|
355 |
|
*
|
356 |
|
* @return javax.swing.JList
|
357 |
|
*/
|
358 |
|
protected AvailableTablesCheckBoxList getTablesList() {
|
359 |
|
if (tablesList == null) {
|
360 |
|
tablesList = new AvailableTablesCheckBoxList(this);
|
361 |
|
tablesList.addListSelectionListener(this);
|
362 |
|
tablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
363 |
|
}
|
|
354 |
return tablesList;
|
|
355 |
}
|
364 |
356 |
|
365 |
|
return tablesList;
|
366 |
|
}
|
|
357 |
/**
|
|
358 |
* This method initializes layerNameTextField
|
|
359 |
*
|
|
360 |
* @return javax.swing.JTextField
|
|
361 |
*/
|
|
362 |
/**
|
|
363 |
* This method initializes jComboBox
|
|
364 |
*
|
|
365 |
* @return javax.swing.JComboBox
|
|
366 |
*/
|
|
367 |
private JComboBox getDatasourceComboBox() {
|
|
368 |
if ( datasourceComboBox == null ) {
|
|
369 |
datasourceComboBox = new JComboBox();
|
|
370 |
datasourceComboBox
|
|
371 |
.setBounds(new java.awt.Rectangle(10, 20, 446, 21));
|
|
372 |
datasourceComboBox.addActionListener(this);
|
|
373 |
}
|
367 |
374 |
|
368 |
|
/**
|
369 |
|
* This method initializes layerNameTextField
|
370 |
|
*
|
371 |
|
* @return javax.swing.JTextField
|
372 |
|
*/
|
|
375 |
return datasourceComboBox;
|
|
376 |
}
|
373 |
377 |
|
374 |
|
/**
|
375 |
|
* This method initializes jComboBox
|
376 |
|
*
|
377 |
|
* @return javax.swing.JComboBox
|
378 |
|
*/
|
379 |
|
private JComboBox getDatasourceComboBox() {
|
380 |
|
if (datasourceComboBox == null) {
|
381 |
|
datasourceComboBox = new JComboBox();
|
382 |
|
datasourceComboBox
|
383 |
|
.setBounds(new java.awt.Rectangle(10, 20, 446, 21));
|
384 |
|
datasourceComboBox.addActionListener(this);
|
385 |
|
}
|
|
378 |
public void actionPerformed(ActionEvent arg0) {
|
|
379 |
if ( datasourceComboBox.getItemCount() == 0 ) {
|
|
380 |
setEmptyPanels();
|
|
381 |
}
|
|
382 |
Object src = arg0.getSource();
|
386 |
383 |
|
387 |
|
return datasourceComboBox;
|
388 |
|
}
|
389 |
|
|
390 |
|
public void actionPerformed(ActionEvent arg0) {
|
391 |
|
if (datasourceComboBox.getItemCount() == 0) {
|
392 |
|
setEmptyPanels();
|
393 |
|
}
|
394 |
|
Object src = arg0.getSource();
|
395 |
|
|
396 |
|
if (src == datasourceComboBox) {
|
|
384 |
if ( src == datasourceComboBox ) {
|
397 |
385 |
Object selected = datasourceComboBox.getSelectedItem();
|
398 |
|
if (selected instanceof MyExplorer) {
|
|
386 |
if ( selected instanceof MyExplorer ) {
|
399 |
387 |
MyExplorer sel_obj = (MyExplorer) selected;
|
400 |
388 |
|
401 |
389 |
getDatasourceComboBox().repaint();
|
... | ... | |
403 |
391 |
updateTableList(dbExplorerParameters);
|
404 |
392 |
}
|
405 |
393 |
|
406 |
|
} else if (src == dbButton) {
|
407 |
|
MyExplorer sel = addNewConnection();
|
|
394 |
} else if ( src == dbButton ) {
|
|
395 |
MyExplorer sel = addNewConnection();
|
408 |
396 |
|
409 |
|
if (sel != null) {
|
410 |
|
dbExplorerParameters = sel.getDbSeverExplorerParameters();
|
411 |
|
loadVectorialDBDatasourcesCombo(sel);
|
412 |
|
getDatasourceComboBox().setSelectedItem(sel);
|
|
397 |
if ( sel != null ) {
|
|
398 |
dbExplorerParameters = sel.getDbSeverExplorerParameters();
|
|
399 |
loadVectorialDBDatasourcesCombo(sel);
|
|
400 |
getDatasourceComboBox().setSelectedItem(sel);
|
413 |
401 |
|
414 |
|
}
|
415 |
|
}
|
416 |
|
|
417 |
|
|
418 |
|
}
|
|
402 |
}
|
|
403 |
}
|
419 |
404 |
|
420 |
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
405 |
}
|
|
406 |
|
|
407 |
@SuppressWarnings({"unchecked", "rawtypes"})
|
421 |
408 |
private MyExplorer addNewConnection() {
|
422 |
|
MyExplorer myExplorer = new MyExplorer();
|
423 |
|
DBServerExplorerParameters resp = null;
|
|
409 |
MyExplorer myExplorer = new MyExplorer();
|
|
410 |
DBServerExplorerParameters resp = null;
|
424 |
411 |
|
425 |
|
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog();
|
426 |
|
newco.showDialog();
|
|
412 |
VectorialDBConnectionParamsDialog newco = new VectorialDBConnectionParamsDialog();
|
|
413 |
newco.showDialog();
|
427 |
414 |
|
428 |
|
if (newco.isOkPressed()) {
|
429 |
|
try {
|
430 |
|
resp = newco.getParameters();
|
431 |
|
} catch (Exception e) {
|
432 |
|
showConnectionErrorMessage(e.getMessage());
|
433 |
|
return null;
|
434 |
|
}
|
435 |
|
PluginsManager manager = PluginsLocator.getManager();
|
436 |
|
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
437 |
|
Map connections = (Map) values.getDynValue("db_connections");
|
438 |
|
if(connections == null){
|
439 |
|
connections = new HashedMap();
|
440 |
|
values.setDynValue("db_connections", connections);
|
|
415 |
if ( newco.isOkPressed() ) {
|
|
416 |
try {
|
|
417 |
resp = newco.getParameters();
|
|
418 |
} catch (Exception e) {
|
|
419 |
showConnectionErrorMessage(e.getMessage());
|
|
420 |
return null;
|
441 |
421 |
}
|
442 |
|
connections.put(newco.getConnectionName(), resp);
|
443 |
|
|
|
422 |
DataManager dataManager = DALLocator.getDataManager();
|
|
423 |
DataServerExplorerPool explorersPool = dataManager.getDataServerExplorerPool();
|
|
424 |
explorersPool.add(newco.getConnectionName(), resp);
|
|
425 |
|
444 |
426 |
// SingleVectorialDBConnectionExtension.saveAllToPersistence();
|
445 |
|
myExplorer.setDbExplorerParameters(resp);
|
446 |
|
myExplorer.setName(newco.getConnectionName());
|
447 |
|
return myExplorer;
|
448 |
|
} else {
|
449 |
|
return null;
|
450 |
|
}
|
451 |
|
}
|
|
427 |
myExplorer.setDbExplorerParameters(resp);
|
|
428 |
myExplorer.setName(newco.getConnectionName());
|
|
429 |
return myExplorer;
|
|
430 |
} else {
|
|
431 |
return null;
|
|
432 |
}
|
|
433 |
}
|
452 |
434 |
|
453 |
|
protected TablesListItem createTabeListItem(DBStoreParameters param) {
|
454 |
|
return new TablesListItem(param, this);
|
455 |
|
}
|
|
435 |
protected TablesListItem createTabeListItem(DBStoreParameters param) {
|
|
436 |
return new TablesListItem(param, this);
|
|
437 |
}
|
456 |
438 |
|
457 |
|
/**
|
458 |
|
* Subclasses of this wizard will return a filtered list
|
459 |
|
* if necessary
|
460 |
|
*
|
461 |
|
* @param explorer
|
462 |
|
* @return
|
463 |
|
* @throws DataException
|
464 |
|
*/
|
465 |
|
protected List getTableList(DBServerExplorer explorer) throws DataException {
|
466 |
|
return explorer.list();
|
467 |
|
}
|
468 |
|
|
469 |
|
@SuppressWarnings("rawtypes")
|
|
439 |
/**
|
|
440 |
* Subclasses of this wizard will return a filtered list
|
|
441 |
* if necessary
|
|
442 |
*
|
|
443 |
* @param explorer
|
|
444 |
* @return
|
|
445 |
* @throws DataException
|
|
446 |
*/
|
|
447 |
protected List getTableList(DBServerExplorer explorer) throws DataException {
|
|
448 |
return explorer.list();
|
|
449 |
}
|
|
450 |
|
|
451 |
@SuppressWarnings("rawtypes")
|
470 |
452 |
protected void updateTableList(
|
471 |
|
DBServerExplorerParameters dbSeverExplorerParameters2) {
|
472 |
|
if (dbSeverExplorerParameters2 == null) {
|
473 |
|
return;
|
474 |
|
}
|
475 |
|
DataManager dm = DALLocator.getDataManager();
|
476 |
|
String err_msg = Messages.getText("connection_error");
|
477 |
|
try {
|
478 |
|
dbExplorer = (DBServerExplorer) dm.openServerExplorer(dbSeverExplorerParameters2.getExplorerName(), dbSeverExplorerParameters2);
|
|
453 |
DBServerExplorerParameters dbSeverExplorerParameters2) {
|
|
454 |
if ( dbSeverExplorerParameters2 == null ) {
|
|
455 |
return;
|
|
456 |
}
|
|
457 |
DataManager dm = DALLocator.getDataManager();
|
|
458 |
String err_msg = Messages.getText("connection_error");
|
|
459 |
try {
|
|
460 |
dbExplorer = (DBServerExplorer) dm.openServerExplorer(dbSeverExplorerParameters2.getExplorerName(), dbSeverExplorerParameters2);
|
479 |
461 |
|
480 |
|
List parameters = getTableList(dbExplorer);
|
|
462 |
List parameters = getTableList(dbExplorer);
|
481 |
463 |
|
482 |
|
DefaultListModel lmodel = new DefaultListModel();
|
|
464 |
DefaultListModel lmodel = new DefaultListModel();
|
483 |
465 |
|
484 |
|
Iterator iter = parameters.iterator();
|
485 |
|
DBStoreParameters param;
|
486 |
|
int count = 0;
|
487 |
|
while (iter.hasNext()) {
|
488 |
|
param = (DBStoreParameters) iter.next();
|
489 |
|
lmodel.addElement(createTabeListItem(param));
|
490 |
|
count++;
|
491 |
|
}
|
|
466 |
Iterator iter = parameters.iterator();
|
|
467 |
DBStoreParameters param;
|
|
468 |
int count = 0;
|
|
469 |
while ( iter.hasNext() ) {
|
|
470 |
param = (DBStoreParameters) iter.next();
|
|
471 |
lmodel.addElement(createTabeListItem(param));
|
|
472 |
count++;
|
|
473 |
}
|
492 |
474 |
|
493 |
|
getTablesList().setModel(lmodel);
|
494 |
|
getTablesScrollPane().setViewportView(tablesList);
|
495 |
|
tablesScrollPane.updateUI();
|
496 |
|
} catch (Exception e) {
|
497 |
|
logger.info("Error while getting table names: " + e.getMessage());
|
498 |
|
|
499 |
|
String remove_question = Messages.getText(
|
500 |
|
"_Remove_connection_parameters_from_list_question");
|
501 |
|
|
502 |
|
int opt = JOptionPane.showConfirmDialog(
|
503 |
|
ApplicationLocator.getManager().getRootComponent(),
|
504 |
|
err_msg + ": " + getLastMessage(e) + "\n" + remove_question,
|
505 |
|
err_msg,
|
506 |
|
JOptionPane.YES_NO_OPTION);
|
507 |
|
|
508 |
|
if (opt == JOptionPane.YES_OPTION) {
|
509 |
|
removeDBPArameters(dbSeverExplorerParameters2);
|
510 |
|
// dbExplorer.
|
511 |
|
loadVectorialDBDatasourcesCombo(null);
|
512 |
|
}
|
513 |
|
}
|
514 |
|
|
515 |
|
}
|
|
475 |
getTablesList().setModel(lmodel);
|
|
476 |
getTablesScrollPane().setViewportView(tablesList);
|
|
477 |
tablesScrollPane.updateUI();
|
|
478 |
} catch (Exception e) {
|
|
479 |
logger.info("Error while getting table names: " + e.getMessage());
|
516 |
480 |
|
517 |
|
/**
|
518 |
|
* Removes DB parameters from list of pre-configured DB parameters
|
519 |
|
* @param dbSeverExplorerParameters2
|
520 |
|
*/
|
521 |
|
private void removeDBPArameters(
|
522 |
|
DBServerExplorerParameters dbparams) {
|
523 |
|
|
|
481 |
String remove_question = Messages.getText(
|
|
482 |
"_Remove_connection_parameters_from_list_question");
|
|
483 |
|
|
484 |
int opt = JOptionPane.showConfirmDialog(
|
|
485 |
ApplicationLocator.getManager().getRootComponent(),
|
|
486 |
err_msg + ": " + getLastMessage(e) + "\n" + remove_question,
|
|
487 |
err_msg,
|
|
488 |
JOptionPane.YES_NO_OPTION);
|
|
489 |
|
|
490 |
if ( opt == JOptionPane.YES_OPTION ) {
|
|
491 |
removeDBPArameters(dbSeverExplorerParameters2);
|
|
492 |
// dbExplorer.
|
|
493 |
loadVectorialDBDatasourcesCombo(null);
|
|
494 |
}
|
|
495 |
}
|
|
496 |
|
|
497 |
}
|
|
498 |
|
|
499 |
/**
|
|
500 |
* Removes DB parameters from list of pre-configured DB parameters
|
|
501 |
*
|
|
502 |
* @param dbSeverExplorerParameters2
|
|
503 |
*/
|
|
504 |
private void removeDBPArameters(
|
|
505 |
DBServerExplorerParameters dbparams) {
|
|
506 |
|
524 |
507 |
PluginsManager manager = PluginsLocator.getManager();
|
525 |
508 |
DynObject values = manager.getPlugin(ExtDB_Spatial.class).getPluginProperties();
|
526 |
509 |
Map connections = (Map) values.getDynValue("db_connections");
|
527 |
|
if (connections == null) {
|
|
510 |
if ( connections == null ) {
|
528 |
511 |
return;
|
529 |
512 |
}
|
530 |
|
|
|
513 |
|
531 |
514 |
DBServerExplorerParameters item = null;
|
532 |
515 |
Iterator it = connections.entrySet().iterator();
|
533 |
516 |
List<String> toremove = new ArrayList();
|
534 |
|
|
535 |
|
while (it.hasNext()) {
|
|
517 |
|
|
518 |
while ( it.hasNext() ) {
|
536 |
519 |
Map.Entry entry = (Entry) it.next();
|
537 |
520 |
item = (DBServerExplorerParameters) entry.getValue();
|
538 |
|
if (dbparams.equals(item)) {
|
|
521 |
if ( dbparams.equals(item) ) {
|
539 |
522 |
toremove.add((String) entry.getKey());
|
540 |
523 |
}
|
541 |
524 |
}
|
542 |
|
|
543 |
|
if (toremove.size() == 0) {
|
|
525 |
|
|
526 |
if ( toremove.size() == 0 ) {
|
544 |
527 |
return;
|
545 |
528 |
}
|
546 |
|
|
547 |
|
for (int i=0; i<toremove.size(); i++) {
|
|
529 |
|
|
530 |
for ( int i = 0; i < toremove.size(); i++ ) {
|
548 |
531 |
connections.remove(toremove.get(i));
|
549 |
532 |
}
|
550 |
533 |
values.setDynValue("db_connections", connections);
|
551 |
|
|
|
534 |
|
552 |
535 |
}
|
553 |
536 |
|
554 |
|
|
555 |
537 |
public void valueChanged(ListSelectionEvent arg0) {
|
556 |
|
Object src = arg0.getSource();
|
|
538 |
Object src = arg0.getSource();
|
557 |
539 |
|
558 |
|
if (src == tablesList) {
|
559 |
|
TablesListItem selected = (TablesListItem) tablesList
|
560 |
|
.getSelectedValue();
|
|
540 |
if ( src == tablesList ) {
|
|
541 |
TablesListItem selected = (TablesListItem) tablesList
|
|
542 |
.getSelectedValue();
|
561 |
543 |
|
562 |
|
setSettingsPanels(selected);
|
563 |
|
checkFinishable();
|
564 |
|
}
|
565 |
|
}
|
|
544 |
setSettingsPanels(selected);
|
|
545 |
checkFinishable();
|
|
546 |
}
|
|
547 |
}
|
566 |
548 |
|
567 |
|
public boolean areSettingsValid() {
|
568 |
|
int count = tablesList.getModel().getSize();
|
|
549 |
public boolean areSettingsValid() {
|
|
550 |
int count = tablesList.getModel().getSize();
|
569 |
551 |
|
570 |
|
boolean at_least_one = false;
|
571 |
|
boolean resp = true;
|
|
552 |
boolean at_least_one = false;
|
|
553 |
boolean resp = true;
|
572 |
554 |
|
573 |
|
for (int i = 0; i < count; i++) {
|
574 |
|
TablesListItem item = (TablesListItem) tablesList.getModel()
|
575 |
|
.getElementAt(i);
|
|
555 |
for ( int i = 0; i < count; i++ ) {
|
|
556 |
TablesListItem item = (TablesListItem) tablesList.getModel()
|
|
557 |
.getElementAt(i);
|
576 |
558 |
|
577 |
|
if (item.isSelected()) {
|
578 |
|
at_least_one = true;
|
579 |
|
}
|
|
559 |
if ( item.isSelected() ) {
|
|
560 |
at_least_one = true;
|
|
561 |
}
|
580 |
562 |
|
581 |
|
if (item.disturbsWizardValidity()) {
|
582 |
|
resp = false;
|
583 |
|
}
|
584 |
|
}
|
|
563 |
if ( item.disturbsWizardValidity() ) {
|
|
564 |
resp = false;
|
|
565 |
}
|
|
566 |
}
|
585 |
567 |
|
586 |
|
return (at_least_one && resp);
|
587 |
|
}
|
|
568 |
return (at_least_one && resp);
|
|
569 |
}
|
588 |
570 |
|
589 |
|
public void checkFinishable() {
|
590 |
|
boolean finishable = areSettingsValid();
|
591 |
|
callStateChanged(finishable);
|
592 |
|
}
|
|
571 |
public void checkFinishable() {
|
|
572 |
boolean finishable = areSettingsValid();
|
|
573 |
callStateChanged(finishable);
|
|
574 |
}
|
593 |
575 |
|
594 |
|
/**
|
595 |
|
* This method initializes jdbcButton
|
596 |
|
*
|
597 |
|
* @return javax.swing.JButton
|
598 |
|
*/
|
599 |
|
private JButton getJdbcButton() {
|
600 |
|
if (dbButton == null) {
|
601 |
|
dbButton = new JButton();
|
602 |
|
dbButton.addActionListener(this);
|
603 |
|
dbButton.setToolTipText(PluginServices.getText(this,
|
604 |
|
"add_connection"));
|
605 |
|
dbButton.setBounds(new java.awt.Rectangle(465, 20, 26, 21));
|
|
576 |
/**
|
|
577 |
* This method initializes jdbcButton
|
|
578 |
*
|
|
579 |
* @return javax.swing.JButton
|
|
580 |
*/
|
|
581 |
private JButton getJdbcButton() {
|
|
582 |
if ( dbButton == null ) {
|
|
583 |
dbButton = new JButton();
|
|
584 |
dbButton.addActionListener(this);
|
|
585 |
dbButton.setToolTipText(PluginServices.getText(this,
|
|
586 |
"add_connection"));
|
|
587 |
dbButton.setBounds(new java.awt.Rectangle(465, 20, 26, 21));
|
606 |
588 |
|
607 |
|
dbButton.setIcon(IconThemeHelper.getImageIcon("geodb-connection-add"));
|
608 |
|
}
|
|
589 |
dbButton.setIcon(IconThemeHelper.getImageIcon("geodb-connection-add"));
|
|
590 |
}
|
609 |
591 |
|
610 |
|
return dbButton;
|
611 |
|
}
|
|
592 |
return dbButton;
|
|
593 |
}
|
612 |
594 |
|
613 |
|
private void showConnectionErrorMessage(String _msg) {
|
614 |
|
String msg = (_msg.length() > 300) ? "" : (": " + _msg);
|
615 |
|
String title = PluginServices.getText(this, "connection_error");
|
616 |
|
JOptionPane.showMessageDialog(this, title + msg, title,
|
617 |
|
JOptionPane.ERROR_MESSAGE);
|
618 |
|
}
|
|
595 |
private void showConnectionErrorMessage(String _msg) {
|
|
596 |
String msg = (_msg.length() > 300) ? "" : (": " + _msg);
|
|
597 |
String title = PluginServices.getText(this, "connection_error");
|
|
598 |
JOptionPane.showMessageDialog(this, title + msg, title,
|
|
599 |
JOptionPane.ERROR_MESSAGE);
|
|
600 |
}
|
619 |
601 |
|
620 |
|
private java.net.URL createResourceUrl(String path) {
|
621 |
|
return getClass().getClassLoader().getResource(path);
|
622 |
|
}
|
|
602 |
private java.net.URL createResourceUrl(String path) {
|
|
603 |
return getClass().getClassLoader().getResource(path);
|
|
604 |
}
|
623 |
605 |
|
624 |
|
public void setSettingsPanels(TablesListItem actTable) {
|
625 |
|
if (actTable == null) {
|
626 |
|
setEmptyPanels();
|
|
606 |
public void setSettingsPanels(TablesListItem actTable) {
|
|
607 |
if ( actTable == null ) {
|
|
608 |
setEmptyPanels();
|
627 |
609 |
|
628 |
|
return;
|
629 |
|
}
|
630 |
|
fieldsPanel = actTable.getUserSelectedFieldsPanel();
|
|
610 |
return;
|
|
611 |
}
|
|
612 |
fieldsPanel = actTable.getUserSelectedFieldsPanel();
|
631 |
613 |
|
632 |
|
removeFieldPanels();
|
633 |
|
add(fieldsPanel);
|
634 |
|
fieldsPanel.repaint();
|
635 |
|
removeSettingsPanels();
|
636 |
|
add(emptySettingsPanel);
|
|
614 |
removeFieldPanels();
|
|
615 |
add(fieldsPanel);
|
|
616 |
fieldsPanel.repaint();
|
|
617 |
removeSettingsPanels();
|
|
618 |
add(emptySettingsPanel);
|
637 |
619 |
|
638 |
|
settingsPanel = createSettingsPanel(actTable);
|
|
620 |
settingsPanel = createSettingsPanel(actTable);
|
639 |
621 |
|
640 |
|
removeSettingsPanels();
|
641 |
|
add(settingsPanel);
|
642 |
|
settingsPanel.repaint();
|
|
622 |
removeSettingsPanels();
|
|
623 |
add(settingsPanel);
|
|
624 |
settingsPanel.repaint();
|
643 |
625 |
|
|
626 |
repaint();
|
|
627 |
}
|
644 |
628 |
|
645 |
|
repaint();
|
646 |
|
}
|
|
629 |
protected UserTableSettingsPanel createSettingsPanel(TablesListItem actTable) {
|
|
630 |
if ( actTable == null ) {
|
|
631 |
return new UserTableSettingsPanel(null, "", true, this, null);
|
|
632 |
}
|
647 |
633 |
|
|
634 |
return actTable.getUserTableSettingsPanel();
|
|
635 |
}
|
648 |
636 |
|
|
637 |
protected void setEmptyPanels() {
|
|
638 |
removeFieldPanels();
|
|
639 |
add(emptyFieldsPanel);
|
|
640 |
fieldsPanel = emptyFieldsPanel;
|
649 |
641 |
|
650 |
|
protected UserTableSettingsPanel createSettingsPanel(TablesListItem actTable) {
|
651 |
|
if (actTable == null) {
|
652 |
|
return new UserTableSettingsPanel(null, "", true, this, null);
|
653 |
|
}
|
|
642 |
repaint();
|
|
643 |
}
|
654 |
644 |
|
655 |
|
return actTable.getUserTableSettingsPanel();
|
656 |
|
}
|
|
645 |
private void removeFieldPanels() {
|
|
646 |
for ( int i = 0; i < getComponentCount(); i++ ) {
|
|
647 |
if ( getComponent(i) instanceof UserSelectedFieldsPanel ) {
|
|
648 |
remove(i);
|
|
649 |
}
|
|
650 |
}
|
|
651 |
}
|
657 |
652 |
|
658 |
|
protected void setEmptyPanels() {
|
659 |
|
removeFieldPanels();
|
660 |
|
add(emptyFieldsPanel);
|
661 |
|
fieldsPanel = emptyFieldsPanel;
|
|
653 |
public DataStoreParameters[] getParameters() {
|
|
654 |
try {
|
|
655 |
TablesListItem[] selected = getSelectedTables();
|
|
656 |
int count = selected.length;
|
|
657 |
DBStoreParameters[] dbParameters = new DBStoreParameters[count];
|
662 |
658 |
|
663 |
|
repaint();
|
664 |
|
}
|
|
659 |
for ( int i = 0; i < count; i++ ) {
|
|
660 |
TablesListItem item = selected[i];
|
665 |
661 |
|
666 |
|
private void removeFieldPanels() {
|
667 |
|
for (int i = 0; i < getComponentCount(); i++) {
|
668 |
|
if (getComponent(i) instanceof UserSelectedFieldsPanel) {
|
669 |
|
remove(i);
|
670 |
|
}
|
671 |
|
}
|
672 |
|
}
|
|
662 |
dbParameters[i] = getParameterForTable(item);
|
|
663 |
}
|
673 |
664 |
|
674 |
|
public DataStoreParameters[] getParameters() {
|
675 |
|
try {
|
676 |
|
TablesListItem[] selected = getSelectedTables();
|
677 |
|
int count = selected.length;
|
678 |
|
DBStoreParameters[] dbParameters = new DBStoreParameters[count];
|
|
665 |
return dbParameters;// layerArrayToGroup(all_layers, groupName);
|
|
666 |
} catch (Exception e) {
|
|
667 |
logger.info("Error while creating jdbc layer: " + e.getMessage(), e);
|
|
668 |
NotificationManager.addError("Error while loading layer: "
|
|
669 |
+ e.getMessage(), e);
|
|
670 |
}
|
679 |
671 |
|
680 |
|
for (int i = 0; i < count; i++) {
|
681 |
|
TablesListItem item = selected[i];
|
|
672 |
return null;
|
|
673 |
}
|
682 |
674 |
|
|
675 |
/**
|
|
676 |
* This method process the errors found in a layer
|
|
677 |
*
|
|
678 |
* @param lyr
|
|
679 |
* @param mapControl
|
|
680 |
*/
|
|
681 |
protected void processErrorsOfLayer(FLayer lyr, MapControl mapControl) {
|
|
682 |
this.getMapContext().callNewErrorEvent(null);
|
|
683 |
}
|
683 |
684 |
|
684 |
|
dbParameters[i] = getParameterForTable(item);
|
685 |
|
}
|
|
685 |
private void removeSettingsPanels() {
|
|
686 |
for ( int i = 0; i < getComponentCount(); i++ ) {
|
|
687 |
if ( getComponent(i) instanceof UserTableSettingsPanel ) {
|
|
688 |
remove(i);
|
|
689 |
}
|
|
690 |
}
|
|
691 |
}
|
686 |
692 |
|
687 |
|
return dbParameters;// layerArrayToGroup(all_layers, groupName);
|
688 |
|
} catch (Exception e) {
|
689 |
|
logger.info("Error while creating jdbc layer: " + e.getMessage(), e);
|
690 |
|
NotificationManager.addError("Error while loading layer: "
|
691 |
|
+ e.getMessage(), e);
|
692 |
|
}
|
|
693 |
protected PrepareContext getPrepareDataStoreContext() {
|
|
694 |
if ( this.prepareDSContext == null ) {
|
|
695 |
this.prepareDSContext = new PrepareContext() {
|
|
696 |
public Window getOwnerWindow() {
|
|
697 |
return null;
|
|
698 |
}
|
693 |
699 |
|
694 |
|
return null;
|
695 |
|
}
|
|
700 |
public IProjection getViewProjection() {
|
|
701 |
return WizardDB.this.getMapContext().getProjection();
|
|
702 |
}
|
696 |
703 |
|
697 |
|
/**
|
698 |
|
* This method process the errors found in a layer
|
699 |
|
*
|
700 |
|
* @param lyr
|
701 |
|
* @param mapControl
|
702 |
|
*/
|
|
704 |
};
|
|
705 |
}
|
|
706 |
return this.prepareDSContext;
|
|
707 |
}
|
703 |
708 |
|
704 |
|
protected void processErrorsOfLayer(FLayer lyr, MapControl mapControl) {
|
705 |
|
this.getMapContext().callNewErrorEvent(null);
|
706 |
|
}
|
|
709 |
@Override
|
|
710 |
public void close() {
|
707 |
711 |
|
708 |
|
private void removeSettingsPanels() {
|
709 |
|
for (int i = 0; i < getComponentCount(); i++) {
|
710 |
|
if (getComponent(i) instanceof UserTableSettingsPanel) {
|
711 |
|
remove(i);
|
712 |
|
}
|
713 |
|
}
|
714 |
|
}
|
|
712 |
}
|
715 |
713 |
|
716 |
|
protected PrepareContext getPrepareDataStoreContext() {
|
717 |
|
if (this.prepareDSContext == null) {
|
718 |
|
this.prepareDSContext = new PrepareContext() {
|
719 |
|
public Window getOwnerWindow() {
|
720 |
|
return null;
|
721 |
|
}
|
|
714 |
protected String getLastMessage(Throwable ex) {
|
722 |
715 |
|
723 |
|
public IProjection getViewProjection() {
|
724 |
|
return WizardDB.this.getMapContext().getProjection();
|
725 |
|
}
|
726 |
|
|
727 |
|
};
|
728 |
|
}
|
729 |
|
return this.prepareDSContext;
|
730 |
|
}
|
731 |
|
|
732 |
|
@Override
|
733 |
|
public void close() {
|
734 |
|
|
735 |
|
}
|
736 |
|
|
737 |
|
|
738 |
|
protected String getLastMessage(Throwable ex) {
|
739 |
|
|
740 |
716 |
Throwable p = ex;
|
741 |
|
while (p.getCause() != null && p.getCause() != p) {
|
|
717 |
while ( p.getCause() != null && p.getCause() != p ) {
|
742 |
718 |
p = p.getCause();
|
743 |
719 |
}
|
744 |
720 |
return p.getMessage();
|
745 |
|
}
|
|
721 |
}
|
746 |
722 |
|
747 |
723 |
} // @jve:decl-index=0:visual-constraint="10,10"
|