Search in sources :

Example 16 with ICubridNodeLoader

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

the class CubridTablesFolderLoader method createUserTableNodes.

/**
	 * Create user table node
	 * 
	 * @param parent ICubridNode
	 * @param allClassInfoList A list includes all the class info
	 * @param level The load level
	 * @param monitor The IProgressMonitor
	 */
private void createUserTableNodes(ICubridNode parent, List<ClassInfo> allClassInfoList, int level, IProgressMonitor monitor) {
    List<String> tables = new ArrayList<String>();
    for (ClassInfo classInfo : allClassInfoList) {
        String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
        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);
        tables.add(classInfo.getClassName());
    }
    if (level == DEFINITE_LEVEL) {
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetUserClassColumnsTask task = new GetUserClassColumnsTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        Map<String, List<TableColumn>> columnsOfTable = task.getColumns(tables);
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && !task.isInTransation() && errorMsg != null && errorMsg.trim().length() > 0) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(errorMsg);
                }
            });
            parent.removeAllChild();
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        for (ClassInfo classInfo : allClassInfoList) {
            String tableId = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
            ICubridNode node = parent.getChild(tableId);
            CubridUserTableLoader tableLoader = (CubridUserTableLoader) node.getLoader();
            tableLoader.setColumns(columnsOfTable.get(classInfo.getClassName()));
            node.getChildren(monitor);
            tableLoader.setLoaded(true);
        }
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ArrayList(java.util.ArrayList) List(java.util.List) GetUserClassColumnsTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassColumnsTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo) Display(org.eclipse.swt.widgets.Display)

Example 17 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addUserFolder.

/**
	 * Add user folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addUserFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String userFolderId = database.getId() + NODE_SEPARATOR + USERS_FOLDER_ID;
    ICubridNode userFolder = database.getChild(userFolderId);
    if (userFolder == null) {
        userFolder = new DefaultSchemaNode(userFolderId, USERS_FOLDER_NAME, "icons/navigator/user_group.png");
        userFolder.setType(CubridNodeType.USER_FOLDER);
        userFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridDbUsersFolderLoader();
        loader.setLevel(getLevel());
        userFolder.setLoader(loader);
        database.addChild(userFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            userFolder.getChildren(monitor);
        }
    } else {
        if (userFolder.getLoader() != null && userFolder.getLoader().isLoaded()) {
            userFolder.getLoader().setLoaded(false);
            userFolder.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 18 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addTriggerFolder.

/**
	 * Add trigger folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addTriggerFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String tiggerFolderId = database.getId() + NODE_SEPARATOR + CubridTriggerFolderLoader.TRIGGER_FOLDER_ID;
    ICubridNode tiggerFolder = database.getChild(tiggerFolderId);
    //IsDBAUserTask
    if (tiggerFolder == null) {
        tiggerFolder = new DefaultSchemaNode(tiggerFolderId, TRIGGER_FOLDER_NAME, "icons/navigator/trigger_group.png");
        tiggerFolder.setType(NodeType.TRIGGER_FOLDER);
        tiggerFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridTriggerFolderLoader();
        loader.setLevel(getLevel());
        tiggerFolder.setLoader(loader);
        database.addChild(tiggerFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            tiggerFolder.getChildren(monitor);
        }
    } else {
        if (tiggerFolder.getLoader() != null && tiggerFolder.getLoader().isLoaded()) {
            tiggerFolder.getLoader().setLoaded(false);
            tiggerFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CubridTriggerFolderLoader(com.cubrid.common.ui.spi.model.loader.CubridTriggerFolderLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 19 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addTableFolder.

/**
	 * Add table folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addTableFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String tablesFolderId = database.getId() + NODE_SEPARATOR + CubridTablesFolderLoader.TABLES_FOLDER_ID;
    ICubridNode tablesFolder = database.getChild(tablesFolderId);
    if (tablesFolder == null) {
        tablesFolder = new DefaultSchemaNode(tablesFolderId, TABLES_FOLDER_NAME, "icons/navigator/schema_table.png");
        tablesFolder.setType(NodeType.TABLE_FOLDER);
        tablesFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridTablesFolderLoader();
        loader.setLevel(getLevel());
        tablesFolder.setLoader(loader);
        database.addChild(tablesFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            tablesFolder.getChildren(monitor);
        }
    } else {
        if (tablesFolder.getLoader() != null && tablesFolder.getLoader().isLoaded()) {
            tablesFolder.getLoader().setLoaded(false);
            tablesFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CubridTablesFolderLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridTablesFolderLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 20 with ICubridNodeLoader

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

the class CubridDatabaseLoader method addJobAutoFolder.

/**
	 * Add job auto folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addJobAutoFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String jobAutoFolderId = database.getId() + NODE_SEPARATOR + JOB_AUTO_FOLDER_ID;
    ICubridNode jobAutoFolder = database.getChild(jobAutoFolderId);
    if (jobAutoFolder == null) {
        jobAutoFolder = new DefaultSchemaNode(jobAutoFolderId, JOB_AUTO_FOLDER_NAME, "icons/navigator/auto_group.png");
        jobAutoFolder.setType(CubridNodeType.JOB_FOLDER);
        jobAutoFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridJobAutoFolderLoader();
        loader.setLevel(getLevel());
        jobAutoFolder.setLoader(loader);
        database.addChild(jobAutoFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            jobAutoFolder.getChildren(monitor);
        }
    } else {
        if (jobAutoFolder.getLoader() != null && jobAutoFolder.getLoader().isLoaded()) {
            jobAutoFolder.getLoader().setLoaded(false);
            jobAutoFolder.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) CubridJobAutoFolderLoader(com.cubrid.cubridmanager.ui.spi.model.loader.jobauto.CubridJobAutoFolderLoader)

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