Search in sources :

Example 26 with GeoServerConnection

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

the class GeoServerWorkspaceNodeTest method testGeoServerLayerNode.

/**
 * Test method for
 * {@link com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode#GeoServerStyleNode(com.sldeditor.common.filesystem.FileSystemInterface)}.
 */
@Test
public void testGeoServerLayerNode() {
    FileSystemInterface fileHandler = new DummyFileSystemInput();
    GeoServerConnection connection = new GeoServerConnection();
    connection.setConnectionName("test connection");
    connection.setUserName("test user name");
    String workspaceName = "workspace";
    GeoServerWorkspaceNode node = new GeoServerWorkspaceNode(fileHandler, connection, workspaceName, true);
    assertEquals(fileHandler, node.getHandler());
    assertEquals(connection, node.getConnection());
    assertEquals(workspaceName, node.getWorkspaceName());
    assertEquals(DataFlavourManager.GEOSERVER_WORKSPACE_DATAITEM_FLAVOUR, node.getDataFlavour());
    assertNull(node.getDestinationText());
}
Also used : FileSystemInterface(com.sldeditor.common.filesystem.FileSystemInterface) GeoServerWorkspaceNode(com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test)

Example 27 with GeoServerConnection

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

the class RenderTransformationManager method main.

/**
 * The main method.
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    GeoServerConnection connection = new GeoServerConnection();
    connection.setConnectionName("Test");
    try {
        connection.setUrl(new URL("http://localhost/geoserver"));
        connection.setUserName("admin");
        connection.setPassword("geoserver");
        RenderTransformationManager.getInstance().getRenderTransform(connection);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL)

Example 28 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection 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 29 with GeoServerConnection

use of com.sldeditor.common.data.GeoServerConnection 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 30 with GeoServerConnection

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

the class SLDUtilsTest method testCreateSLDFromStringGeoServer.

@Test
public void testCreateSLDFromStringGeoServer() {
    SLDData sldData = new SLDData(null, expectedSld);
    String geoserverUrl = "http://localhost:8080/geoserver";
    GeoServerConnection connectionData = new GeoServerConnection();
    try {
        connectionData.setUrl(new URL(geoserverUrl));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    sldData.setConnectionData(connectionData);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
    assertNull(sld);
    sld = SLDUtils.createSLDFromString(sldData);
    StyledLayer[] styledLayers = sld.getStyledLayers();
    NamedLayer namedLayer = (NamedLayer) styledLayers[0];
    Style[] actualStyles = namedLayer.getStyles();
    PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
    assertEquals("circle", mark.getWellKnownName().toString());
    // Check resource locator
    geoserverUrl = geoserverUrl + "/styles/";
    assertTrue(geoserverUrl.compareTo(sldData.getResourceLocator().toExternalForm()) == 0);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) MalformedURLException(java.net.MalformedURLException) StyledLayer(org.geotools.styling.StyledLayer) MarkImpl(org.geotools.styling.MarkImpl) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Aggregations

GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)50 Test (org.junit.Test)31 URL (java.net.URL)12 ArrayList (java.util.ArrayList)11 StyleWrapper (com.sldeditor.common.data.StyleWrapper)10 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)9 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)9 MalformedURLException (java.net.MalformedURLException)9 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)8 SLDData (com.sldeditor.common.data.SLDData)7 GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)5 GeoServerOverallNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerOverallNode)5 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)5 GeoServerReadProgress (com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress)5 GeoServerClientInterface (com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface)5 HashMap (java.util.HashMap)5 List (java.util.List)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4