Search in sources :

Example 56 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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 57 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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 58 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class CubridFunctionFolderLoader 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().setSpFunctionInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
        task.setSpType(SPType.FUNCTION);
        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<SPInfo> spInfoList = task.getSPInfoList();
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        boolean isDBA = false;
        String loginUserName = "";
        if (userInfo != null && userInfo.isDbaAuthority()) {
            isDBA = true;
        }
        if (userInfo != null) {
            loginUserName = userInfo.getName();
        }
        List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
        if (spInfoList != null && !spInfoList.isEmpty()) {
            for (SPInfo spInfo : spInfoList) {
                if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
                    continue;
                }
                authSpInfoList.add(spInfo);
                String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
                ICubridNode spNode = createFunctionNode(id, spInfo);
                parent.addChild(spNode);
            }
        }
        databaseInfo.setSpFunctionInfoList(authSpInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) ArrayList(java.util.ArrayList) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetSPInfoListTask(com.cubrid.cubridmanager.core.cubrid.sp.task.GetSPInfoListTask)

Example 59 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class CubridProcedureFolderLoader 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().setSpProcedureInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
        task.setSpType(SPType.PROCEDURE);
        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<SPInfo> spInfoList = task.getSPInfoList();
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        boolean isDBA = false;
        String loginUserName = "";
        if (userInfo != null && userInfo.isDbaAuthority()) {
            isDBA = true;
        }
        if (userInfo != null) {
            loginUserName = userInfo.getName();
        }
        List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
        if (spInfoList != null && !spInfoList.isEmpty()) {
            for (SPInfo spInfo : spInfoList) {
                if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
                    continue;
                }
                authSpInfoList.add(spInfo);
                String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
                ICubridNode spNode = createProcedureNode(id, spInfo);
                parent.addChild(spNode);
            }
        }
        databaseInfo.setSpProcedureInfoList(authSpInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) ArrayList(java.util.ArrayList) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetSPInfoListTask(com.cubrid.cubridmanager.core.cubrid.sp.task.GetSPInfoListTask)

Example 60 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class MenuProvider method buildUserTableMenu.

/**
	 * Construct user table related actions
	 *
	 * @param manager the parent IMenuManager
	 * @param node The ICubridNode object
	 */
public void buildUserTableMenu(IMenuManager manager, ICubridNode node) {
    DatabaseInfo dbInfo = ((ISchemaNode) node).getDatabase().getDatabaseInfo();
    // SELECT GROUP
    IMenuManager selectSqlMenu = new MenuManager(Messages.lblMakeSelectQueryGrp);
    manager.add(selectSqlMenu);
    // SELECT
    addActionToManager(selectSqlMenu, getAction(MakeSelectQueryAction.ID));
    // Parameterized SELECT
    addActionToManager(selectSqlMenu, getAction(MakeSelectPstmtQueryAction.ID));
    // Parameterized INSERT
    addActionToManager(manager, getAction(MakeInsertQueryAction.ID));
    // Parameterized UPDATE
    addActionToManager(manager, getAction(MakeUpdateQueryAction.ID));
    // Parameterized DELETE
    addActionToManager(manager, getAction(MakeDeleteQueryAction.ID));
    // CREATE GROUP
    IMenuManager createSqlMenu = new MenuManager(Messages.lblMakeCreateQueryGrp);
    manager.add(createSqlMenu);
    addActionToManager(createSqlMenu, getAction(MakeCreateQueryAction.ID));
    addActionToManager(createSqlMenu, getAction(MakeCloneQueryAction.ID));
    manager.add(new Separator());
    // Schema to Code Actions
    addActionToManager(manager, getAction(TableToJavaCodeAction.ID));
    addActionToManager(manager, getAction(TableToPhpCodeAction.ID));
    addActionToManager(manager, getAction(ExportTableDefinitionAction.ID));
    manager.add(new Separator());
    // Install Schema Comment
    addActionToManager(manager, getAction(SchemaCommentInstallAction.ID));
    manager.add(new Separator());
    // View data
    IMenuManager viewDataMenu = new MenuManager(Messages.viewDataMenuName);
    manager.add(viewDataMenu);
    addActionToManager(viewDataMenu, getAction(TableSelectAllAction.ID));
    addActionToManager(viewDataMenu, getAction(SelectByOnePstmtDataAction.ID));
    addActionToManager(viewDataMenu, getAction(SelectByMultiPstmtDataAction.ID));
    viewDataMenu.add(new Separator());
    addActionToManager(viewDataMenu, getAction(TableSelectCountAction.ID));
    // Input data
    IMenuManager inputDataMenu = new MenuManager(Messages.inputDataMenuName);
    manager.add(inputDataMenu);
    addActionToManager(inputDataMenu, getAction(InsertOneByPstmtAction.ID));
    addActionToManager(inputDataMenu, getAction(ImportDataFromFileAction.ID));
    //		addActionToManager(manager, getAction(RunSQLFileAction.ID));
    manager.add(new Separator());
    // Export & Import Actions
    addActionToManager(manager, getAction(ExportWizardAction.ID));
    addActionToManager(manager, getAction(ImportWizardAction.ID));
    manager.add(new Separator());
    // Manage table
    addActionToManager(manager, getAction(EditTableAction.ID));
    IAction renameTableAction = getAction(RenameTableAction.ID);
    renameTableAction.setText(com.cubrid.common.ui.spi.Messages.tableRenameActionName);
    renameTableAction.setImageDescriptor(CommonUIPlugin.getImageDescriptor("icons/action/table_rename.png"));
    addActionToManager(manager, renameTableAction);
    IMenuManager moreMenu = new MenuManager(Messages.tableMoreName);
    addActionToManager(moreMenu, getAction(DeleteTableAction.ID));
    IAction action = getAction(DeleteTableAction.ID);
    if (CompatibleUtil.isSupportTruncateTable(dbInfo)) {
        if (action != null) {
            action.setText(Messages.deleteAllRecordsActionName);
        }
        addActionToManager(moreMenu, getAction(TruncateTableAction.ID));
    } else {
        if (action != null) {
            action.setText(Messages.tableDeleteAllActionName);
        }
    }
    IAction tableDropAction = getAction(DropTableAction.ID);
    addActionToManager(moreMenu, tableDropAction);
    moreMenu.add(new Separator());
    if (CompatibleUtil.isSupportCreateTableLike(dbInfo)) {
        addActionToManager(moreMenu, getAction(CreateLikeTableAction.ID));
    }
    manager.add(moreMenu);
}
Also used : IAction(org.eclipse.jface.action.IAction) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13