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());
}
}
}
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);
}
}
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));
}
}
}
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;
}
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);
}
}
}
}
Aggregations