Search in sources :

Example 1 with SelectedFiles

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

the class SLDEditor method chooseNewSLD.

/**
 * Choose new sld.
 */
@Override
public void chooseNewSLD() {
    NewSLDPanel panel = new NewSLDPanel();
    List<SLDDataInterface> newSLDList = panel.showDialog(Controller.getInstance().getFrame());
    if (newSLDList != null) {
        SelectedFiles selectedFiles = new SelectedFiles();
        selectedFiles.setSldData(newSLDList);
        if (loadSLDString(selectedFiles)) {
            uiMgr.populateUI(1);
        }
    }
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) NewSLDPanel(com.sldeditor.create.NewSLDPanel)

Example 2 with SelectedFiles

use of com.sldeditor.common.filesystem.SelectedFiles 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 3 with SelectedFiles

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

the class GeoServerInput method getSLDContents.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.extension.input.FileSystemInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
     */
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
    if (node instanceof GeoServerStyleNode) {
        GeoServerStyleNode styleNode = (GeoServerStyleNode) node;
        GeoServerConnection connectionData = styleNode.getConnectionData();
        GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
        if (client != null) {
            String sldContent = client.getStyle(styleNode.getStyle());
            SLDDataInterface sldData = new SLDData(styleNode.getStyle(), sldContent);
            sldData.setConnectionData(connectionData);
            sldData.setReadOnly(false);
            List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
            sldDataList.add(sldData);
            SelectedFiles selectedFiles = new SelectedFiles();
            selectedFiles.setSldData(sldDataList);
            selectedFiles.setDataSource(false);
            selectedFiles.setConnectionData(connectionData);
            return selectedFiles;
        }
    } else if (node instanceof GeoServerWorkspaceNode) {
        GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) node;
        GeoServerConnection connectionData = workspaceNode.getConnection();
        GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
        List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
        if (workspaceNode.isStyle()) {
            Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
            if ((client != null) && (styleMap != null)) {
                for (StyleWrapper style : styleMap.get(workspaceNode.getWorkspaceName())) {
                    String sldContent = client.getStyle(style);
                    SLDDataInterface sldData = new SLDData(style, sldContent);
                    sldData.setConnectionData(connectionData);
                    sldData.setReadOnly(false);
                    sldDataList.add(sldData);
                }
            }
        }
        SelectedFiles selectedFiles = new SelectedFiles();
        selectedFiles.setSldData(sldDataList);
        selectedFiles.setDataSource(false);
        selectedFiles.setConnectionData(connectionData);
        return selectedFiles;
    } else if (node instanceof GeoServerStyleHeadingNode) {
        GeoServerStyleHeadingNode styleHeadingNode = (GeoServerStyleHeadingNode) node;
        GeoServerConnection connectionData = styleHeadingNode.getConnection();
        GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connectionData);
        List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
        Map<String, List<StyleWrapper>> styleMap = getStyleMap(connectionData);
        if ((client != null) && (styleMap != null)) {
            for (String workspaceName : styleMap.keySet()) {
                for (StyleWrapper style : styleMap.get(workspaceName)) {
                    String sldContent = client.getStyle(style);
                    SLDDataInterface sldData = new SLDData(style, sldContent);
                    sldData.setConnectionData(connectionData);
                    sldData.setReadOnly(false);
                    sldDataList.add(sldData);
                }
            }
        }
        SelectedFiles selectedFiles = new SelectedFiles();
        selectedFiles.setSldData(sldDataList);
        selectedFiles.setDataSource(false);
        selectedFiles.setConnectionData(connectionData);
        return selectedFiles;
    } else if (node instanceof GeoServerNode) {
        GeoServerNode geoServerNode = (GeoServerNode) node;
        GeoServerConnection connectionData = geoServerNode.getConnection();
        SelectedFiles selectedFiles = new SelectedFiles();
        selectedFiles.setDataSource(false);
        selectedFiles.setConnectionData(connectionData);
        return selectedFiles;
    }
    return null;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) GeoServerStyleNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode) GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerStyleHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with SelectedFiles

use of com.sldeditor.common.filesystem.SelectedFiles 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 5 with SelectedFiles

use of com.sldeditor.common.filesystem.SelectedFiles 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)

Aggregations

SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)14 SLDDataInterface (com.sldeditor.common.SLDDataInterface)12 ArrayList (java.util.ArrayList)7 NodeInterface (com.sldeditor.common.NodeInterface)4 List (java.util.List)3 Test (org.junit.Test)3 LoadSLDInterface (com.sldeditor.common.LoadSLDInterface)2 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)2 SLDData (com.sldeditor.common.data.SLDData)2 DatabaseFeatureClassNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode)2 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)2 File (java.io.File)2 HashMap (java.util.HashMap)2 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)1 PrefData (com.sldeditor.common.preferences.PrefData)1 NewSLDPanel (com.sldeditor.create.NewSLDPanel)1