use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode in project sldeditor by robward-scisys.
the class VectorToolTest method testSupports.
/**
* Test method for {@link com.sldeditor.tool.vector.VectorTool#supports(java.util.List, java.util.List, java.util.List)}.
*/
@Test
public void testSupports() {
try {
FileTreeNode vectorTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.shp");
vectorTreeNode.setFileCategory(FileTreeNodeTypeEnum.VECTOR);
FileTreeNode rasterTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.tif");
rasterTreeNode.setFileCategory(FileTreeNodeTypeEnum.RASTER);
List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
// Try vector file
nodeTypeList.add(vectorTreeNode);
VectorTool vectorTool = new VectorTool(null);
assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try raster file
nodeTypeList.clear();
nodeTypeList.add(rasterTreeNode);
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try database feature class
nodeTypeList.clear();
DatabaseFeatureClassNode databaseFeatureClassNode = new DatabaseFeatureClassNode(null, null, "db fc");
nodeTypeList.add(databaseFeatureClassNode);
assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try invalid node class
nodeTypeList.clear();
nodeTypeList.add(new GeoServerStyleHeadingNode(null, null, "test"));
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try with no nodes
nodeTypeList.clear();
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try with null
assertFalse(vectorTool.supports(uniqueNodeTypeList, null, sldDataList));
} catch (SecurityException e) {
e.printStackTrace();
fail();
} catch (FileNotFoundException e) {
e.printStackTrace();
fail();
}
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode 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;
}
use of com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode in project sldeditor by robward-scisys.
the class GeoServerReadProgress method populateStyles.
/**
* Populate styles.
*
* @param connection the connection
* @param geoServerNode the geo server node
*/
private void populateStyles(GeoServerConnection connection, GeoServerNode geoServerNode) {
removeNode(geoServerNode, STYLES_NODE_TITLE);
GeoServerStyleHeadingNode styleNode = new GeoServerStyleHeadingNode(this.handler, connection, STYLES_NODE_TITLE);
geoServerNode.add(styleNode);
Map<String, List<StyleWrapper>> styleMap = geoServerStyleMap.get(connection);
for (String workspaceName : styleMap.keySet()) {
List<StyleWrapper> styleList = styleMap.get(workspaceName);
GeoServerWorkspaceNode workspaceNode = new GeoServerWorkspaceNode(this.handler, connection, workspaceName, true);
// It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
treeModel.insertNodeInto(workspaceNode, styleNode, styleNode.getChildCount());
for (StyleWrapper styleWrapper : styleList) {
GeoServerStyleNode childNode = new GeoServerStyleNode(this.handler, connection, styleWrapper);
// It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
treeModel.insertNodeInto(childNode, workspaceNode, workspaceNode.getChildCount());
}
}
}
Aggregations