use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class GeoServerConnectionTool 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) {
connectionList.clear();
for (NodeInterface node : nodeTypeList) {
if (node instanceof GeoServerNode) {
GeoServerNode geoserverNode = (GeoServerNode) node;
connectionList.add(geoserverNode.getConnection());
}
}
updateButtonState();
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class ToolManager method forwardSelectedItems.
/**
* Forward selected items.
*
* @param nodeTypeList the node type list
* @param sldDataList the sld data list
*/
private void forwardSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
if (toolPanel != null) {
List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
if (nodeTypeList != null) {
for (NodeInterface o : nodeTypeList) {
if (!uniqueNodeTypeList.contains(o.getClass())) {
uniqueNodeTypeList.add(o.getClass());
}
}
}
toolPanel.setSelectedItems(uniqueNodeTypeList, nodeTypeList, sldDataList);
}
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class TransferableDataItemTest method testTransferableDataItem.
/**
* Test method for
* {@link com.sldeditor.datasource.extension.filesystem.node.TransferableDataItem#TransferableDataItem()}.
*/
@Test
public void testTransferableDataItem() {
Map<NodeInterface, TreePath> selectedData = new HashMap<NodeInterface, TreePath>();
FileTreeNode fileTreeNode1 = null;
FileTreeNode fileTreeNode2 = null;
FileTreeNode fileTreeNode3 = null;
FileTreeNode fileTreeNode4 = null;
try {
fileTreeNode1 = new FileTreeNode(new File(System.getProperty("user.dir")), "file1.txt");
fileTreeNode2 = new FileTreeNode(new File(System.getProperty("user.dir")), "file2.txt");
fileTreeNode3 = new FileTreeNode(new File(System.getProperty("user.dir")), "file3.txt");
fileTreeNode4 = new FileTreeNode(new File(System.getProperty("user.dir")), "file4.txt");
selectedData.put(fileTreeNode1, new TreePath(new DefaultMutableTreeNode("branch1")));
selectedData.put(fileTreeNode2, new TreePath(new DefaultMutableTreeNode("branch2")));
selectedData.put(fileTreeNode3, new TreePath(new DefaultMutableTreeNode("branch3")));
selectedData.put(fileTreeNode4, new TreePath(new DefaultMutableTreeNode("branch4")));
TransferableDataItem dataItem = new TransferableDataItem(selectedData);
DataFlavor dataFlavour = dataItem.getDataFlavour();
assertEquals(FileTreeNode.class, dataFlavour.getRepresentationClass());
try {
Object data = dataItem.getTransferData(DataFlavourManager.FOLDER_DATAITEM_FLAVOR);
assertTrue(data instanceof TransferredData);
assertEquals(selectedData.size(), ((TransferredData) data).getDataListSize());
assertFalse(dataItem.isDataFlavorSupported(BuiltInDataFlavour.GEOSERVER_DATAITEM_FLAVOUR));
assertTrue(dataItem.isDataFlavorSupported(DataFlavourManager.FOLDER_DATAITEM_FLAVOR));
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.common.NodeInterface 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.NodeInterface 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;
}
Aggregations