use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerConnectionTool method updateButtonState.
/**
* Update button state.
*/
private void updateButtonState() {
int connected = 0;
int disconnected = 0;
if (geoServerConnectState != null) {
for (GeoServerConnection connection : connectionList) {
if (geoServerConnectState.isConnected(connection)) {
connected++;
} else {
disconnected++;
}
}
}
boolean connectedEnabled = false;
boolean disconnectedEnabled = false;
if ((connected == 0) || (disconnected == 0)) {
if (connected > 0) {
disconnectedEnabled = true;
} else if (disconnected > 0) {
connectedEnabled = true;
}
}
connectButton.setEnabled(connectedEnabled);
disconnectButton.setEnabled(disconnectedEnabled);
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerConnectionTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
panel = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.title")));
//
// Connect button
//
connectButton = new ToolButton(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.connect"), "tool/connect.png");
connectButton.setEnabled(true);
connectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (geoServerConnectState != null) {
connectButton.setEnabled(false);
disconnectButton.setEnabled(false);
geoServerConnectState.connect(connectionList);
for (GeoServerConnection connection : connectionList) {
if (!geoServerConnectState.isConnected(connection)) {
connectButton.setEnabled(true);
}
}
}
}
});
panel.add(connectButton);
//
// Disconnect button
//
disconnectButton = new ToolButton(Localisation.getString(GeoServerConnectionTool.class, "GeoServerConnectionTool.disconnect"), "tool/disconnect.png");
disconnectButton.setEnabled(false);
disconnectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (geoServerConnectState != null) {
connectButton.setEnabled(false);
disconnectButton.setEnabled(false);
geoServerConnectState.disconnect(connectionList);
}
}
});
panel.add(disconnectButton);
panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerConnectionListTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
panel = new JPanel();
panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.title")));
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
btnNew = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.new"), "tool/newconnection.png");
btnNew.setEnabled(true);
btnNew.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (geoServerConnectUpdate != null) {
GeoServerConnection connectionDetails = new GeoServerConnection();
GeoServerConnection newConnectionDetails = ConnectorDetailsPanel.showDialog(null, connectionDetails);
if (newConnectionDetails != null) {
geoServerConnectUpdate.addNewConnection(newConnectionDetails);
}
}
}
});
panel.add(btnNew);
btnDuplicate = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.duplicate"), "tool/duplicateconnection.png");
btnDuplicate.setEnabled(false);
btnDuplicate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (geoServerConnectUpdate != null) {
if (!connectionList.isEmpty()) {
GeoServerConnection selectedConnectionDetails = connectionList.get(0);
GeoServerConnection duplicateItem = selectedConnectionDetails.duplicate();
geoServerConnectUpdate.addNewConnection(duplicateItem);
}
}
}
});
panel.add(btnDuplicate);
btnEdit = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.edit"), "tool/editconnection.png");
btnEdit.setEnabled(false);
btnEdit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (geoServerConnectUpdate != null) {
if (!connectionList.isEmpty()) {
GeoServerConnection selectedConnectionDetails = connectionList.get(0);
GeoServerConnection newConnectionDetails = ConnectorDetailsPanel.showDialog(null, selectedConnectionDetails);
if (newConnectionDetails != null) {
geoServerConnectUpdate.updateConnectionDetails(selectedConnectionDetails, newConnectionDetails);
}
}
}
}
});
panel.add(btnEdit);
btnDelete = new ToolButton(Localisation.getString(GeoServerConnectionListTool.class, "GeoServerConnectionListTool.delete"), "tool/deleteconnection.png");
btnDelete.setEnabled(false);
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (geoServerConnectUpdate != null) {
geoServerConnectUpdate.deleteConnections(connectionList);
}
}
});
panel.add(btnDelete);
panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testSetArguments.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#setArguments(java.util.List)}.
*/
@Test
public void testSetArguments() {
File configPropertiesFile = new File("./FileSystemExtensionTest.properties");
PropertyManagerFactory.getInstance().setPropertyFile(configPropertiesFile);
FileSystemExtension fsExt = new FileSystemExtension();
FileSystemExtensionFactory.override(null);
fsExt.initialise(null, new DummyToolMgr());
// Handle null argument
fsExt.setArguments(null);
List<String> extensionArgList = new ArrayList<String>();
extensionArgList.add("invalid1");
extensionArgList.add("in.val.id2");
extensionArgList.add("in.va.li.d3.");
extensionArgList.add("invalid4=abc");
String actual = fsExt.setArguments(extensionArgList);
assertNull(actual);
// File does not exist
extensionArgList.clear();
String expectedFile = "folder=X:\\asdef";
extensionArgList.add(expectedFile);
actual = fsExt.setArguments(extensionArgList);
assertNull(actual);
// Valid file
extensionArgList.clear();
File f = null;
try {
f = File.createTempFile(getClass().getSimpleName(), ".tmp");
} catch (IOException e) {
e.printStackTrace();
fail();
}
expectedFile = "folder=" + f.getParent();
extensionArgList.add(expectedFile);
actual = fsExt.setArguments(extensionArgList);
assertEquals(expectedFile, actual);
f.delete();
// Invalid GeoServer
extensionArgList.clear();
String expectedGeoServer = "geoserver=unknown";
extensionArgList.add(expectedGeoServer);
actual = fsExt.setArguments(extensionArgList);
assertNull(actual);
// Valid GeoServer
GeoServerConnection geoServerConnection = new GeoServerConnection();
geoServerConnection.setConnectionName("GeoServer connection");
try {
geoServerConnection.setUrl(new URL("http://localhost/geoserver"));
} catch (MalformedURLException e) {
e.printStackTrace();
fail();
}
geoServerConnection.setUserName("username");
geoServerConnection.setPassword("password");
GeoServerConnectionManager.getInstance().addNewConnection(null, geoServerConnection);
GeoServerConnectionManager.getInstance().updateList();
extensionArgList.clear();
expectedGeoServer = "geoserver=" + geoServerConnection.getConnectionName();
extensionArgList.add(expectedGeoServer);
actual = fsExt.setArguments(extensionArgList);
assertEquals(expectedGeoServer, actual);
configPropertiesFile.delete();
}
use of com.sldeditor.common.data.GeoServerConnection in project sldeditor by robward-scisys.
the class GeoServerInputTest method testUpdateConnectionDetails.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.geoserver.GeoServerInput#updateConnectionDetails(com.sldeditor.common.data.GeoServerConnection, com.sldeditor.common.data.GeoServerConnection)}.
*/
@Test
public void testUpdateConnectionDetails() {
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.updateConnectionDetails(null, null);
// Delete connection details
List<GeoServerConnection> listToDelete = new ArrayList<GeoServerConnection>();
listToDelete.add(connection1);
input.deleteConnections(listToDelete);
GeoServerConnection connection1Updated = new GeoServerConnection();
connection1Updated.setConnectionName("update test connection 1");
input.addNewConnection(connection1Updated);
// Update the connection details
input.updateConnectionDetails(connection1, connection1Updated);
StyleWrapper styleWrapper = new StyleWrapper("workspace", "layer1");
SLDData sldData = new SLDData(styleWrapper, "sld contents");
sldData.setConnectionData(connection1);
// Try and save with the old GeoServer connection details
assertFalse(input.save(sldData));
// Try and save with the new GeoServer connection details
sldData.setConnectionData(connection1Updated);
assertTrue(input.save(sldData));
}
Aggregations