Search in sources :

Example 1 with CreateLikeTableDialog

use of com.cubrid.common.ui.cubrid.table.dialog.CreateLikeTableDialog in project cubrid-manager by CUBRID.

the class CreateLikeTableAction method doRun.

/**
	 * Do run
	 *
	 * @param node
	 */
private void doRun(ISchemaNode node) {
    CreateLikeTableDialog dialog = new CreateLikeTableDialog(getShell());
    dialog.setDatabase(node.getDatabase());
    if (NodeType.USER_TABLE.equals(node.getType())) {
        String tableName = node.getName();
        dialog.setLikeTableName(tableName);
    }
    if (IDialogConstants.OK_ID == dialog.open()) {
        // FIXME
        TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
        String tableName = dialog.getNewTableName();
        ICubridNode newNode = null;
        if (NodeType.USER_TABLE.equals(node.getType())) {
            ClassInfo classInfo = (ClassInfo) node.getAdapter(ClassInfo.class);
            String id = node.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
            ClassInfo newClassInfo = new ClassInfo(tableName, null, ClassType.NORMAL, classInfo.isSystemClass(), classInfo.isPartitionedClass());
            newNode = CubridTablesFolderLoader.createUserTableNode(node.getParent(), id, newClassInfo, node.getParent().getLoader().getLevel(), new NullProgressMonitor());
            if (node.getDatabase().getDatabaseInfo().getUserTableInfoList() != null) {
                node.getDatabase().getDatabaseInfo().getUserTableInfoList().add(newClassInfo);
            }
            CommonUITool.addNodeToTree(treeViewer, node.getParent(), newNode);
        } else {
            if (node == null || !node.getLoader().isLoaded()) {
                return;
            }
            String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
            ClassInfo newClassInfo = new ClassInfo(tableName, null, ClassType.NORMAL, false, false);
            newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
            CommonUITool.addNodeToTree(treeViewer, node, newNode);
        }
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CreateLikeTableDialog(com.cubrid.common.ui.cubrid.table.dialog.CreateLikeTableDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) 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

CreateLikeTableDialog (com.cubrid.common.ui.cubrid.table.dialog.CreateLikeTableDialog)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)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