Search in sources :

Example 1 with FileSystemInterface

use of com.sldeditor.common.filesystem.FileSystemInterface 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;
}
Also used : FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) FileSystemInput(com.sldeditor.extension.filesystem.file.FileSystemInput)

Example 2 with FileSystemInterface

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

the class FileSystemExtension method initialise.

/**
 * Initialise.
 *
 * @param parent the parent
 * @param toolMgr the tool manager
 */
@Override
public void initialise(LoadSLDInterface parent, ToolSelectionInterface toolMgr) {
    this.toolMgr = toolMgr;
    this.parentObj = parent;
    if (toolMgr != null) {
        toolMgr.addRecursiveListener(this);
    }
    // Add extensions
    extensionList = FileSystemExtensionFactory.getFileExtensionList(toolMgr);
    extensionPanel = new JPanel();
    extensionPanel.setLayout(new BorderLayout());
    extensionPanel.setPreferredSize(new Dimension(450, 400));
    JPanel toolPanel = null;
    if (toolMgr != null) {
        toolPanel = toolMgr.getPanel();
    }
    if (toolPanel != null) {
        extensionPanel.add(toolPanel, BorderLayout.NORTH);
    }
    tree = new FSTree();
    tree.setRootVisible(true);
    DefaultMutableTreeNode rootNode;
    try {
        rootNode = new DefaultMutableTreeNode(ROOT_NODE);
        model = new DefaultTreeModel(rootNode);
        FileSystemNodeManager.create(tree, model);
        for (FileSystemInterface extension : extensionList) {
            extension.populate(tree, model, rootNode);
        }
    } catch (SecurityException e1) {
        ConsoleManager.getInstance().exception(this, e1);
    }
    tree.setModel(model);
    tree.setDragEnabled(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                int row = tree.getClosestRowForLocation(e.getX(), e.getY());
                tree.setSelectionRow(row);
                Object selectedItem = tree.getLastSelectedPathComponent();
                Thread t1 = new Thread(new Runnable() {

                    public void run() {
                        JPopupMenu popupMenu = new JPopupMenu();
                        for (FileSystemInterface extension : extensionList) {
                            extension.rightMouseButton(popupMenu, selectedItem, e);
                        }
                        if ((popupMenu.getComponentCount() > 0) && (e != null)) {
                            popupMenu.show(e.getComponent(), e.getX(), e.getY());
                        }
                    }
                });
                t1.start();
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }
    });
    // Listen for Tree Selection Events
    tree.addTreeExpansionListener(new TreeExpansionListener() {

        /*
             * (non-Javadoc)
             * 
             * @see javax.swing.event.TreeExpansionListener#treeExpanded(javax.swing.event.TreeExpansionEvent)
             */
        public void treeExpanded(TreeExpansionEvent evt) {
            TreePath path = evt.getPath();
            Object selectedItem = path.getLastPathComponent();
            for (FileSystemInterface extension : extensionList) {
                if (extension.treeExpanded(selectedItem)) {
                    ((DefaultTreeModel) tree.getModel()).nodeStructureChanged((TreeNode) selectedItem);
                }
            }
        }

        /*
             * (non-Javadoc)
             * 
             * @see javax.swing.event.TreeExpansionListener#treeCollapsed(javax.swing.event.TreeExpansionEvent)
             */
        public void treeCollapsed(TreeExpansionEvent evt) {
        // Nothing to do
        }
    });
    // Tree selection listener
    tree.setTreeSelection(this);
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.add(new JScrollPane(tree));
    extensionPanel.add(panel, BorderLayout.CENTER);
    logger.debug("FileSystem initialise finished");
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) TreeExpansionListener(javax.swing.event.TreeExpansionListener) MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FSTree(com.sldeditor.datasource.extension.filesystem.node.FSTree) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) JPopupMenu(javax.swing.JPopupMenu) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent)

Example 3 with FileSystemInterface

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

the class FileSystemExtensionTest method testInitialise.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#initialise(com.sldeditor.common.LoadSLDInterface, com.sldeditor.common.ToolSelectionInterface)}.
 */
@Test
public void testInitialise() {
    FileSystemExtension fsExt = new FileSystemExtension();
    DummyExtension dummyExtension = new DummyExtension();
    List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
    overrideExtensionList.add(dummyExtension);
    FileSystemExtensionFactory.override(overrideExtensionList);
    fsExt.initialise(null, null);
    fsExt.initialise(null, new DummyToolMgr());
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with FileSystemInterface

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

the class FileSystemExtensionTest method testGetPanel.

/**
 * Test method for {@link com.sldeditor.extension.filesystem.FileSystemExtension#getPanel()}.
 */
@Test
public void testGetPanel() {
    FileSystemExtension fsExt = new FileSystemExtension();
    DummyExtension dummyExtension = new DummyExtension();
    List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
    overrideExtensionList.add(dummyExtension);
    FileSystemExtensionFactory.override(overrideExtensionList);
    fsExt.initialise(null, null);
    assertTrue(fsExt.getPanel() != null);
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with FileSystemInterface

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

the class FileSystemExtensionTest method testSave.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.FileSystemExtension#save(com.sldeditor.common.SLDDataInterface)}.
 */
@Test
public void testSave() {
    FileSystemExtension fsExt = new FileSystemExtension();
    DummyExtension dummyExtension = new DummyExtension();
    List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
    overrideExtensionList.add(dummyExtension);
    FileSystemExtensionFactory.override(overrideExtensionList);
    fsExt.initialise(null, null);
    // Try null parameter
    assertFalse(fsExt.save(null));
    assertTrue(fsExt.save(new SLDData(null, null)));
}
Also used : FileSystemExtension(com.sldeditor.extension.filesystem.FileSystemExtension) SLDData(com.sldeditor.common.data.SLDData) FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)15 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)8 FileSystemExtension (com.sldeditor.extension.filesystem.FileSystemExtension)7 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)3 TreePath (javax.swing.tree.TreePath)2 NodeInterface (com.sldeditor.common.NodeInterface)1 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)1 SLDData (com.sldeditor.common.data.SLDData)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 FSTree (com.sldeditor.datasource.extension.filesystem.node.FSTree)1 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)1 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)1 GeoServerOverallNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerOverallNode)1 GeoServerStyleNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleNode)1 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)1 FileSystemInput (com.sldeditor.extension.filesystem.file.FileSystemInput)1 BorderLayout (java.awt.BorderLayout)1