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