Search in sources :

Example 1 with Collation

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

the class EditVirtualTableDialog method buildVirtualDBCollationList.

private void buildVirtualDBCollationList() {
    collationList = new ArrayList<Collation>();
    Collation emptyCollation = new Collation();
    emptyCollation.setCharset("");
    emptyCollation.setName("");
    collationList.add(emptyCollation);
    collationList.addAll(Collation.getDefaultCollations());
}
Also used : Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation)

Example 2 with Collation

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

the class GetCollations method execute.

public void execute() {
    String sql = "SELECT coll_name, charset_name FROM db_collation ORDER BY coll_id ASC";
    // [TOOLS-2425]Support shard broker
    sql = databaseInfo.wrapShardQuery(sql);
    collations = new ArrayList<Collation>();
    try {
        if (StringUtil.isNotEmpty(errorMsg)) {
            return;
        }
        if (connection == null || connection.isClosed()) {
            errorMsg = Messages.error_getConnection;
            return;
        }
        stmt = connection.createStatement();
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            Collation collation = new Collation();
            collation.setName(rs.getString("coll_name"));
            collation.setCharset(rs.getString("charset_name"));
            collations.add(collation);
        }
    } catch (SQLException e) {
        errorMsg = e.getMessage();
    } finally {
        finish();
    }
}
Also used : SQLException(java.sql.SQLException) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation)

Example 3 with Collation

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

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

the class TableEditorPart method fillCollationCombo.

private void fillCollationCombo() {
    if (collationList == null || WidgetUtil.disposed(collationCombo)) {
        return;
    }
    String searchCol = null;
    if (oldSchemaInfo != null) {
        searchCol = oldSchemaInfo.getCollation();
    } else if (newSchemaInfo != null) {
        searchCol = newSchemaInfo.getCollation();
    } else {
        searchCol = Collation.DEFAULT_COLLATION;
    }
    for (Collation collation : collationList) {
        if (collation == null) {
            continue;
        }
        String collationName = collation.getName();
        if (collationName == null) {
            continue;
        }
        collationCombo.add(collationName);
        if (collationName.equals(searchCol)) {
            collationCombo.select(collationCombo.getItemCount() - 1);
        }
    }
    if (collationCombo.getItemCount() > 0 && collationCombo.getSelectionIndex() == -1) {
        collationCombo.select(0);
    }
}
Also used : Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation)

Example 5 with Collation

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

the class ERSchema method clone.

public ERSchema clone() {
    ERSchema schema = null;
    try {
        schema = (ERSchema) super.clone();
        schema.physicalLogicalRelation = physicalLogicalRelation.clone();
        List<ERTable> copiedTables = new ArrayList<ERTable>();
        for (ERTable table : tablesList) {
            copiedTables.add(table.clone());
        }
        schema.tablesList = copiedTables;
        List<Collation> copiedCollections = new LinkedList<Collation>();
        for (Collation collation : collections) {
            copiedCollections.add(collation.clone());
        }
        schema.collections = copiedCollections;
    } catch (CloneNotSupportedException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return schema;
}
Also used : ArrayList(java.util.ArrayList) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation) LinkedList(java.util.LinkedList)

Aggregations

Collation (com.cubrid.cubridmanager.core.cubrid.database.model.Collation)10 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)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 SQLException (java.sql.SQLException)2 IWorkbench (org.eclipse.ui.IWorkbench)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 Constraint (com.cubrid.common.core.common.model.Constraint)1 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)1 IDatabaseSpec (com.cubrid.common.core.common.model.IDatabaseSpec)1 SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)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