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);
}
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());
}
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);
}
Aggregations