Search in sources :

Example 6 with DatabaseNode

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);
    }
}
Also used : DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode)

Example 7 with DatabaseNode

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);
}
Also used : DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode) DatabaseOverallNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseOverallNode) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) NodeInterface(com.sldeditor.common.NodeInterface)

Example 8 with DatabaseNode

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();
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) DatabaseNode(com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DatabaseConnection(com.sldeditor.common.data.DatabaseConnection) DatabaseInput(com.sldeditor.extension.filesystem.database.DatabaseInput) File(java.io.File) NodeInterface(com.sldeditor.common.NodeInterface) Test(org.junit.Test)

Aggregations

DatabaseNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseNode)8 NodeInterface (com.sldeditor.common.NodeInterface)3 DatabaseConnection (com.sldeditor.common.data.DatabaseConnection)3 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)2 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 DatabaseOverallNode (com.sldeditor.datasource.extension.filesystem.node.database.DatabaseOverallNode)1 DatabaseInput (com.sldeditor.extension.filesystem.database.DatabaseInput)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1