Search in sources :

Example 56 with DefaultSchemaNode

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

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

the class CubridUserTableLoader method loadColumns.

/**
	 * Load the columns and its children node
	 * 
	 * @param parent the parent node
	 * @param level the node level
	 * @param monitor the IProgressMonitor object
	 */
protected void loadColumns(ICubridNode parent, int level, final IProgressMonitor monitor) {
    String columnFolderId = parent.getId() + NODE_SEPARATOR + COLUMN_FOLDER_ID;
    ICubridNode columnFolder = parent.getChild(columnFolderId);
    if (columnFolder == null) {
        columnFolder = new DefaultSchemaNode(columnFolderId, COLUMN_FOLDER_NAME, "icons/navigator/folder.png");
        columnFolder.setType(NodeType.TABLE_COLUMN_FOLDER);
        columnFolder.setContainer(true);
        parent.addChild(columnFolder);
        CubridUserTableColumnLoader columnLoader = new CubridUserTableColumnLoader();
        columnLoader.setLevel(level);
        columnFolder.setLoader(columnLoader);
        if (level == DEFINITE_LEVEL) {
            columnLoader.setColumns(columns);
            columnFolder.getChildren(monitor);
        }
    } else {
        if (columnFolder.getLoader() != null && columnFolder.getLoader().isLoaded()) {
            columnFolder.getLoader().setLoaded(false);
            columnFolder.getChildren(monitor);
        }
    }
    columns = null;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 58 with DefaultSchemaNode

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

the class CubridViewsFolderLoader method createUserViewNode.

/**
	 * 
	 * Create user view node
	 * 
	 * @param id The node id
	 * @param classInfo The model object
	 * @return ICubridNode
	 */
public static ICubridNode createUserViewNode(String id, ClassInfo classInfo) {
    ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_view_item.png");
    classNode.setType(NodeType.USER_VIEW);
    classNode.setEditorId(SchemaInfoEditorPart.ID);
    classNode.setContainer(false);
    classNode.setModelObj(classInfo);
    return classNode;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 59 with DefaultSchemaNode

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

the class CubridSerialFolderLoader method createSerialNode.

/**
	 * 
	 * Create serial node
	 * 
	 * @param id The node id
	 * @param serialInfo The model object
	 * @return ICubridNode
	 */
public static ICubridNode createSerialNode(String id, SerialInfo serialInfo) {
    ICubridNode serialNode = new DefaultSchemaNode(id, serialInfo.getName(), "icons/navigator/serial_item.png");
    serialNode.setId(id);
    serialNode.setType(NodeType.SERIAL);
    serialNode.setModelObj(serialInfo);
    serialNode.setContainer(false);
    return serialNode;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 60 with DefaultSchemaNode

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

the class CubridTriggerFolderLoader method createTriggerNode.

/**
	 * 
	 * Create trigger node
	 * 
	 * @param id The node id
	 * @param trigger The model object
	 * @return ICubridNode
	 */
public static ICubridNode createTriggerNode(String id, Trigger trigger) {
    ICubridNode triggerNode = new DefaultSchemaNode(id, trigger.getName(), "icons/navigator/trigger_item.png");
    triggerNode.setType(NodeType.TRIGGER);
    triggerNode.setModelObj(trigger);
    triggerNode.setContainer(false);
    return triggerNode;
}
Also used : ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

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