use of com.sldeditor.common.DataSourceConnectorInterface in project sldeditor by robward-scisys.
the class DataSourceConfigPanel method dataSourceLoaded.
/*
* (non-Javadoc)
*
* @see com.sldeditor.datasource.DataSourceUpdatedInterface#dataSourceLoaded(com.sldeditor.datasource.impl.GeometryTypeEnum, boolean)
*/
@Override
public void dataSourceLoaded(GeometryTypeEnum geometryType, boolean isConnectedToDataSourceFlag) {
this.isConnectedToDataSourceFlag = isConnectedToDataSourceFlag;
if (attributeData == null) {
attributeData = new DataSourceAttributeList();
}
// Populate data source properties panel
DataSourcePropertiesInterface dataSourceProperties = dataSource.getDataConnectorProperties();
if (dataSourceProperties != null) {
dataSourceProperties.populate();
// Display the correct data source connector panel
DataSourceConnectorInterface dsc = dataSourceProperties.getDataSourceConnector();
showPanel(dsc.getDisplayName());
}
// Populate table
dataSource.readAttributes(attributeData);
if (dataModel != null) {
dataModel.setConnectedToDataSource(isConnectedToDataSourceFlag);
dataModel.populate(attributeData.getData());
setPopulatingTable(true);
dataModel.fireTableDataChanged();
setPopulatingTable(false);
}
updateButtonState();
}
use of com.sldeditor.common.DataSourceConnectorInterface in project sldeditor by robward-scisys.
the class DataSourceConfigPanel method createDataSourceConnectorPanel.
/**
* Creates the data source connector panel.
*
* @return the component
*/
private Component createDataSourceConnectorPanel() {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
Map<Class<?>, DataSourceConnectorInterface> dscMap = DataSourceConnectorFactory.getDataSourceConnectorList();
//
// Set up the card layout from the available data source connectors
//
dscPanel = new JPanel();
dscPanel.setLayout(new CardLayout());
for (Class<?> key : dscMap.keySet()) {
DataSourceConnectorInterface dsConnector = dscMap.get(key);
JPanel panelToAdd = dsConnector.getPanel();
dscPanel.add(panelToAdd, dsConnector.getDisplayName());
}
mainPanel.add(dscPanel, BorderLayout.CENTER);
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout(FlowLayout.LEADING));
JLabel label = new JLabel(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.dataSource"));
panel1.add(label);
mainPanel.add(panel1, BorderLayout.NORTH);
return mainPanel;
}
use of com.sldeditor.common.DataSourceConnectorInterface in project sldeditor by robward-scisys.
the class VectorTool method importFeatureClass.
/**
* Import feature class.
*
* @param featureClassNode the feature class node
* @return true, if successful
*/
protected boolean importFeatureClass(DatabaseFeatureClassNode featureClassNode) {
if (featureClassNode != null) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), featureClassNode.toString()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(featureClassNode.getConnectionData(), featureClassNode.toString());
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
loadSymbol(dsProperties, sldData, featureClassNode.toString(), featureClassNode.getConnectionData().getConnectionName());
}
}
return false;
}
use of com.sldeditor.common.DataSourceConnectorInterface in project sldeditor by robward-scisys.
the class VectorTool method setDataSource.
/**
* Sets the data source.
*
* @param featureClassNode the new data source
*/
protected void setDataSource(DatabaseFeatureClassNode featureClassNode) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.setDataSource"), featureClassNode.toString()));
// Vector file
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
SLDEditorFile.getInstance().setDataSource(dsProperties);
DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
if (dataSource != null) {
dataSource.connect(featureClassNode.toString(), SLDEditorFile.getInstance(), CheckAttributeFactory.getCheckList());
}
}
}
use of com.sldeditor.common.DataSourceConnectorInterface in project sldeditor by robward-scisys.
the class VectorTool method importFile.
/**
* Import file.
*
* @param fileTreeNode the file tree node
*/
protected boolean importFile(FileTreeNode fileTreeNode) {
if (fileTreeNode != null) {
File vectorFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), vectorFile.getAbsolutePath()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(vectorFile);
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
try {
String vectorFilename = vectorFile.toURI().toURL().toString();
dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(vectorFilename));
} catch (MalformedURLException exceptionObj) {
ConsoleManager.getInstance().exception(VectorTool.class, exceptionObj);
return false;
}
loadSymbol(dsProperties, sldData, vectorFile);
}
return true;
}
Aggregations