use of com.sldeditor.common.filesystem.SelectedFiles in project sldeditor by robward-scisys.
the class SelectedFilesTest method test.
@Test
public void test() {
SelectedFiles selectedFiles = new SelectedFiles();
assertTrue(selectedFiles.isDataSource() == false);
assertTrue(selectedFiles.isFolder() == false);
assertTrue(selectedFiles.getSldData().isEmpty());
selectedFiles.setDataSource(true);
assertTrue(selectedFiles.isDataSource());
selectedFiles.setIsFolder(true);
assertTrue(selectedFiles.isFolder());
List<SLDDataInterface> actualSldData = new ArrayList<SLDDataInterface>();
actualSldData.add(new SLDData(null, "test1"));
actualSldData.add(new SLDData(null, "test2"));
actualSldData.add(new SLDData(null, "test3"));
selectedFiles.setSldData(actualSldData);
assertTrue(selectedFiles.getSldData().size() == actualSldData.size());
}
use of com.sldeditor.common.filesystem.SelectedFiles in project sldeditor by robward-scisys.
the class PrefManagerTest method testSetLastFolderViewed.
/**
* Test method for {@link com.sldeditor.common.preferences.PrefManager#setLastFolderViewed()}.
*/
@Test
public void testSetLastFolderViewed() {
PrefManager.initialise(null);
DummyPropertyManager propertyManager = new DummyPropertyManager();
PrefManager.initialise(propertyManager);
// Try with a null argument
PrefManager.getInstance().setLastFolderViewed(null);
PrefData actualPrefData = PrefManager.getInstance().getPrefData();
assertFalse(actualPrefData.isSaveLastFolderView());
assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
assertNull(actualPrefData.getLastFolderViewed());
// Try with an empty selected files object
SelectedFiles selectedFiles = new SelectedFiles();
PrefManager.getInstance().setLastFolderViewed(selectedFiles);
actualPrefData = PrefManager.getInstance().getPrefData();
assertFalse(actualPrefData.isSaveLastFolderView());
assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
assertNull(actualPrefData.getLastFolderViewed());
// Set folder
String expectedFolderName = "/tmp/test/abc";
selectedFiles.setFolderName(expectedFolderName);
PrefManager.getInstance().setLastFolderViewed(selectedFiles);
actualPrefData = PrefManager.getInstance().getPrefData();
assertFalse(actualPrefData.isSaveLastFolderView());
assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
assertEquals(expectedFolderName, actualPrefData.getLastFolderViewed());
expectedFolderName = "c:/tmp/test/abc";
selectedFiles.setFolderName(expectedFolderName);
PrefManager.getInstance().setLastFolderViewed(selectedFiles);
actualPrefData = PrefManager.getInstance().getPrefData();
assertFalse(actualPrefData.isSaveLastFolderView());
assertEquals(PrefDataLastViewedEnum.FOLDER, actualPrefData.getLastViewedKey());
assertEquals(expectedFolderName, actualPrefData.getLastFolderViewed());
actualPrefData.setSaveLastFolderView(true);
PrefManager.getInstance().setPrefData(actualPrefData);
actualPrefData = PrefManager.getInstance().getPrefData();
assertTrue(actualPrefData.isSaveLastFolderView());
// Set geoserver
String expectedGeoServerName = "GeoServer test";
GeoServerConnection connectionData = new GeoServerConnection();
connectionData.setConnectionName(expectedGeoServerName);
selectedFiles = new SelectedFiles();
selectedFiles.setConnectionData(connectionData);
PrefManager.getInstance().setLastFolderViewed(selectedFiles);
actualPrefData = PrefManager.getInstance().getPrefData();
assertTrue(actualPrefData.isSaveLastFolderView());
assertEquals(PrefDataLastViewedEnum.GEOSERVER, actualPrefData.getLastViewedKey());
assertEquals(expectedGeoServerName, actualPrefData.getLastFolderViewed());
}
use of com.sldeditor.common.filesystem.SelectedFiles 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.filesystem.SelectedFiles in project sldeditor by robward-scisys.
the class SLDEditor method openFile.
/**
* Open file.
*
* @param url the url
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.SLDEditorInterface#openFile(java.net.URL)
*/
@Override
public void openFile(URL url) {
List<SLDDataInterface> sldDataList = null;
for (ExtensionInterface extension : extensionList) {
if (sldDataList == null) {
sldDataList = extension.open(url);
}
}
if (sldDataList != null) {
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldDataList);
loadSLDString(selectedFiles);
}
}
use of com.sldeditor.common.filesystem.SelectedFiles in project sldeditor by robward-scisys.
the class DataFlavourManager method copy.
/**
* Copy.
*
* @param destinationTreeNode the destination tree node
* @param transferredData the transferred data
* @return true, if successful
*/
public static boolean copy(NodeInterface destinationTreeNode, TransferredData transferredData) {
if ((destinationTreeNode == null) || (transferredData == null)) {
return false;
}
Map<NodeInterface, List<SLDDataInterface>> map = new LinkedHashMap<NodeInterface, List<SLDDataInterface>>();
for (int index = 0; index < transferredData.getDataListSize(); index++) {
NodeInterface nodeToTransfer = (NodeInterface) transferredData.getTreePath(index).getLastPathComponent();
SelectedFiles selectedFiles = nodeToTransfer.getHandler().getSLDContents(nodeToTransfer);
map.put(nodeToTransfer, selectedFiles.getSldData());
}
return destinationTreeNode.getHandler().copyNodes(destinationTreeNode, map);
}
Aggregations