Search in sources :

Example 21 with SLDDataInterface

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

the class DatabaseInput method getSLDContents.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.extension.input.FileSystemInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
     */
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
    SelectedFiles selectedFiles = new SelectedFiles();
    if (node instanceof DatabaseFeatureClassNode) {
        List<SLDDataInterface> sldContentList = new ArrayList<SLDDataInterface>();
        selectedFiles.setSldData(sldContentList);
        selectedFiles.setDataSource(true);
    }
    return selectedFiles;
}
Also used : DatabaseFeatureClassNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList)

Example 22 with SLDDataInterface

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

the class FileSystemInput method getSLDContents.

/**
 * Gets the SLD contents.
 *
 * @param node the node
 * @return the SLD contents
 */
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
    SelectedFiles selectedFiles = new SelectedFiles();
    if (node instanceof FileTreeNode) {
        FileTreeNode fileTreeNode = (FileTreeNode) node;
        selectedFiles.setIsFolder(fileTreeNode.isDir());
        File f = fileTreeNode.getFile();
        String folderName = f.isFile() ? f.getParent() : f.getAbsolutePath();
        selectedFiles.setFolderName(folderName);
    }
    for (FileHandlerInterface handler : fileHandlerMap.values()) {
        List<SLDDataInterface> sldContentList = handler.getSLDContents(node);
        if (sldContentList != null) {
            selectedFiles.setSldData(sldContentList);
            selectedFiles.setDataSource(handler.isDataSource());
            return selectedFiles;
        }
    }
    return selectedFiles;
}
Also used : FileHandlerInterface(com.sldeditor.datasource.extension.filesystem.node.file.FileHandlerInterface) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) File(java.io.File) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

Example 23 with SLDDataInterface

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

the class FileSystemInput method deleteNodes.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.extension.input.FileSystemInterface#deleteNodes(com.sldeditor.extension.input.
     * NodeInterface, java.util.List)
     */
@Override
public void deleteNodes(NodeInterface nodeToTransfer, List<SLDDataInterface> sldDataList) {
    if (sldDataList == null) {
        return;
    }
    if (nodeToTransfer instanceof FileTreeNode) {
        for (SLDDataInterface sldData : sldDataList) {
            String sldFilename = sldData.getSLDFile().getAbsolutePath();
            File file = new File(sldFilename);
            file.delete();
        }
        DefaultMutableTreeNode destinationNode = (DefaultMutableTreeNode) nodeToTransfer;
        TreeNode parent = destinationNode.getParent();
        destinationNode.removeFromParent();
        if (treeModel != null) {
            treeModel.reload(parent);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) TreeNode(javax.swing.tree.TreeNode) File(java.io.File) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

Example 24 with SLDDataInterface

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

the class FileSystemInput method copyNodes.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.extension.input.FileSystemInterface#drop(com.sldeditor.extension.input.
     * NodeInterface, java.util.Map)
     */
@Override
public boolean copyNodes(NodeInterface destinationTreeNode, Map<NodeInterface, List<SLDDataInterface>> copyDataMap) {
    if ((destinationTreeNode == null) || (copyDataMap == null)) {
        return false;
    }
    FileTreeNode destinationNode = (FileTreeNode) destinationTreeNode;
    if (!destinationNode.isDir()) {
        destinationNode = (FileTreeNode) destinationNode.getParent();
    }
    File destinationFolder = destinationNode.getFile();
    for (NodeInterface key : copyDataMap.keySet()) {
        List<SLDDataInterface> sldDataList = copyDataMap.get(key);
        for (SLDDataInterface sldData : sldDataList) {
            String sldFilename = sldData.getSLDFile().getAbsolutePath();
            FileHandlerInterface handler = getFileHandler(sldFilename);
            if (handler != null) {
                String sldName = handler.getSLDName(sldData);
                File existingFolder = new File(sldFilename).getParentFile();
                if (existingFolder.equals(destinationFolder)) {
                    sldName = "Copy of " + sldName;
                }
                File updateFile = new File(destinationFolder, sldName);
                sldData.setSLDFile(updateFile);
                save(sldData);
            }
        }
        destinationNode.refreshFolder();
        if (treeModel != null) {
            treeModel.reload(destinationNode);
        }
    }
    return true;
}
Also used : FileHandlerInterface(com.sldeditor.datasource.extension.filesystem.node.file.FileHandlerInterface) SLDDataInterface(com.sldeditor.common.SLDDataInterface) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

Example 25 with SLDDataInterface

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

the class RenderPanelImpl method renderSymbol.

/**
 * Render symbol.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.marker.iface.RenderSymbolInterface#renderSymbol()
     */
@Override
public void renderSymbol() {
    validSymbol = SelectedSymbol.getInstance().isValid();
    if (validSymbol) {
        StyledLayerDescriptor sld = SelectedSymbol.getInstance().getSld();
        SLDDataInterface sldData = SLDEditorFile.getInstance().getSLDData();
        if (sld != null) {
            for (SLDOutputInterface sldOutput : sldOutputList) {
                sldOutput.updatedSLD(sldData, sld);
            }
            renderSymbol((Style) renderSymbol.getRenderStyle(SelectedSymbol.getInstance()));
        } else {
            renderSymbol(null);
        }
    } else {
        repaint();
    }
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SLDOutputInterface(com.sldeditor.common.output.SLDOutputInterface)

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