Search in sources :

Example 6 with SelectedFiles

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());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with SelectedFiles

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());
}
Also used : PrefData(com.sldeditor.common.preferences.PrefData) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Example 8 with SelectedFiles

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;
}
Also used : FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) TreePath(javax.swing.tree.TreePath) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList) NodeInterface(com.sldeditor.common.NodeInterface)

Example 9 with SelectedFiles

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);
    }
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ExtensionInterface(com.sldeditor.extension.ExtensionInterface)

Example 10 with 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);
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList) List(java.util.List) NodeInterface(com.sldeditor.common.NodeInterface) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)14 SLDDataInterface (com.sldeditor.common.SLDDataInterface)12 ArrayList (java.util.ArrayList)7 NodeInterface (com.sldeditor.common.NodeInterface)4 List (java.util.List)3 Test (org.junit.Test)3 LoadSLDInterface (com.sldeditor.common.LoadSLDInterface)2 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)2 SLDData (com.sldeditor.common.data.SLDData)2 DatabaseFeatureClassNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode)2 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)2 File (java.io.File)2 HashMap (java.util.HashMap)2 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)1 PrefData (com.sldeditor.common.preferences.PrefData)1 NewSLDPanel (com.sldeditor.create.NewSLDPanel)1