use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode in project sldeditor by robward-scisys.
the class DatabaseReadProgress method disconnect.
/**
* Disconnect.
*
* @param connection the node
*/
public void disconnect(DatabaseConnection connection) {
DatabaseNode node = nodeMap.get(connection);
node.removeAllChildren();
if (treeModel != null) {
treeModel.reload(node);
}
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode in project sldeditor by robward-scisys.
the class DatabaseConnectionListTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
connectionList.clear();
selectedDatabaseType = null;
boolean databaseNodesSelected = false;
boolean canDuplicate = true;
for (NodeInterface nodeType : nodeTypeList) {
if (nodeType instanceof DatabaseNode) {
DatabaseNode databaseNode = (DatabaseNode) nodeType;
DatabaseConnection connection = databaseNode.getConnection();
connectionList.add(connection);
databaseNodesSelected = true;
if (!connection.isSupportsDuplication()) {
canDuplicate = false;
}
} else if (nodeType instanceof DatabaseOverallNode) {
DatabaseOverallNode databaseOverallNode = (DatabaseOverallNode) nodeType;
selectedDatabaseType = databaseOverallNode.toString();
canDuplicate = false;
}
}
btnDuplicate.setEnabled(canDuplicate && databaseNodesSelected && (connectionList.size() == 1));
btnEdit.setEnabled(databaseNodesSelected && (connectionList.size() == 1));
btnDelete.setEnabled(databaseNodesSelected);
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode in project sldeditor by robward-scisys.
the class DatabaseConnectionToolTest method testDatabaseConnectionTool.
/**
* Test method for
* {@link com.sldeditor.tool.databaseconnection.DatabaseConnectionTool#DatabaseConnectionTool(com.sldeditor.tool.databaseconnection.DatabaseConnectStateInterface)}.
*/
@Test
public void testDatabaseConnectionTool() {
TestDatabaseConnectState state = new TestDatabaseConnectState();
TestDatabaseConnectionTool testObj = new TestDatabaseConnectionTool(state);
testObj.setSelectedItems(null, null);
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
DatabaseConnection connection = DatabaseConnectionFactory.createGeoPackage();
nodeTypeList.add(new DatabaseNode(new DatabaseInput(ToolManager.getInstance()), connection));
File parent = new File("");
String filename = "test.gpkg";
FileTreeNode fileTreeNode = null;
try {
fileTreeNode = new FileTreeNode(parent, filename);
fileTreeNode.setFileCategory(FileTreeNodeTypeEnum.DATABASE);
nodeTypeList.add(fileTreeNode);
} catch (SecurityException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
testObj.setSelectedItems(nodeTypeList, null);
testObj.populateComplete(null);
assertNotNull(testObj.getPanel());
List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
List<SLDDataInterface> sldDataList = null;
assertFalse(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
uniqueNodeTypeList.add(String.class);
assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
nodeTypeList.remove(0);
assertTrue(testObj.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
testObj.testConnect();
testObj.testDisconnect();
}
Aggregations