use of com.sldeditor.common.SLDDataInterface 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.common.SLDDataInterface 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.common.SLDDataInterface in project sldeditor by robward-scisys.
the class FileSystemExtension method treeItemSelected.
/**
* Called to determine the selected items from the tree nodes selected.
*
* @return the selected files
*/
private SelectedFiles treeItemSelected() {
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
List<NodeInterface> nodeList = new ArrayList<NodeInterface>();
SelectedFiles combinedFiles = new SelectedFiles();
TreePath[] selectedPaths = tree.getSelectionPaths();
if (selectedPaths != null) {
for (TreePath selectedPath : selectedPaths) {
Object o = selectedPath.getLastPathComponent();
if (o instanceof NodeInterface) {
NodeInterface handler = (NodeInterface) o;
FileSystemInterface input = handler.getHandler();
SelectedFiles selectedFiles = input.getSLDContents(handler);
if (selectedFiles != null) {
combinedFiles.setDataSource(selectedFiles.isDataSource());
combinedFiles.setFolderName(selectedFiles.getFolderName());
combinedFiles.setConnectionData(selectedFiles.getConnectionData());
combinedFiles.setIsFolder(combinedFiles.isFolder() | selectedFiles.isFolder());
List<SLDDataInterface> handlerDataList = selectedFiles.getSldData();
if (handlerDataList != null) {
combinedFiles.appendSLDData(handlerDataList);
sldDataList.addAll(handlerDataList);
}
}
nodeList.add(handler);
}
}
}
if (toolMgr != null) {
toolMgr.setSelectedItems(nodeList, sldDataList);
}
return combinedFiles;
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class MXDParser method readLayers.
/**
* Read layers from intermediate mxd files.
*
* @param mxdJSON the mxd JSON
* @param outputFormat the output format
* @return the MXD info
*/
public static Map<String, SLDDataInterface> readLayers(String filename, SLDOutputFormatEnum outputFormat) {
if (filename == null) {
return null;
}
File intermediateFile = new File(filename);
if (!intermediateFile.exists()) {
return null;
}
MXDParser parser = new MXDParser();
MXDInfo mxdInfo = new MXDInfo();
mxdInfo.setIntermediateFile(intermediateFile);
JsonObject mxdJSON = convertFileToJSON(filename);
// Read mxd filename
String mxdFilename = "";
JsonElement mxdFilenameJson = mxdJSON.get("mxd");
if (mxdFilenameJson != null) {
mxdFilename = mxdFilenameJson.getAsString();
mxdInfo.setMxdFilename(mxdFilename);
}
File f = new File(mxdFilename);
String mxdName = f.getName();
int pos = mxdName.lastIndexOf("\\");
if (pos > 0) {
mxdName = mxdName.substring(pos + 1);
}
mxdInfo.setMxdName(mxdName);
// Read layers
Map<String, SLDDataInterface> layerMap = new HashMap<String, SLDDataInterface>();
// Read layers
JsonArray layerList = mxdJSON.getAsJsonArray("layers");
for (int index = 0; index < layerList.size(); index++) {
JsonObject layer = (JsonObject) layerList.get(index);
JsonElement layerNameElement = layer.get("name");
if (layerNameElement != null) {
String layerName = layerNameElement.getAsString();
SLDDataInterface sldData = parser.importLayer(layer, outputFormat);
layerMap.put(layerName, sldData);
}
}
return layerMap;
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class SLDTree method repopulateTree.
/**
* Repopulate tree for a undo/redo operation.
*
* @param sldContents the sld contents
*/
private void repopulateTree(String sldContents) {
int[] selectedRows = symbolTree.getSelectionRows();
SLDDataInterface sldData = new SLDData(null, sldContents);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
SelectedSymbol.getInstance().setSld(sld);
populateSLD();
if ((selectedRows != null) && (selectedRows.length > 0)) {
symbolTree.setSelectionRow(selectedRows[0]);
}
}
Aggregations