Search in sources :

Example 11 with NodeInterface

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();
}
Also used : GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) NodeInterface(com.sldeditor.common.NodeInterface)

Example 12 with NodeInterface

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);
    }
}
Also used : ArrayList(java.util.ArrayList) NodeInterface(com.sldeditor.common.NodeInterface)

Example 13 with NodeInterface

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());
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HashMap(java.util.HashMap) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) DataFlavor(java.awt.datatransfer.DataFlavor) TransferredData(com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData) TreePath(javax.swing.tree.TreePath) TransferableDataItem(com.sldeditor.datasource.extension.filesystem.node.TransferableDataItem) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test)

Example 14 with NodeInterface

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;
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) StyleWrapper(com.sldeditor.common.data.StyleWrapper) NodeInterface(com.sldeditor.common.NodeInterface)

Example 15 with NodeInterface

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;
}
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)

Aggregations

NodeInterface (com.sldeditor.common.NodeInterface)26 SLDDataInterface (com.sldeditor.common.SLDDataInterface)9 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)9 ArrayList (java.util.ArrayList)8 File (java.io.File)7 IOException (java.io.IOException)7 Test (org.junit.Test)7 TransferredData (com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData)5 FileNotFoundException (java.io.FileNotFoundException)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 TreePath (javax.swing.tree.TreePath)5 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)4 JTree (javax.swing.JTree)4 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)3 DatabaseNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode)3 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)3 DataFlavor (java.awt.datatransfer.DataFlavor)3 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)3 HashMap (java.util.HashMap)3 List (java.util.List)3