Search in sources :

Example 11 with ClassInfo

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.

the class CubridPartitionedTableLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetPartitionedClassListTask task = new GetPartitionedClassListTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        List<ClassInfo> classInfoList = task.getAllPartitionedClassInfoList(parent.getLabel());
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        if (classInfoList != null && !classInfoList.isEmpty()) {
            for (ClassInfo clasInfo : classInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + clasInfo.getClassName();
                ICubridNode partitionedClassNode = new DefaultSchemaNode(id, clasInfo.getClassName(), "icons/navigator/schema_table_item.png");
                partitionedClassNode.setType(NodeType.USER_PARTITIONED_TABLE);
                partitionedClassNode.setModelObj(clasInfo);
                partitionedClassNode.setContainer(false);
                partitionedClassNode.setEditorId(SchemaInfoEditorPart.ID);
                parent.addChild(partitionedClassNode);
            }
        }
        database.getDatabaseInfo().addPartitionedTableList(parent.getLabel(), classInfoList);
        Collections.sort(parent.getChildren());
        loadColumns(parent, getLevel(), monitor);
        loadIndexes(parent, getLevel(), monitor);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) GetPartitionedClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetPartitionedClassListTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo) Display(org.eclipse.swt.widgets.Display)

Example 12 with ClassInfo

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.

the class CubridSystemViewFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setSysViewInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        List<ClassInfo> allClassInfoList = task.getSchema(false, false);
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        if (allClassInfoList != null) {
            for (ClassInfo classInfo : allClassInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
                ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_view_item.png");
                classNode.setType(NodeType.SYSTEM_VIEW);
                classNode.setEditorId(SchemaInfoEditorPart.ID);
                classNode.setContainer(false);
                classNode.setModelObj(classInfo);
                parent.addChild(classNode);
            }
        }
        database.getDatabaseInfo().setSysViewInfoList(allClassInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 13 with ClassInfo

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.

the class CubridTablesFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setUserTableInfoList(null);
            database.getDatabaseInfo().setSysTableInfoList(null);
            database.getDatabaseInfo().setPartitionedTableMap(null);
            database.getDatabaseInfo().clearSchemas();
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        List<ClassInfo> allClassInfoList = task.getSchema(true, true);
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        // add system table folder
        String systemTableFolderId = parent.getId() + NODE_SEPARATOR + SYSTEM_TABLE_FOLDER_ID;
        ICubridNode systemTableFolder = parent.getChild(systemTableFolderId);
        parent.removeAllChild();
        if (systemTableFolder == null) {
            systemTableFolder = new DefaultSchemaNode(systemTableFolderId, SYSTEM_TABLE_FOLDER_NAME, "icons/navigator/folder_sys.png");
            systemTableFolder.setType(NodeType.SYSTEM_TABLE_FOLDER);
            systemTableFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridSystemTableFolderLoader();
            loader.setLevel(getLevel());
            systemTableFolder.setLoader(loader);
            parent.addChild(systemTableFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                systemTableFolder.getChildren(monitor);
            }
        } else {
            parent.addChild(systemTableFolder);
            if (systemTableFolder.getLoader() != null && systemTableFolder.getLoader().isLoaded()) {
                systemTableFolder.getLoader().setLoaded(false);
                systemTableFolder.getChildren(monitor);
            }
        }
        if (allClassInfoList != null) {
            createUserTableNodes(parent, allClassInfoList, getLevel(), monitor);
        }
        database.getDatabaseInfo().setUserTableInfoList(allClassInfoList);
        database.getDatabaseInfo().clearSchemas();
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 14 with ClassInfo

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo in project cubrid-manager by CUBRID.

the class DatabaseInfoTest method testGetClassInfoList.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getClassInfoList()}
	 * .
	 */
public void testGetClassInfoList() {
    bean.getClassInfoList();
    List<ClassInfo> userTableInfoList = new ArrayList<ClassInfo>();
    List<ClassInfo> userViewInfoList = new ArrayList<ClassInfo>();
    List<ClassInfo> sysTableInfoList = new ArrayList<ClassInfo>();
    List<ClassInfo> sysViewInfoList = new ArrayList<ClassInfo>();
    userTableInfoList.add(new ClassInfo("className"));
    userViewInfoList.add(new ClassInfo("className"));
    sysTableInfoList.add(new ClassInfo("className"));
    sysViewInfoList.add(new ClassInfo("className"));
    bean.getClassInfoList();
    bean.setUserTableInfoList(userTableInfoList);
    bean.setUserViewInfoList(userViewInfoList);
    bean.setSysTableInfoList(sysTableInfoList);
    bean.setSysViewInfoList(sysViewInfoList);
    bean.getClassInfoList();
}
Also used : ArrayList(java.util.ArrayList) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 15 with ClassInfo

use of com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo 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

ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)29 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)10 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)9 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)8 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)8 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)7 SQLException (java.sql.SQLException)6 Map (java.util.Map)6 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)5 ClassAuthorizations (com.cubrid.cubridmanager.core.cubrid.table.model.ClassAuthorizations)5 GetAllAttrTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllAttrTask)5 GetViewAllColumnsTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetViewAllColumnsTask)5 TreeViewer (org.eclipse.jface.viewers.TreeViewer)5 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4 ClassType (com.cubrid.cubridmanager.core.utils.ModelUtil.ClassType)4 CreateViewDialog (com.cubrid.common.ui.cubrid.table.dialog.CreateViewDialog)3