Search in sources :

Example 36 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridViewsFolderLoader 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().setUserViewInfoList(null);
            database.getDatabaseInfo().setSysViewInfoList(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, 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;
        }
        // add system view folder
        String systemViewFolderId = parent.getId() + NODE_SEPARATOR + SYSTEM_VIEW_FOLDER_ID;
        ICubridNode systemViewFolder = parent.getChild(systemViewFolderId);
        parent.removeAllChild();
        if (systemViewFolder == null) {
            systemViewFolder = new DefaultSchemaNode(systemViewFolderId, SYSTEM_VIEW_FOLDER_NAME, "icons/navigator/folder_sys.png");
            systemViewFolder.setType(NodeType.SYSTEM_VIEW_FOLDER);
            systemViewFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridSystemViewFolderLoader();
            loader.setLevel(getLevel());
            systemViewFolder.setLoader(loader);
            parent.addChild(systemViewFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                systemViewFolder.getChildren(monitor);
            }
        } else {
            parent.addChild(systemViewFolder);
            if (systemViewFolder.getLoader() != null && systemViewFolder.getLoader().isLoaded()) {
                systemViewFolder.getLoader().setLoaded(false);
                systemViewFolder.getChildren(monitor);
            }
        }
        if (allClassInfoList != null) {
            for (ClassInfo classInfo : allClassInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
                ICubridNode classNode = createUserViewNode(id, classInfo);
                parent.addChild(classNode);
            }
        }
        database.getDatabaseInfo().setUserViewInfoList(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 37 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CubridFunctionFolderLoader method createFunctionNode.

/**
	 * 
	 * Create function node
	 * 
	 * @param id The node id
	 * @param spInfo The model object
	 * @return ICubridNode
	 */
public static ICubridNode createFunctionNode(String id, SPInfo spInfo) {
    ICubridNode spNode = new DefaultSchemaNode(id, spInfo.getSpName(), "icons/navigator/procedure_func_item.png");
    spNode.setType(NodeType.STORED_PROCEDURE_FUNCTION);
    spNode.setModelObj(spInfo);
    spNode.setContainer(false);
    return spNode;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 38 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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 39 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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 40 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4