Search in sources :

Example 96 with ISchemaNode

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

the class CreateLikeTableAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || !isSupported(objArr)) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) objArr[0];
    if (node == null) {
        return;
    }
    doRun(node);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode)

Example 97 with ISchemaNode

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

the class QueryEditorDNDController method fillInSelectedNode.

/**
	 *
	 * Fill in the selected node
	 *
	 * @param schemaNodeList all table nodes
	 * @param columnNodeMap all columns node
	 * @return boolean
	 */
private boolean fillInSelectedNode(List<ISchemaNode> schemaNodeList, Map<String, List<ISchemaNode>> columnNodeMap) {
    TreeViewer treeViewer = perspectiveTreeviewerMap.get(PerspectiveManager.getInstance().getCurrentPerspectiveId());
    if (treeViewer == null) {
        return false;
    }
    ISelection selection = treeViewer.getSelection();
    if (!(selection instanceof TreeSelection)) {
        return false;
    }
    TreeSelection ts = (TreeSelection) selection;
    Object[] objs = ts.toArray();
    String dbId = null;
    for (Object obj : objs) {
        if (obj instanceof ISchemaNode) {
            ISchemaNode node = (ISchemaNode) obj;
            CubridDatabase database = node.getDatabase();
            if (dbId == null) {
                dbId = database.getId();
            }
            if (!dbId.equals(database.getId())) {
                return false;
            }
            String type = node.getType();
            if (NodeType.SYSTEM_TABLE.equals(type) || NodeType.SYSTEM_VIEW.equals(type) || NodeType.USER_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE.equals(type) || NodeType.USER_VIEW.equals(type) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
                schemaNodeList.add(node);
            } else if (NodeType.TABLE_COLUMN.equals(type)) {
                String name = node.getParent().getParent().getName();
                List<ISchemaNode> columnNodeList = columnNodeMap.get(name);
                if (columnNodeList == null) {
                    columnNodeList = new ArrayList<ISchemaNode>();
                    columnNodeMap.put(name, columnNodeList);
                }
                columnNodeList.add(node);
            }
        }
    }
    return true;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 98 with ISchemaNode

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

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

the class CubridTriggerFolderLoader 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().setTriggerList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        ITask task = null;
        if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
            task = new GetTriggerListTask(parent.getServer().getServerInfo());
            ((GetTriggerListTask) task).setDbName(database.getLabel());
        } else {
            task = new JDBCGetTriggerListTask(databaseInfo);
        }
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        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();
        List<Trigger> triggerList = null;
        if (task instanceof GetTriggerListTask) {
            triggerList = ((GetTriggerListTask) task).getTriggerInfoList();
        } else if (task instanceof JDBCGetTriggerListTask) {
            triggerList = ((JDBCGetTriggerListTask) task).getTriggerInfoList();
        }
        if (triggerList != null && !triggerList.isEmpty()) {
            for (Trigger trigger : triggerList) {
                String id = parent.getId() + NODE_SEPARATOR + trigger.getName();
                ICubridNode triggerNode = createTriggerNode(id, trigger);
                parent.addChild(triggerNode);
            }
        }
        databaseInfo.setTriggerList(triggerList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) Trigger(com.cubrid.common.core.common.model.Trigger) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) JDBCGetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerListTask) GetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.GetTriggerListTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) JDBCGetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerListTask)

Example 100 with ISchemaNode

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

the class CubridSystemTableFolderLoader 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().setSysTableInfoList(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, 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;
        }
        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_table_item.png");
                classNode.setType(NodeType.SYSTEM_TABLE);
                classNode.setEditorId(SchemaInfoEditorPart.ID);
                classNode.setContainer(false);
                classNode.setModelObj(classInfo);
                parent.addChild(classNode);
            }
        }
        database.getDatabaseInfo().setSysTableInfoList(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)

Aggregations

ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)158 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)104 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ArrayList (java.util.ArrayList)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)23 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)23 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)22 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)21 Shell (org.eclipse.swt.widgets.Shell)16 ITask (com.cubrid.common.core.task.ITask)13 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)13 IEditorPart (org.eclipse.ui.IEditorPart)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 HashSet (java.util.HashSet)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 PartInitException (org.eclipse.ui.PartInitException)10