Search in sources :

Example 11 with SLDDataInterface

use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.

the class DataSourceImpl method openExternalDataSource.

/**
 * Open external data source.
 *
 * @param typeName the type name
 */
private void openExternalDataSource(String typeName) {
    logger.debug("openExternalDataSource : " + typeName);
    if (externalDataSource == null) {
        ConsoleManager.getInstance().error(this, "No external data source creation object set");
    } else {
        List<DataSourceInfo> dataSourceInfoList = externalDataSource.connect(typeName, null, this.editorFileInterface);
        if ((dataSourceInfoList != null) && (dataSourceInfoList.size() == 1)) {
            dataSourceInfo = dataSourceInfoList.get(0);
            if (dataSourceInfo.hasData()) {
                logger.debug("External data sources:");
                dataSourceInfo.populateFieldMap();
                connectedToDataSourceFlag = true;
            } else {
                openWithoutDataSource();
            }
        }
        // Populate external fields
        DataSourceAttributeList attributeData = new DataSourceAttributeList();
        readAttributes(attributeData);
        SLDDataInterface sldData = this.editorFileInterface.getSLDData();
        sldData.setFieldList(attributeData.getData());
    }
}
Also used : DataSourceAttributeList(com.sldeditor.datasource.attribute.DataSourceAttributeList) SLDDataInterface(com.sldeditor.common.SLDDataInterface)

Example 12 with SLDDataInterface

use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.

the class DataSourceImpl method updateFields.

/**
 * Update fields.
 *
 * @param attributeData the attribute data
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.datasource.DataSourceInterface#updateFields(com.sldeditor.render.iface. RenderAttributeDataInterface)
     */
@Override
public void updateFields(DataSourceAttributeListInterface attributeData) {
    if (attributeData != null) {
        List<DataSourceAttributeData> attributeDataList = attributeData.getData();
        if (this.editorFileInterface != null) {
            this.dataSourceProperties = editorFileInterface.getDataSource();
            SLDDataInterface sldData = this.editorFileInterface.getSLDData();
            if (sldData != null) {
                sldData.setFieldList(attributeDataList);
            }
        }
        this.connectedToDataSourceFlag = false;
        createInternalDataSource();
        notifyDataSourceLoaded();
    }
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) SLDDataInterface(com.sldeditor.common.SLDDataInterface)

Example 13 with SLDDataInterface

use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.

the class DataSourceImpl method addField.

/**
 * Adds the field.
 *
 * @param dataSourceField the data source field
 */
@Override
public void addField(DataSourceAttributeData dataSourceField) {
    if (dataSourceField != null) {
        if (connectedToDataSourceFlag == false) {
            SLDDataInterface sldData = this.editorFileInterface.getSLDData();
            List<DataSourceAttributeData> fieldList = sldData.getFieldList();
            if (fieldList == null) {
                fieldList = new ArrayList<DataSourceAttributeData>();
                sldData.setFieldList(fieldList);
            }
            fieldList.add(dataSourceField);
            createInternalDataSource();
            notifyDataSourceLoaded();
        }
    }
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) SLDDataInterface(com.sldeditor.common.SLDDataInterface)

Example 14 with SLDDataInterface

use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.

the class DataFlavourManager method displayMessages.

/**
 * Display messages.
 *
 * @param destinationTreeNode the destination tree node
 * @param transferredData the transferred data
 * @param action the action
 */
public static void displayMessages(NodeInterface destinationTreeNode, TransferredData transferredData, int action) {
    if ((destinationTreeNode == null) || (transferredData == null)) {
        return;
    }
    String actionString = "???";
    if (action == TransferHandler.MOVE) {
        actionString = "Moved";
    } else if (action == TransferHandler.COPY) {
        actionString = "Copied";
    }
    String destinationString = destinationTreeNode.getHandler().getDestinationText(destinationTreeNode);
    for (int index = 0; index < transferredData.getDataListSize(); index++) {
        NodeInterface nodeToTransfer = (NodeInterface) transferredData.getTreePath(index).getLastPathComponent();
        SelectedFiles selectedFiles = nodeToTransfer.getHandler().getSLDContents(nodeToTransfer);
        for (SLDDataInterface sldData : selectedFiles.getSldData()) {
            ConsoleManager.getInstance().information(DataFlavourManager.class, String.format("%s %s -> %s", actionString, sldData.getLayerName(), destinationString));
        }
    }
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) NodeInterface(com.sldeditor.common.NodeInterface)

Example 15 with SLDDataInterface

use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.

the class SLDFileHandler method internalOpenFile.

/**
 * Internal open file.
 *
 * @param f the file
 * @param list the list
 */
private void internalOpenFile(File f, List<SLDDataInterface> list) {
    if (f.isFile() && FileSystemUtils.isFileExtensionSupported(f, getFileExtensionList())) {
        try {
            String sldContents = readFile(f, Charset.defaultCharset());
            SLDDataInterface sldData = new SLDData(new StyleWrapper(f.getName()), sldContents);
            sldData.setSLDFile(f);
            sldData.setReadOnly(false);
            list.add(sldData);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) IOException(java.io.IOException)

Aggregations

SLDDataInterface (com.sldeditor.common.SLDDataInterface)72 File (java.io.File)34 IOException (java.io.IOException)21 SLDData (com.sldeditor.common.data.SLDData)20 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)20 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)17 URL (java.net.URL)17 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)14 StyleWrapper (com.sldeditor.common.data.StyleWrapper)12 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)12 FileNotFoundException (java.io.FileNotFoundException)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 URISyntaxException (java.net.URISyntaxException)10 NodeInterface (com.sldeditor.common.NodeInterface)9 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)6 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)5 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5