use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class RenderTransformationDialog method main.
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
GeoServerConnectionManagerInterface dummyInterface = new GeoServerConnectionManagerInterface() {
@Override
public List<GeoServerConnection> getConnectionList() {
List<GeoServerConnection> list = new ArrayList<GeoServerConnection>();
GeoServerConnection connection = new GeoServerConnection();
connection.setConnectionName("Test");
try {
connection.setUrl(new URL("http://localhost:8080/geoserver"));
connection.setUserName("admin");
connection.setPassword("geoserver");
list.add(connection);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
@Override
public void updateList() {
}
@Override
public GeoServerConnection getConnection(String connectionDataName) {
return null;
}
@Override
public void readPropertyFile(GeoServerReadProgress progress) {
}
@Override
public Map<GeoServerConnection, GeoServerClientInterface> getConnectionMap() {
return null;
}
@Override
public void removeConnection(GeoServerConnection connection) {
}
@Override
public void addNewConnection(GeoServerReadProgress progress, GeoServerConnection newConnectionDetails) {
}
};
List<VersionData> vendorOptionList = new ArrayList<VersionData>();
vendorOptionList.add(VersionData.getLatestVersion(GeoServerVendorOption.class));
VendorOptionManager.getInstance().setSelectedVendorOptions(vendorOptionList);
RenderTransformationDialog dlg = new RenderTransformationDialog(dummyInterface);
dlg.showDialog(null);
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface 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.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method deleteNodes.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#deleteNodes(com.sldeditor.extension.input.NodeInterface, java.util.List)
*/
@Override
public void deleteNodes(NodeInterface nodeToTransfer, List<SLDDataInterface> sldDataList) {
if ((nodeToTransfer == null) || (sldDataList == null)) {
return;
}
if (nodeToTransfer instanceof GeoServerWorkspaceNode) {
Map<GeoServerClientInterface, String> connectionsToRefreshMap = new HashMap<GeoServerClientInterface, String>();
for (SLDDataInterface sldData : sldDataList) {
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(sldData.getConnectionData());
if (client != null) {
connectionsToRefreshMap.put(client, sldData.getStyle().getWorkspace());
client.deleteStyle(sldData.getStyle());
}
}
// Refreshing the workspace re-populates the user interface
for (GeoServerClientInterface client : connectionsToRefreshMap.keySet()) {
client.refreshWorkspace(connectionsToRefreshMap.get(client));
}
}
}
use of com.sldeditor.extension.filesystem.geoserver.client.GeoServerClientInterface 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.extension.filesystem.geoserver.client.GeoServerClientInterface in project sldeditor by robward-scisys.
the class GeoServerInput method copyNodes.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#drop(com.sldeditor.extension.input.NodeInterface, java.util.Map)
*/
@Override
public boolean copyNodes(NodeInterface destinationTreeNode, Map<NodeInterface, List<SLDDataInterface>> droppedDataMap) {
if (droppedDataMap == null) {
return false;
}
if (destinationTreeNode instanceof GeoServerWorkspaceNode) {
GeoServerWorkspaceNode workspaceNode = (GeoServerWorkspaceNode) destinationTreeNode;
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(workspaceNode.getConnection());
if (client == null) {
return false;
} else {
for (NodeInterface key : droppedDataMap.keySet()) {
for (SLDDataInterface sldData : droppedDataMap.get(key)) {
StyleWrapper styleWrapper = sldData.getStyle();
removeStyleFileExtension(styleWrapper);
styleWrapper.setWorkspace(workspaceNode.getWorkspaceName());
client.uploadSLD(styleWrapper, sldData.getSld());
}
}
client.refreshWorkspace(workspaceNode.getWorkspaceName());
}
return true;
}
return false;
}
Aggregations