Search in sources :

Example 1 with GeoServerLayerNode

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

the class GeoServerLayerUpdateTool method extractWorkspaceLayers.

private void extractWorkspaceLayers(GeoServerWorkspaceNode workspaceNode) {
    for (int layerIndex = 0; layerIndex < workspaceNode.getChildCount(); layerIndex++) {
        TreeNode childTreeNode = workspaceNode.getChildAt(layerIndex);
        if (childTreeNode instanceof GeoServerLayerNode) {
            GeoServerLayerNode layerNode = (GeoServerLayerNode) childTreeNode;
            GeoServerLayer layer = layerNode.getLayer();
            layerList.add(layer);
        }
    }
}
Also used : GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) TreeNode(javax.swing.tree.TreeNode) GeoServerLayerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)

Example 2 with GeoServerLayerNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode 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 3 with GeoServerLayerNode

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

the class GeoServerLayerNodeTest method testGeoServerLayerNode.

/**
 * Test method for {@link com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode#GeoServerLayerNode(com.sldeditor.common.filesystem.FileSystemInterface, com.sldeditor.common.data.GeoServerLayer)}.
 */
@Test
public void testGeoServerLayerNode() {
    FileSystemInterface fileHandler = new DummyFileSystemInput();
    GeoServerLayer layer = new GeoServerLayer();
    String expectedLayerName = "layer name";
    layer.setLayerName(expectedLayerName);
    GeoServerLayerNode node = new GeoServerLayerNode(fileHandler, layer);
    assertEquals(layer, node.getLayer());
    assertEquals(fileHandler, node.getHandler());
    assertEquals(BuiltInDataFlavour.GEOSERVER_LAYER_DATAITEM_FLAVOUR, node.getDataFlavour());
    assertNull(node.getDestinationText());
}
Also used : FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) GeoServerLayerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode) Test(org.junit.Test)

Example 4 with GeoServerLayerNode

use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode 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

GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)4 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)4 GeoServerLayerHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode)2 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)2 TreeNode (javax.swing.tree.TreeNode)2 NodeInterface (com.sldeditor.common.NodeInterface)1 FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)1 List (java.util.List)1 Test (org.junit.Test)1