Revision 43377 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionPanel.java
DefaultJDBCConnectionPanel.java | ||
---|---|---|
20 | 20 |
import javax.swing.plaf.basic.BasicHTML; |
21 | 21 |
import javax.swing.text.View; |
22 | 22 |
import org.apache.commons.lang3.ArrayUtils; |
23 |
import org.apache.commons.lang3.BooleanUtils; |
|
23 | 24 |
import org.apache.commons.lang3.StringUtils; |
24 | 25 |
import org.gvsig.fmap.dal.DALLocator; |
25 | 26 |
import org.gvsig.fmap.dal.DataFactory; |
... | ... | |
46 | 47 |
private static final long serialVersionUID = -6119489353793596382L; |
47 | 48 |
private JDBCServerExplorerParameters forcedParameters; |
48 | 49 |
private ItemListener onChangeConnectorItemListener; |
50 |
private ConnectorFilter connectorFilter=null; |
|
49 | 51 |
|
50 | 52 |
@Override |
51 | 53 |
public JComponent asJComponent() { |
... | ... | |
156 | 158 |
private void translate() { |
157 | 159 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
158 | 160 |
|
161 |
this.lblFile.setText(i18nManager.getTranslation("_File")); |
|
159 | 162 |
this.lblConnectionName.setText(i18nManager.getTranslation("_Connection_name")); |
160 | 163 |
this.lblConnector.setText(i18nManager.getTranslation("_Driver_type")); |
161 | 164 |
this.lblServer.setText(i18nManager.getTranslation("_Host")); |
... | ... | |
200 | 203 |
this.txtUsername.setEnabled( !( field.isReadOnly() || field.isHidden() )); |
201 | 204 |
field = definition.getDynField(JDBCServerExplorerParameters.PASSWORD_PARAMTER_NAME); |
202 | 205 |
this.txtPassword.setEnabled( !( field.isReadOnly() || field.isHidden() )); |
203 |
this.btnDataBaseBrowser.setVisible(parameters instanceof FilesystemStoreParameters); |
|
206 |
if( parameters instanceof FilesystemStoreParameters ) { |
|
207 |
File f = ((FilesystemStoreParameters) parameters).getFile(); |
|
208 |
if( f==null ) { |
|
209 |
this.txtFile.setText(""); |
|
210 |
} else { |
|
211 |
this.txtFile.setText(f.getAbsolutePath()); |
|
212 |
} |
|
213 |
this.btnDataBaseBrowser.setVisible(true); |
|
214 |
this.txtFile.setVisible(true); |
|
215 |
this.lblFile.setVisible(true); |
|
216 |
} else { |
|
217 |
this.btnDataBaseBrowser.setVisible(false); |
|
218 |
this.txtFile.setVisible(false); |
|
219 |
this.lblFile.setVisible(false); |
|
220 |
} |
|
204 | 221 |
} |
205 | 222 |
|
206 | 223 |
@Override |
... | ... | |
338 | 355 |
} |
339 | 356 |
return -1; |
340 | 357 |
} |
358 |
|
|
359 |
@Override |
|
360 |
public void setConnectorFilter(ConnectorFilter connectorFilter) { |
|
361 |
this.connectorFilter = connectorFilter; |
|
362 |
fillConnections(); |
|
363 |
fillConnectors(); |
|
364 |
} |
|
341 | 365 |
|
342 | 366 |
private void fillConnectors() { |
343 | 367 |
DataManager dataManager = DALLocator.getDataManager(); |
344 | 368 |
|
345 | 369 |
ServerExplorerParametersComboItem last = null; |
370 |
this.cboConnectors.removeAllItems(); |
|
346 | 371 |
this.cboConnectors.addItem(new ServerExplorerParametersComboItem("",null)); |
347 | 372 |
|
348 | 373 |
for (DataFactory factory : dataManager.getServerExplorerRegister() ) { |
349 | 374 |
DataServerExplorerParameters params = (DataServerExplorerParameters) factory.createParameters(); |
350 | 375 |
if ( params instanceof JDBCServerExplorerParameters ) { |
351 |
if( params.getClass() == JDBCServerExplorerParameters.class && |
|
352 |
last == null ) { |
|
353 |
// Si es el proveedor generico de JDBC, lo guarda para |
|
354 |
// a?adirlo al final del combo. |
|
355 |
last = new ServerExplorerParametersComboItem( |
|
356 |
factory.getDescription(), |
|
357 |
(JDBCServerExplorerParameters) params |
|
358 |
); |
|
359 |
} else { |
|
360 |
this.cboConnectors.addItem( |
|
361 |
new ServerExplorerParametersComboItem( |
|
376 |
if( this.connectorFilter==null || this.connectorFilter.accept((JDBCServerExplorerParameters) params) ) { |
|
377 |
if( params.getClass() == JDBCServerExplorerParameters.class && |
|
378 |
last == null ) { |
|
379 |
// Si es el proveedor generico de JDBC, lo guarda para |
|
380 |
// a?adirlo al final del combo. |
|
381 |
last = new ServerExplorerParametersComboItem( |
|
362 | 382 |
factory.getDescription(), |
363 | 383 |
(JDBCServerExplorerParameters) params |
364 |
) |
|
365 |
); |
|
384 |
); |
|
385 |
} else { |
|
386 |
this.cboConnectors.addItem( |
|
387 |
new ServerExplorerParametersComboItem( |
|
388 |
factory.getDescription(), |
|
389 |
(JDBCServerExplorerParameters) params |
|
390 |
) |
|
391 |
); |
|
392 |
} |
|
366 | 393 |
} |
367 | 394 |
} |
368 | 395 |
} |
... | ... | |
376 | 403 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
377 | 404 |
|
378 | 405 |
DataServerExplorerParameters params; |
379 |
|
|
406 |
this.cboConnections.removeAllItems(); |
|
380 | 407 |
Iterator it = pool.iterator(); |
381 | 408 |
while ( it.hasNext() ) { |
382 | 409 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next(); |
383 | 410 |
if ( entry.getExplorerParameters() instanceof JDBCServerExplorerParameters ) { |
384 |
JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) entry.getExplorerParameters(); |
|
385 |
this.cboConnections.addItem( |
|
386 |
new ServerExplorerParametersComboItem(entry.getName(), dbParams) |
|
387 |
); |
|
411 |
if( this.connectorFilter==null || this.connectorFilter.accept((JDBCServerExplorerParameters) entry.getExplorerParameters()) ) { |
|
412 |
JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) entry.getExplorerParameters(); |
|
413 |
this.cboConnections.addItem( |
|
414 |
new ServerExplorerParametersComboItem(entry.getName(), dbParams) |
|
415 |
); |
|
416 |
} |
|
388 | 417 |
} |
389 | 418 |
} |
390 | 419 |
this.cboConnections.setSelectedIndex(-1); |
... | ... | |
397 | 426 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
398 | 427 |
|
399 | 428 |
pool.remove(name); |
429 |
fillConnections(); |
|
400 | 430 |
} |
401 | 431 |
|
402 | 432 |
@Override |
... | ... | |
424 | 454 |
return; |
425 | 455 |
} |
426 | 456 |
((FilesystemStoreParameters)this.forcedParameters).setFile(files[0]); |
427 |
this.txtDataBase.setText(this.forcedParameters.getDBName());
|
|
457 |
this.txtFile.setText(((FilesystemStoreParameters)(this.forcedParameters)).getFile().getAbsolutePath());
|
|
428 | 458 |
} |
429 | 459 |
} |
Also available in: Unified diff