Search in sources :

Example 1 with ICubridNodeLoader

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

the class CubridSPFolderLoader 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;
        }
        // add function folder
        String functionFolderId = parent.getId() + NODE_SEPARATOR + FUNCTION_FOLDER_ID;
        ICubridNode functionFolder = parent.getChild(functionFolderId);
        if (functionFolder == null) {
            functionFolder = new DefaultSchemaNode(functionFolderId, FUNCTION_FOLDER_NAME, "icons/navigator/folder.png");
            functionFolder.setType(NodeType.STORED_PROCEDURE_FUNCTION_FOLDER);
            functionFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridFunctionFolderLoader();
            loader.setLevel(getLevel());
            functionFolder.setLoader(loader);
            parent.addChild(functionFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                functionFolder.getChildren(monitor);
            }
        } else {
            if (functionFolder.getLoader() != null && functionFolder.getLoader().isLoaded()) {
                functionFolder.getLoader().setLoaded(false);
                functionFolder.getChildren(monitor);
            }
        }
        // add procedure folder
        String procedureFolderId = parent.getId() + NODE_SEPARATOR + PROCEDURE_FOLDER_ID;
        ICubridNode procedureFolder = parent.getChild(procedureFolderId);
        if (procedureFolder == null) {
            procedureFolder = new DefaultSchemaNode(procedureFolderId, PROCEDURE_FOLDER_NAME, "icons/navigator/folder.png");
            procedureFolder.setType(NodeType.STORED_PROCEDURE_PROCEDURE_FOLDER);
            procedureFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridProcedureFolderLoader();
            loader.setLevel(getLevel());
            procedureFolder.setLoader(loader);
            parent.addChild(procedureFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                procedureFolder.getChildren(monitor);
            }
        } else {
            if (procedureFolder.getLoader() != null && procedureFolder.getLoader().isLoaded()) {
                procedureFolder.getLoader().setLoaded(false);
                procedureFolder.getChildren(monitor);
            }
        }
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) 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)

Example 2 with ICubridNodeLoader

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

the class CubridUserTableLoader method loadIndexes.

/**
	 * Load the indexes and its children node
	 * 
	 * @param parent the parent node
	 * @param level the node level
	 * @param monitor the IProgressMonitor object
	 */
protected void loadIndexes(ICubridNode parent, int level, final IProgressMonitor monitor) {
    synchronized (this) {
        String indexFolderId = parent.getId() + NODE_SEPARATOR + INDEX_FOLDER_ID;
        ICubridNode indexFolder = parent.getChild(indexFolderId);
        if (indexFolder == null) {
            indexFolder = new DefaultSchemaNode(indexFolderId, INDEX_FOLDER_NAME, "icons/navigator/folder.png");
            indexFolder.setType(NodeType.TABLE_INDEX_FOLDER);
            indexFolder.setContainer(true);
            parent.addChild(indexFolder);
            ICubridNodeLoader indexLoader = new CubridUserTableIndexLoader();
            indexLoader.setLevel(level);
            indexFolder.setLoader(indexLoader);
        } else {
            if (indexFolder.getLoader() != null && indexFolder.getLoader().isLoaded()) {
                indexFolder.getLoader().setLoaded(false);
                indexFolder.getChildren(monitor);
            }
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 3 with ICubridNodeLoader

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

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

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

the class CubridTablesFolderLoader method createUserTableNode.

/**
	 * 
	 * Create user table node for other type
	 * 
	 * @param parent ICubridNode
	 * @param id The node id
	 * @param classInfo The model object
	 * @param level The load level
	 * @param monitor The IProgressMonitor
	 * @return ICubridNode object
	 */
public static ICubridNode createUserTableNode(ICubridNode parent, String id, ClassInfo classInfo, int level, IProgressMonitor monitor) {
    ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
    classNode.setEditorId(SchemaInfoEditorPart.ID);
    classNode.setContainer(true);
    classNode.setModelObj(classInfo);
    classNode.setType(NodeType.USER_TABLE);
    parent.addChild(classNode);
    ICubridNodeLoader loader = null;
    if (classInfo.isPartitionedClass()) {
        classNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
        classNode.setIconPath("icons/navigator/schema_table_partition.png");
        classNode.setContainer(true);
        loader = new CubridPartitionedTableLoader();
    } else {
        loader = new CubridUserTableLoader();
    }
    loader.setLevel(level);
    classNode.setLoader(loader);
    if (level == DEFINITE_LEVEL) {
        classNode.getChildren(monitor);
    }
    return classNode;
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)27 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)21 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)4 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)4 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)3 ArrayList (java.util.ArrayList)3 CubridSerialFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridSerialFolderLoader)2 CubridTriggerFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridTriggerFolderLoader)2 CubridTablesFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridTablesFolderLoader)2 CubridViewsFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridViewsFolderLoader)2 CubridSPFolderLoader (com.cubrid.common.ui.spi.model.loader.sp.CubridSPFolderLoader)2 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)2