Search in sources :

Example 1 with DataSourceConnectorInterface

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();
}
Also used : DataSourceAttributeList(com.sldeditor.datasource.attribute.DataSourceAttributeList) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface)

Example 2 with DataSourceConnectorInterface

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;
}
Also used : JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface)

Example 3 with DataSourceConnectorInterface

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;
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) DatabaseClientInterface(com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface)

Example 4 with DataSourceConnectorInterface

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());
        }
    }
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) DatabaseClientInterface(com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface)

Example 5 with DataSourceConnectorInterface

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File)

Aggregations

DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)10 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)7 DataSourceConnector (com.sldeditor.datasource.connector.instance.DataSourceConnector)4 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)3 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)3 DataSourceProperties (com.sldeditor.datasource.impl.DataSourceProperties)3 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 Test (org.junit.Test)3 DatabaseClientInterface (com.sldeditor.extension.filesystem.database.client.DatabaseClientInterface)2 FlowLayout (java.awt.FlowLayout)2 HashMap (java.util.HashMap)2 JPanel (javax.swing.JPanel)2 LoadSLDInterface (com.sldeditor.common.LoadSLDInterface)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 DataSourceAttributeList (com.sldeditor.datasource.attribute.DataSourceAttributeList)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 ToolButton (com.sldeditor.tool.ToolButton)1 BorderLayout (java.awt.BorderLayout)1