Search in sources :

Example 1 with CubridUserTableLoader

use of com.cubrid.common.ui.spi.model.loader.schema.CubridUserTableLoader in project cubrid-manager by CUBRID.

the class TableEditorPart method completeAll.

public void completeAll() {
    CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgNull2DefComplete, jobName));
    if (this.isNewTableFlag) {
        ICubridNode node = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTablesFolderLoader.TABLES_FOLDER_ID);
        if (node == null || !node.getLoader().isLoaded()) {
            return;
        }
        String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
        boolean isPartition = newSchemaInfo.getPartitionList() != null && newSchemaInfo.getPartitionList().size() > 0;
        ClassInfo newClassInfo = new ClassInfo(tableName, owner, ClassType.NORMAL, false, isPartition);
        ICubridNode newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
        if (CubridNavigatorView.findNavigationView() == null) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
        if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        CommonUITool.addNodeToTree(treeViewer, node, newNode);
        // refresh table folder count label
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        if (database == null) {
            return;
        }
        database.getDatabaseInfo().removeSchema(tableName);
        if (oldPartitionInfoList.isEmpty() && !partitionInfoList.isEmpty()) {
            editedTableNode.setIconPath("icons/navigator/schema_table_partition.png");
            editedTableNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
            editedTableNode.setLoader(new CubridPartitionedTableLoader());
        } else if (!oldPartitionInfoList.isEmpty() && partitionInfoList.isEmpty()) {
            editedTableNode.setIconPath("icons/navigator/schema_table_item.png");
            editedTableNode.setType(NodeType.USER_TABLE);
            editedTableNode.setLoader(new CubridUserTableLoader());
        }
        TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
        if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        CommonUITool.refreshNavigatorTree(treeViewer, editedTableNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(editedTableNode, CubridNodeChangedEventType.NODE_REFRESH));
        /* Broadcast the view changed */
        QueryEditorUtil.fireSchemaNodeChanged(editedTableNode);
    }
    getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
}
Also used : CubridPartitionedTableLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridPartitionedTableLoader) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridUserTableLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridUserTableLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 CubridPartitionedTableLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridPartitionedTableLoader)1 CubridUserTableLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridUserTableLoader)1 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1