Search in sources :

Example 6 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class DataFlavourManager method displayMessages.

/**
 * Display messages.
 *
 * @param destinationTreeNode the destination tree node
 * @param transferredData the transferred data
 * @param action the action
 */
public static void displayMessages(NodeInterface destinationTreeNode, TransferredData transferredData, int action) {
    if ((destinationTreeNode == null) || (transferredData == null)) {
        return;
    }
    String actionString = "???";
    if (action == TransferHandler.MOVE) {
        actionString = "Moved";
    } else if (action == TransferHandler.COPY) {
        actionString = "Copied";
    }
    String destinationString = destinationTreeNode.getHandler().getDestinationText(destinationTreeNode);
    for (int index = 0; index < transferredData.getDataListSize(); index++) {
        NodeInterface nodeToTransfer = (NodeInterface) transferredData.getTreePath(index).getLastPathComponent();
        SelectedFiles selectedFiles = nodeToTransfer.getHandler().getSLDContents(nodeToTransfer);
        for (SLDDataInterface sldData : selectedFiles.getSldData()) {
            ConsoleManager.getInstance().information(DataFlavourManager.class, String.format("%s %s -> %s", actionString, sldData.getLayerName(), destinationString));
        }
    }
}
Also used : SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) NodeInterface(com.sldeditor.common.NodeInterface)

Example 7 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class FSTreeCellRenderer method getTreeCellRendererComponent.

/**
 * This is the only TreeCellRenderer method.
 * Compute the string to display, and pass it to the wrapped renderer
 *
 * @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
 */
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    Object userObject = node.getUserObject();
    String name = getItemText(node, userObject);
    super.getTreeCellRendererComponent(tree, name, selected, expanded, leaf, row, hasFocus);
    if (node instanceof NodeInterface) {
        Icon icon = ((NodeInterface) node).getIcon();
        if (icon != null) {
            setIcon(icon);
        }
    }
    return this;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Icon(javax.swing.Icon) NodeInterface(com.sldeditor.common.NodeInterface)

Example 8 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class FileSystemInput 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>> copyDataMap) {
    if ((destinationTreeNode == null) || (copyDataMap == null)) {
        return false;
    }
    FileTreeNode destinationNode = (FileTreeNode) destinationTreeNode;
    if (!destinationNode.isDir()) {
        destinationNode = (FileTreeNode) destinationNode.getParent();
    }
    File destinationFolder = destinationNode.getFile();
    for (NodeInterface key : copyDataMap.keySet()) {
        List<SLDDataInterface> sldDataList = copyDataMap.get(key);
        for (SLDDataInterface sldData : sldDataList) {
            String sldFilename = sldData.getSLDFile().getAbsolutePath();
            FileHandlerInterface handler = getFileHandler(sldFilename);
            if (handler != null) {
                String sldName = handler.getSLDName(sldData);
                File existingFolder = new File(sldFilename).getParentFile();
                if (existingFolder.equals(destinationFolder)) {
                    sldName = "Copy of " + sldName;
                }
                File updateFile = new File(destinationFolder, sldName);
                sldData.setSLDFile(updateFile);
                save(sldData);
            }
        }
        destinationNode.refreshFolder();
        if (treeModel != null) {
            treeModel.reload(destinationNode);
        }
    }
    return true;
}
Also used : FileHandlerInterface(com.sldeditor.datasource.extension.filesystem.node.file.FileHandlerInterface) SLDDataInterface(com.sldeditor.common.SLDDataInterface) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

Example 9 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class GeoServerConnectionListTool 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();
    boolean geoServerNodesSelected = false;
    for (NodeInterface nodeType : nodeTypeList) {
        if (nodeType instanceof GeoServerNode) {
            GeoServerNode geoserverNode = (GeoServerNode) nodeType;
            connectionList.add(geoserverNode.getConnection());
            geoServerNodesSelected = true;
        }
    }
    btnDuplicate.setEnabled(geoServerNodesSelected && (connectionList.size() == 1));
    btnEdit.setEnabled(geoServerNodesSelected && (connectionList.size() == 1));
    btnDelete.setEnabled(geoServerNodesSelected);
}
Also used : GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) NodeInterface(com.sldeditor.common.NodeInterface)

Example 10 with NodeInterface

use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.

the class DatabaseConnectionTool 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();
    if (nodeTypeList != null) {
        for (NodeInterface node : nodeTypeList) {
            if (node instanceof DatabaseNode) {
                DatabaseNode databaseNode = (DatabaseNode) node;
                connectionList.add(databaseNode.getConnection());
            } else if (node instanceof FileTreeNode) {
                FileTreeNode fileNode = (FileTreeNode) node;
                if (fileNode.getFileCategory() == FileTreeNodeTypeEnum.DATABASE) {
                    DatabaseConnection databaseConnection = DatabaseConnectionFactory.getConnection(fileNode.getFile().getAbsolutePath());
                    connectionList.add(databaseConnection);
                }
            }
        }
    }
    updateButtonState();
}
Also used : DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) NodeInterface(com.sldeditor.common.NodeInterface) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

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