Search in sources :

Example 6 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerReadProgress method populateLayers.

/**
 * Populate layers.
 *
 * @param connection the connection
 * @param geoServerNode the geo server node
 */
private void populateLayers(GeoServerConnection connection, GeoServerNode geoServerNode) {
    removeNode(geoServerNode, LAYERS_NODE_TITLE);
    GeoServerLayerHeadingNode layersNode = new GeoServerLayerHeadingNode(this.handler, connection, LAYERS_NODE_TITLE);
    geoServerNode.add(layersNode);
    Map<String, List<GeoServerLayer>> layerMap = geoServerLayerMap.get(connection);
    for (String workspaceName : layerMap.keySet()) {
        List<GeoServerLayer> layerList = layerMap.get(workspaceName);
        GeoServerWorkspaceNode workspaceNode = new GeoServerWorkspaceNode(this.handler, connection, workspaceName, false);
        // It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
        treeModel.insertNodeInto(workspaceNode, layersNode, layersNode.getChildCount());
        for (GeoServerLayer layer : layerList) {
            GeoServerLayerNode childNode = new GeoServerLayerNode(this.handler, layer);
            // It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
            treeModel.insertNodeInto(childNode, workspaceNode, workspaceNode.getChildCount());
        }
    }
}
Also used : GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) List(java.util.List) GeoServerLayerHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode) GeoServerLayerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)

Example 7 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerReadProgress method readStylesComplete.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.extension.input.geoserver.GeoServerReadProgressInterface#readStylesComplete(com.sldeditor.extension.input.geoserver.
     * GeoServerConnection, java.util.Map, boolean)
     */
@Override
public void readStylesComplete(GeoServerConnection connection, Map<String, List<StyleWrapper>> styleMap, boolean partialRefresh) {
    if (styleMap == null) {
        return;
    }
    if (partialRefresh) {
        Map<String, List<StyleWrapper>> extistingStyleMap = this.geoServerStyleMap.get(connection);
        for (String workspace : styleMap.keySet()) {
            extistingStyleMap.put(workspace, styleMap.get(workspace));
        }
        GeoServerNode geoServerNode = nodeMap.get(connection);
        for (String workspace : styleMap.keySet()) {
            DefaultMutableTreeNode stylesNode = getNode(geoServerNode, STYLES_NODE_TITLE);
            GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) getNode(stylesNode, workspace);
            refreshWorkspace(connection, workspaceNode);
        }
    } else {
        this.geoServerStyleMap.put(connection, styleMap);
        // Update state
        PopulateState state = populateStateMap.get(connection);
        if (state != null) {
            state.setStylesComplete();
        }
        checkPopulateComplete(connection);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) List(java.util.List)

Example 8 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerInput 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 ((nodeToTransfer == null) || (sldDataList == null)) {
        return;
    }
    if (nodeToTransfer instanceof GeoServerWorkspaceNode) {
        Map<GeoServerClientInterface, String> connectionsToRefreshMap = new HashMap<GeoServerClientInterface, String>();
        for (SLDDataInterface sldData : sldDataList) {
            GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(sldData.getConnectionData());
            if (client != null) {
                connectionsToRefreshMap.put(client, sldData.getStyle().getWorkspace());
                client.deleteStyle(sldData.getStyle());
            }
        }
        // Refreshing the workspace re-populates the user interface
        for (GeoServerClientInterface client : connectionsToRefreshMap.keySet()) {
            client.refreshWorkspace(connectionsToRefreshMap.get(client));
        }
    }
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) HashMap(java.util.HashMap) SLDDataInterface(com.sldeditor.common.SLDDataInterface)

Example 9 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerInput 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>> droppedDataMap) {
    if (droppedDataMap == null) {
        return false;
    }
    if (destinationTreeNode instanceof GeoServerWorkspaceNode) {
        GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) destinationTreeNode;
        GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(workspaceNode.getConnection());
        if (client == null) {
            return false;
        } else {
            for (NodeInterface key : droppedDataMap.keySet()) {
                for (SLDDataInterface sldData : droppedDataMap.get(key)) {
                    StyleWrapper styleWrapper = sldData.getStyle();
                    removeStyleFileExtension(styleWrapper);
                    styleWrapper.setWorkspace(workspaceNode.getWorkspaceName());
                    client.uploadSLD(styleWrapper, sldData.getSld());
                }
            }
            client.refreshWorkspace(workspaceNode.getWorkspaceName());
        }
        return true;
    }
    return false;
}
Also used : 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) NodeInterface(com.sldeditor.common.NodeInterface)

Example 10 with GeoServerWorkspaceNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode in project sldeditor by robward-scisys.

the class GeoServerLayerUpdateTool method setSelectedItems.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
     */
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
    layerList.clear();
    connection = null;
    for (NodeInterface node : nodeTypeList) {
        if (node instanceof GeoServerLayerNode) {
            GeoServerLayerNode layerNode = (GeoServerLayerNode) node;
            GeoServerLayer layer = layerNode.getLayer();
            layerList.add(layer);
            if (connection == null) {
                connection = layer.getConnection();
            }
        } else if (node instanceof GeoServerLayerHeadingNode) {
            GeoServerLayerHeadingNode layerHeadingNode = (GeoServerLayerHeadingNode) node;
            connection = layerHeadingNode.getConnection();
            for (int workspaceIndex = 0; workspaceIndex < layerHeadingNode.getChildCount(); workspaceIndex++) {
                TreeNode treeNode = layerHeadingNode.getChildAt(workspaceIndex);
                if (treeNode instanceof GeoServerWorkspaceNode) {
                    GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) treeNode;
                    extractWorkspaceLayers(workspaceNode);
                }
            }
        } else if (node instanceof GeoServerWorkspaceNode) {
            GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) node;
            if (!workspaceNode.isStyle()) {
                connection = workspaceNode.getConnection();
                extractWorkspaceLayers(workspaceNode);
            }
        }
    }
}
Also used : GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) TreeNode(javax.swing.tree.TreeNode) GeoServerLayerHeadingNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode) NodeInterface(com.sldeditor.common.NodeInterface) GeoServerLayerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)

Aggregations

GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)11 SLDDataInterface (com.sldeditor.common.SLDDataInterface)5 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 StyleWrapper (com.sldeditor.common.data.StyleWrapper)5 List (java.util.List)5 NodeInterface (com.sldeditor.common.NodeInterface)3 SLDData (com.sldeditor.common.data.SLDData)3 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Test (org.junit.Test)3 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)2 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)2 GeoServerLayerHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode)2 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)2 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)2 GeoServerStyleHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode)2 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)2 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)2