Search in sources :

Example 96 with ICubridNode

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

the class CubridUserTableColumnLoader 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;
        }
        if (columns == null && !getColumns(parent, monitor, database)) {
            return;
        }
        if (monitor.isCanceled()) {
            columns = null;
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        String parentId = parent.getId();
        if (columns != null && !columns.isEmpty()) {
            for (TableColumn column : columns) {
                String label = column.getColumnName() + ",";
                label += FieldHandlerUtils.getComleteType(column.getTypeName(), column.getSubElementTypeName(), column.getPrecision(), column.getScale());
                String nodeId = parentId + NODE_SEPARATOR + column.getColumnName();
                ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_column_item.png");
                if (column.isPrimaryKey()) {
                    node.setIconPath("icons/primary_key.png");
                }
                node.setType(NodeType.TABLE_COLUMN);
                node.setModelObj(column);
                node.setContainer(false);
                parent.addChild(node);
            }
        }
        columns = null;
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : 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) TableColumn(com.cubrid.cubridmanager.core.cubrid.table.model.TableColumn)

Example 97 with ICubridNode

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

the class CubridUserTableIndexLoader 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 GetUserClassIndexesTask task = new GetUserClassIndexesTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        String tableName = parent.getParent().getLabel();
        List<TableIndex> indexes = task.getIndexesNames(tableName);
        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();
        String parentId = parent.getId();
        if (indexes != null && !indexes.isEmpty()) {
            for (TableIndex index : indexes) {
                String indexName = index.getIndexName();
                String nodeId = parentId + NODE_SEPARATOR + indexName;
                String label = indexName;
                List<String> dependColumns = index.getColumns();
                if (dependColumns != null && !dependColumns.isEmpty()) {
                    String keyAttrName = index.getColumns().toString();
                    label += keyAttrName.replace('[', '(').replace(']', ')');
                }
                ICubridNode node = new DefaultSchemaNode(nodeId, label, "icons/navigator/table_index_item.png");
                if (index.isPrimaryKey()) {
                    node.setIconPath("icons/primary_key.png");
                }
                node.setType(NodeType.TABLE_INDEX);
                node.setModelObj(index);
                node.setContainer(false);
                parent.addChild(node);
            }
        }
        Collections.sort(parent.getChildren());
        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) TableIndex(com.cubrid.cubridmanager.core.cubrid.table.model.TableIndex) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetUserClassIndexesTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetUserClassIndexesTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Display(org.eclipse.swt.widgets.Display)

Example 98 with ICubridNode

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

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

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

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22