Search in sources :

Example 1 with GetCollations

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations in project cubrid-manager by CUBRID.

the class EditTableAction method doRun.

private void doRun(ISchemaNode table, int type) {
    final DatabaseInfo databaseInfo = NodeUtil.findDatabaseInfo(table);
    if (databaseInfo == null) {
        return;
    }
    final String tableName = table.getName();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            databaseInfo.removeSchema(tableName);
            SchemaInfo schemaInfo = databaseInfo.getSchemaInfo(tableName);
            if (schemaInfo == null) {
                openErrorBox(shell, databaseInfo.getErrorMessage(), monitor);
                return false;
            }
            return true;
        }
    };
    boolean supportCharset = CompatibleUtil.isSupportCreateDBByCharset(databaseInfo);
    JDBCGetAllDbUserTask allUserTask = new JDBCGetAllDbUserTask(databaseInfo);
    taskExcutor.addTask(allUserTask);
    GetCollations collationTask = null;
    if (supportCharset) {
        collationTask = new GetCollations(databaseInfo);
        taskExcutor.addTask(collationTask);
    }
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    List<String> dbUserList = allUserTask.getDbUserList();
    SchemaInfo schemaInfo = databaseInfo.getSchemaInfo(tableName);
    TableEditorInput input = new TableEditorInput(table.getDatabase(), false, schemaInfo, table, type);
    input.setDbUserList(dbUserList);
    if (supportCharset) {
        List<Collation> collations = collationTask.getCollations();
        input.setCollationList(collations);
    }
    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        //If true, active opened editor of it and return, else open new editor.
        for (IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
            IEditorPart oldEditor = editorRef.getEditor(true);
            if (oldEditor.getEditorInput() instanceof TableEditorInput) {
                TableEditorInput oldInput = (TableEditorInput) oldEditor.getEditorInput();
                ISchemaNode oldTable = oldInput.getEditedTableNode();
                if (oldTable != null && oldTable.equals(table)) {
                    workbenchWindow.getActivePage().activate(oldEditor);
                    return;
                }
            }
        }
        workbenchWindow.getActivePage().openEditor(input, TableEditorPart.ID);
    } catch (Exception ignore) {
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableEditorInput(com.cubrid.common.ui.cubrid.table.editor.TableEditorInput) JDBCGetAllDbUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.JDBCGetAllDbUserTask) IEditorPart(org.eclipse.ui.IEditorPart) GetCollations(com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation) IWorkbench(org.eclipse.ui.IWorkbench) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 2 with GetCollations

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations in project cubrid-manager by CUBRID.

the class NewTableAction method doRun.

private void doRun(ISchemaNode node) {
    CubridDatabase database = node.getDatabase();
    TaskExecutor taskExcutor = new CommonTaskExec(null);
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    boolean supportCharset = CompatibleUtil.isSupportCreateDBByCharset(databaseInfo);
    JDBCGetAllDbUserTask allUserTask = new JDBCGetAllDbUserTask(databaseInfo);
    taskExcutor.addTask(allUserTask);
    GetCollations collationTask = null;
    if (supportCharset) {
        collationTask = new GetCollations(databaseInfo);
        taskExcutor.addTask(collationTask);
    }
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    TableEditorInput input = new TableEditorInput(database, true, null, null, EditTableAction.MODE_TABLE_EDIT);
    List<String> dbUserList = allUserTask.getDbUserList();
    input.setDbUserList(dbUserList);
    if (supportCharset) {
        List<Collation> collations = collationTask.getCollations();
        input.setCollationList(collations);
    }
    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        workbenchWindow.getActivePage().openEditor(input, TableEditorPart.ID);
    } catch (Exception ignore) {
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TableEditorInput(com.cubrid.common.ui.cubrid.table.editor.TableEditorInput) JDBCGetAllDbUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.JDBCGetAllDbUserTask) GetCollations(com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation) IWorkbench(org.eclipse.ui.IWorkbench) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 3 with GetCollations

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations in project cubrid-manager by CUBRID.

the class ERSchemaEditor method initCollections.

/**
	 * Get collections from database, and add a empty collection
	 * 
	 * @param databaseInfo
	 */
private void initCollections(final DatabaseInfo databaseInfo) {
    if (databaseInfo instanceof ERVirtualDatabaseInfo) {
        ERVirtualDatabaseInfo db = (ERVirtualDatabaseInfo) databaseInfo;
        erSchema.setCollections(db.getCollections());
        return;
    }
    new Thread(new Runnable() {

        public void run() {
            GetCollations collationTask = new GetCollations(databaseInfo);
            collationTask.execute();
            List<Collation> collationList = collationTask.getCollations();
            Collation emptyCollation = new Collation();
            emptyCollation.setCharset("");
            emptyCollation.setName("");
            collationList.add(0, emptyCollation);
            erSchema.setCollections(collationList);
        }
    }).start();
}
Also used : ERVirtualDatabaseInfo(com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo) GetCollations(com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation)

Aggregations

Collation (com.cubrid.cubridmanager.core.cubrid.database.model.Collation)3 GetCollations (com.cubrid.cubridmanager.core.cubrid.table.task.GetCollations)3 TableEditorInput (com.cubrid.common.ui.cubrid.table.editor.TableEditorInput)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 JDBCGetAllDbUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.JDBCGetAllDbUserTask)2 IWorkbench (org.eclipse.ui.IWorkbench)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 ITask (com.cubrid.common.core.task.ITask)1 ERVirtualDatabaseInfo (com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IEditorReference (org.eclipse.ui.IEditorReference)1