Search in sources :

Example 16 with GeoServerLayer

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

the class ConfigureLayerStyleDialog method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    JPanel panel = new JPanel();
    getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(new BorderLayout(0, 0));
    table = new JTable(dataModel);
    dataModel.setColumnRenderer(table.getColumnModel());
    ListSelectionModel selectionModel = table.getSelectionModel();
    selectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            // Get selected rows and find the selected style.
            // If the selected layers all don't use the same style
            // then set to null
            int[] selectedRows = table.getSelectedRows();
            StyleWrapper selectedLayerStyle = null;
            boolean isUniqueStyle = true;
            for (int index = 0; index < selectedRows.length; index++) {
                GeoServerLayer layer = dataModel.getLayer(selectedRows[index]);
                if (selectedLayerStyle == null) {
                    selectedLayerStyle = layer.getStyle();
                } else if (isUniqueStyle) {
                    if (selectedLayerStyle.compareTo(layer.getStyle()) != 0) {
                        isUniqueStyle = false;
                    }
                }
            }
            geoServerStyleTree.select(isUniqueStyle ? selectedLayerStyle : null);
        }
    });
    JScrollPane scrollPane = new JScrollPane(table);
    panel.add(scrollPane, BorderLayout.CENTER);
    // 
    // Button panel
    // 
    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.TRAILING);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    JButton btnOk = new JButton(Localisation.getString(ConfigureLayerStyleDialog.class, "common.ok"));
    btnOk.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okButtonPressed = false;
            updatedLayerList = dataModel.getUpdatedLayers();
            if (!updatedLayerList.isEmpty()) {
                okButtonPressed = true;
            }
            setVisible(false);
        }
    });
    buttonPanel.add(btnOk);
    JButton btnCancel = new JButton(Localisation.getString(ConfigureLayerStyleDialog.class, "common.cancel"));
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okButtonPressed = false;
            setVisible(false);
        }
    });
    buttonPanel.add(btnCancel);
    geoServerStyleTree = new GeoServerStyleTree(this);
    getContentPane().add(geoServerStyleTree, BorderLayout.EAST);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) ListSelectionModel(javax.swing.ListSelectionModel) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) StyleWrapper(com.sldeditor.common.data.StyleWrapper) JTable(javax.swing.JTable)

Example 17 with GeoServerLayer

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

the class GeoServerInputTest method testDeleteConnections.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#deleteConnections(java.util.List)}.
 */
@Test
public void testDeleteConnections() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    // Add some GeoServer connections
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    input.addNewConnection(connection1);
    GeoServerConnection connection2 = new GeoServerConnection();
    connection2.setConnectionName("test connection 2");
    input.addNewConnection(connection2);
    // Try null parameters
    input.deleteConnections(null);
    // Populate some styles
    Map<String, List<StyleWrapper>> expectedStyleMap = new HashMap<String, List<StyleWrapper>>();
    // CHECKSTYLE:OFF
    StyleWrapper[] styleWrappers = { new StyleWrapper("workspace", "style1"), new StyleWrapper("workspace", "style2") };
    // CHECKSTYLE:ON
    expectedStyleMap.put("style1", Arrays.asList(styleWrappers));
    Map<String, List<GeoServerLayer>> expectedLayerMap = new HashMap<String, List<GeoServerLayer>>();
    // CHECKSTYLE:OFF
    GeoServerLayer[] geoServerLayers = { new GeoServerLayer("workspace", "style1"), new GeoServerLayer("workspace", "style2") };
    // CHECKSTYLE:ON
    expectedLayerMap.put("style1", Arrays.asList(geoServerLayers));
    input.populateComplete(connection1, expectedStyleMap, expectedLayerMap);
    input.populateComplete(connection2, expectedStyleMap, expectedLayerMap);
    Map<String, List<StyleWrapper>> actualStyleMap = input.getStyleMap(connection1);
    assertEquals(expectedStyleMap, actualStyleMap);
    // Delete a GeoServer connection
    List<GeoServerConnection> connectionList = new ArrayList<GeoServerConnection>();
    connectionList.add(connection1);
    input.deleteConnections(connectionList);
    actualStyleMap = input.getStyleMap(connection1);
    assertTrue(actualStyleMap == null);
    // Check the other connection wasn't deleted
    actualStyleMap = input.getStyleMap(connection2);
    assertEquals(1, actualStyleMap.size());
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) StyleWrapper(com.sldeditor.common.data.StyleWrapper) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Example 18 with GeoServerLayer

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

the class GeoServerInputTest method testUpdateLayerStyle.

/**
 * Test method for
 * {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#updateLayerStyle(com.sldeditor.common.data.StyleWrapper, java.util.List)}.
 */
@Test
public void testUpdateLayerStyle() {
    GeoServerInput input = new GeoServerInput(null);
    GeoServerInput.overrideGeoServerClientClass(DummyGeoServerClient.class);
    // Add some GeoServer connections
    GeoServerConnection connection1 = new GeoServerConnection();
    connection1.setConnectionName("test connection 1");
    input.addNewConnection(connection1);
    GeoServerConnection connection2 = new GeoServerConnection();
    connection2.setConnectionName("test connection 2");
    input.addNewConnection(connection2);
    // Try with null objects
    input.updateLayerStyle(null);
    // CHECKSTYLE:OFF
    GeoServerLayer[] geoServerLayers = { new GeoServerLayer("workspace", "style1"), new GeoServerLayer("workspace", "style2") };
    // CHECKSTYLE:ON
    List<GeoServerLayer> layerList = Arrays.asList(geoServerLayers);
    StyleWrapper updatedStyle = new StyleWrapper("workspace", "layer1");
    for (GeoServerLayer layer : layerList) {
        layer.setStyle(updatedStyle);
    }
    input.updateLayerStyle(layerList);
}
Also used : GeoServerInput(com.sldeditor.extension.filesystem.geoserver.GeoServerInput) GeoServerLayer(com.sldeditor.common.data.GeoServerLayer) StyleWrapper(com.sldeditor.common.data.StyleWrapper) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) Test(org.junit.Test) SLDFileHandlerTest(com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)

Aggregations

GeoServerLayer (com.sldeditor.common.data.GeoServerLayer)18 Test (org.junit.Test)11 StyleWrapper (com.sldeditor.common.data.StyleWrapper)8 GeoServerConnection (com.sldeditor.common.data.GeoServerConnection)5 List (java.util.List)5 GeoServerLayerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerNode)4 GeoServerInput (com.sldeditor.extension.filesystem.geoserver.GeoServerInput)3 SLDFileHandlerTest (com.sldeditor.test.unit.extension.filesystem.file.sld.SLDFileHandlerTest)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 GeoServerLayerHeadingNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerLayerHeadingNode)2 GeoServerWorkspaceNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerWorkspaceNode)2 TreeNode (javax.swing.tree.TreeNode)2 NodeInterface (com.sldeditor.common.NodeInterface)1 FileSystemInterface (com.sldeditor.common.filesystem.FileSystemInterface)1 GeoServerNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerNode)1 GeoServerOverallNode (com.sldeditor.datasource.extension.filesystem.node.geoserver.GeoServerOverallNode)1 GeoServerReadProgress (com.sldeditor.extension.filesystem.geoserver.GeoServerReadProgress)1 RESTLayer (it.geosolutions.geoserver.rest.decoder.RESTLayer)1 RESTLayerList (it.geosolutions.geoserver.rest.decoder.RESTLayerList)1