use of com.sldeditor.extension.filesystem.file.FileSystemInput in project sldeditor by robward-scisys.
the class FileSystemExtension method save.
/**
* Save.
*
* @param sldData the sld data
* @return true, if successful
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.ExtensionInterface#save(java.net.URL, com.sldeditor.ui.iface.SLDDataInterface)
*/
@Override
public boolean save(SLDDataInterface sldData) {
boolean saved = false;
for (FileSystemInterface extension : extensionList) {
if (saved == false) {
saved = extension.save(sldData);
}
}
if (saved) {
FileSystemInput fileSystemInput = FileSystemExtensionFactory.getFileSystemInput();
if (fileSystemInput != null) {
fileSystemInput.setFolder(sldData.getSLDURL(), true);
}
}
sldSaved = true;
return saved;
}
use of com.sldeditor.extension.filesystem.file.FileSystemInput in project sldeditor by robward-scisys.
the class FileSystemExtensionFactory method populateExtensions.
/**
* Populate default file extensions.
*
* @param toolMgr the tool manager
*/
private static void populateExtensions(ToolSelectionInterface toolMgr) {
geoServerInput = new GeoServerInput(toolMgr);
geoServerInput.readPropertyFile();
extensionList.add(geoServerInput);
databaseInput = new DatabaseInput(toolMgr);
databaseInput.readPropertyFile();
extensionList.add(databaseInput);
fileSystemInput = new FileSystemInput(toolMgr);
extensionList.add(fileSystemInput);
}
use of com.sldeditor.extension.filesystem.file.FileSystemInput in project sldeditor by robward-scisys.
the class FileSystemInputTest method testGetNodeTypes.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.file.FileSystemInput#getNodeTypes()}.
*/
@Test
public void testGetNodeTypes() {
FileSystemInput input = new FileSystemInput(null);
assertTrue(input.getNodeTypes().isEmpty());
}
use of com.sldeditor.extension.filesystem.file.FileSystemInput in project sldeditor by robward-scisys.
the class FileSystemInputTest method testFileSystemInput.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.file.FileSystemInput#FileSystemInput(com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testFileSystemInput() {
FileSystemInput input = new FileSystemInput(null);
FSTree tree = new FSTree();
DefaultMutableTreeNode rootNode;
try {
rootNode = new DefaultMutableTreeNode("Root");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
input.populate(tree, model, rootNode);
URL url = SLDFileHandlerTest.class.getResource("/point/sld/point_attribute.sld");
List<SLDDataInterface> sldDataList = input.open(url);
assertEquals(1, sldDataList.size());
File parent = null;
try {
parent = new File(url.toURI());
parent = parent.getParentFile();
} catch (URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}
FileTreeNode fileTreeNode = new FileTreeNode(parent, "point_attribute.sld");
List<SLDDataInterface> sldDataContentsList = input.getSLDContents(fileTreeNode).getSldData();
assertEquals(1, sldDataContentsList.size());
// Changes where the file is to be saved to
File saveFile = File.createTempFile(getClass().getSimpleName(), ".sld");
SLDData sldData = (SLDData) sldDataContentsList.get(0);
sldData.setSLDFile(saveFile);
assertFalse(input.save(null));
assertTrue(input.save(sldData));
saveFile.delete();
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.sldeditor.extension.filesystem.file.FileSystemInput in project sldeditor by robward-scisys.
the class FileSystemInputTest method testCopyNodes.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.file.FileSystemInput#copyNodes(com.sldeditor.common.NodeInterface, java.util.Map)}.
*/
@Test
public void testCopyNodes() {
FileSystemInput input = new FileSystemInput(null);
URL url = SLDFileHandlerTest.class.getResource("/point/sld/point_attribute.sld");
List<SLDDataInterface> sldDataList = input.open(url);
assertEquals(1, sldDataList.size());
try {
Path tempFolder = Files.createTempDirectory(getClass().getSimpleName());
File tempFolderFile = tempFolder.toFile();
FileTreeNode destinationTreeNode = new FileTreeNode(tempFolderFile.getParentFile(), tempFolderFile.getName());
Map<NodeInterface, List<SLDDataInterface>> copyDataMap = new HashMap<NodeInterface, List<SLDDataInterface>>();
copyDataMap.put(destinationTreeNode, sldDataList);
assertTrue(input.copyNodes(destinationTreeNode, copyDataMap));
SLDData sldData = (SLDData) sldDataList.get(0);
sldData.setSLDFile(new File(tempFolderFile, "point_attribute.sld"));
input.deleteNodes(destinationTreeNode, sldDataList);
tempFolderFile.deleteOnExit();
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations