Search in sources :

Example 6 with GeoServerClientInterface

use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.

the class RenderTransformationDialog method main.

/**
 * The main method.
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    GeoServerConnectionManagerInterface dummyInterface = new GeoServerConnectionManagerInterface() {

        @Override
        public List<GeoServerConnection> getConnectionList() {
            List<GeoServerConnection> list = new ArrayList<GeoServerConnection>();
            GeoServerConnection connection = new GeoServerConnection();
            connection.setConnectionName("Test");
            try {
                connection.setUrl(new URL("http://localhost:8080/geoserver"));
                connection.setUserName("admin");
                connection.setPassword("geoserver");
                list.add(connection);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            return list;
        }

        @Override
        public void updateList() {
        }

        @Override
        public GeoServerConnection getConnection(String connectionDataName) {
            return null;
        }

        @Override
        public void readPropertyFile(GeoServerReadProgress progress) {
        }

        @Override
        public Map<GeoServerConnection, GeoServerClientInterface> getConnectionMap() {
            return null;
        }

        @Override
        public void removeConnection(GeoServerConnection connection) {
        }

        @Override
        public void addNewConnection(GeoServerReadProgress progress, GeoServerConnection newConnectionDetails) {
        }
    };
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    vendorOptionList.add(VersionData.getLatestVersion(GeoServerVendorOption.class));
    VendorOptionManager.getInstance().setSelectedVendorOptions(vendorOptionList);
    RenderTransformationDialog dlg = new RenderTransformationDialog(dummyInterface);
    dlg.showDialog(null);
}
Also used : MalformedURLException(java.net.MalformedURLException) GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) VersionData(com.sldeditor.common.vendoroption.VersionData) GeoServerConnectionManagerInterface(com.sldeditor.common.connection.GeoServerConnectionManagerInterface) GeoServerReadProgress(com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress)

Example 7 with GeoServerClientInterface

use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.

the class GeoServerInput method rightMouseButton.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.common.filesystem.FileSystemInterface#rightMouseButton(javax.swing.JPopupMenu, java.lang.Object, java.awt.event.MouseEvent)
     */
@Override
public void rightMouseButton(JPopupMenu popupMenu, Object selectedItem, MouseEvent e) {
    if (selectedItem instanceof GeoServerNode) {
        GeoServerNode geoServerNode = (GeoServerNode) selectedItem;
        GeoServerConnection connection = geoServerNode.getConnection();
        GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connection);
        if (client != null) {
            if (client.isConnected()) {
                JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.disconnect"));
                connectMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent event) {
                        disconnectFromGeoServer(client);
                    }
                });
                popupMenu.add(connectMenuItem);
            } else {
                JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.connect"));
                connectMenuItem.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent event) {
                        GeoServerNode geoserver = (GeoServerNode) selectedItem;
                        GeoServerConnection connection = geoserver.getConnection();
                        connectToGeoServer(connection);
                    }
                });
                popupMenu.add(connectMenuItem);
            }
        }
    } else if (selectedItem instanceof FileTreeNode) {
        FileTreeNode fileNode = (FileTreeNode) selectedItem;
        if (ExternalFilenames.getFileExtension(fileNode.getFile().getAbsolutePath()).compareToIgnoreCase(SLD_FILE_EXTENSION) == 0) {
            JMenu uploadToGeoServerMenu = new JMenu(Localisation.getString(GeoServerInput.class, "GeoServerInput.uploadToGeoServer"));
            populateGeoServerConnections(uploadToGeoServerMenu);
            popupMenu.add(uploadToGeoServerMenu);
        }
    }
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) ActionListener(java.awt.event.ActionListener) GeoServerNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) JMenu(javax.swing.JMenu) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)

Example 8 with GeoServerClientInterface

use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.

the class GeoServerInput method deleteNodes.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.extension.input.FileSystemInterface#deleteNodes(com.sldeditor.extension.input.NodeInterface, java.util.List)
     */
@Override
public void deleteNodes(NodeInterface nodeToTransfer, List<SLDDataInterface> sldDataList) {
    if ((nodeToTransfer == null) || (sldDataList == null)) {
        return;
    }
    if (nodeToTransfer instanceof GeoServerWorkspaceNode) {
        Map<GeoServerClientInterface, String> connectionsToRefreshMap = new HashMap<GeoServerClientInterface, String>();
        for (SLDDataInterface sldData : sldDataList) {
            GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(sldData.getConnectionData());
            if (client != null) {
                connectionsToRefreshMap.put(client, sldData.getStyle().getWorkspace());
                client.deleteStyle(sldData.getStyle());
            }
        }
        // Refreshing the workspace re-populates the user interface
        for (GeoServerClientInterface client : connectionsToRefreshMap.keySet()) {
            client.refreshWorkspace(connectionsToRefreshMap.get(client));
        }
    }
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) HashMap(java.util.HashMap) SLDDataInterface(com.sldeditor.common.SLDDataInterface)

Example 9 with GeoServerClientInterface

use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.

the class GeoServerInput method populateGeoServerConnections.

/**
 * Populate geo server connections.
 *
 * @param uploadToGeoServerMenu the upload to geo server menu
 */
private void populateGeoServerConnections(JMenu uploadToGeoServerMenu) {
    if (uploadToGeoServerMenu != null) {
        Map<GeoServerConnection, GeoServerClientInterface> connectionMap = GeoServerConnectionManager.getInstance().getConnectionMap();
        if (connectionMap.isEmpty()) {
            JMenuItem noGeoServerMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.noGeoServerConnections"));
            uploadToGeoServerMenu.add(noGeoServerMenuItem);
        } else {
            for (GeoServerConnection connection : connectionMap.keySet()) {
                JMenu geoServer = new JMenu(connection.getConnectionName());
                uploadToGeoServerMenu.add(geoServer);
                GeoServerClientInterface client = connectionMap.get(connection);
                if (client.isConnected()) {
                    populateWorkspaceList(client, geoServer);
                } else {
                    JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.connect"));
                    connectMenuItem.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent event) {
                            connectMenuItem.setEnabled(false);
                            connectToGeoServer(connection);
                            connectMenuItem.setEnabled(true);
                        }
                    });
                    geoServer.add(connectMenuItem);
                }
            }
        }
    }
}
Also used : GeoServerClientInterface(com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) JMenu(javax.swing.JMenu)

Example 10 with GeoServerClientInterface

use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface 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)

Aggregations

GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)10 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)3 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)3 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 NodeInterface (com.sldeditor.common.NodeInterface)1 GeoServerConnectionManagerInterface (com.sldeditor.common.connection.GeoServerConnectionManagerInterface)1 SLDData (com.sldeditor.common.data.SLDData)1 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)1 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)1 VersionData (com.sldeditor.common.vendoroption.VersionData)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 GeoServerStyleHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerStyleHeadingNode)1