Search in sources :

Example 6 with Collation

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

the class ERVirtualDatabaseInfo method buildVirtualDBCollationList.

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

Example 7 with Collation

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

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

the class TableEditorPart method init.

public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    TableEditorInput tableInfoEditorInput = (TableEditorInput) input;
    this.database = tableInfoEditorInput.getDatabase();
    this.editedTableNode = tableInfoEditorInput.getEditedTableNode();
    this.isNewTableFlag = tableInfoEditorInput.isNewTableFlag();
    this.dbUserList = tableInfoEditorInput.getDbUserList();
    this.showDefaultType = tableInfoEditorInput.getType();
    this.collationList = tableInfoEditorInput.getCollationList();
    if (collationList != null) {
        Collation emptyCollation = new Collation();
        emptyCollation.setCharset("");
        emptyCollation.setName("");
        collationList.add(0, emptyCollation);
    }
    this.oldSchemaInfo = tableInfoEditorInput.getSchemaInfo();
    this.supportCharset = CompatibleUtil.isSupportCreateDBByCharset(database.getDatabaseInfo());
    if (isNewTableFlag) {
        newSchemaInfo = new SchemaInfo();
        //$NON-NLS-1$
        newSchemaInfo.setClassname("");
        newSchemaInfo.setOwner(database.getUserName());
        newSchemaInfo.setDbname(database.getName());
        newSchemaInfo.setType(Messages.userSchema);
        newSchemaInfo.setVirtual(Messages.schemaTypeClass);
        if (database.getDatabaseInfo() != null) {
            newSchemaInfo.setCollation(database.getDatabaseInfo().getCollation());
        }
    } else {
        newSchemaInfo = null;
        if (tableInfoEditorInput.getSchemaInfo() != null) {
            newSchemaInfo = tableInfoEditorInput.getSchemaInfo().clone();
            originalConstraints.addAll(newSchemaInfo.getConstraints());
        }
    }
    if (supportCharset) {
        columnProperites = new String[] { IAttributeColumn.COL_EMPTY, IAttributeColumn.COL_FLAG, IAttributeColumn.COL_NAME, IAttributeColumn.COL_DATATYPE, IAttributeColumn.COL_DEFAULT, IAttributeColumn.COL_AUTO_INCREMENT, IAttributeColumn.COL_NOT_NULL, IAttributeColumn.COL_PK, IAttributeColumn.COL_UK, IAttributeColumn.COL_SHARED, IAttributeColumn.COL_COLLATION, IAttributeColumn.COL_MEMO };
    } else {
        columnProperites = new String[] { IAttributeColumn.COL_EMPTY, IAttributeColumn.COL_FLAG, IAttributeColumn.COL_NAME, IAttributeColumn.COL_DATATYPE, IAttributeColumn.COL_DEFAULT, IAttributeColumn.COL_AUTO_INCREMENT, IAttributeColumn.COL_NOT_NULL, IAttributeColumn.COL_PK, IAttributeColumn.COL_UK, IAttributeColumn.COL_SHARED, IAttributeColumn.COL_MEMO };
    }
    Connection conn = null;
    try {
        conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
        IDatabaseSpec dbSpec = database.getDatabaseInfo();
        isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(dbSpec, conn);
        database.getDatabaseInfo().setSupportTableComment(isSupportTableComment);
        if (isSupportTableComment && !isNewTableFlag && newSchemaInfo != null) {
            Map<String, SchemaComment> map = SchemaCommentHandler.loadDescription(dbSpec, conn, newSchemaInfo.getClassname());
            for (DBAttribute attr : newSchemaInfo.getAttributes()) {
                SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), attr.getName());
                if (schemaComment != null) {
                    attr.setDescription(schemaComment.getDescription());
                }
            }
            // get description for index
            for (Constraint cons : newSchemaInfo.getConstraints()) {
                if (CompatibleUtil.isCommentSupports(dbSpec)) {
                    String indexName = cons.getName();
                    SchemaComment indexComment = SchemaCommentHandler.loadObjectDescription(dbSpec, conn, indexName, CommentType.INDEX);
                    if (indexComment != null) {
                        cons.setDescription(indexComment.getDescription());
                    }
                }
            }
            SchemaComment schemaComment = SchemaCommentHandler.find(map, newSchemaInfo.getClassname(), null);
            if (schemaComment != null) {
                newSchemaInfo.setDescription(schemaComment.getDescription());
            }
        }
    } catch (SQLException e) {
        LOGGER.error("", e);
    } catch (Exception e) {
        LOGGER.error("", e);
    } finally {
        QueryUtil.freeQuery(conn);
    }
    schemaChangeMgr = new SchemaChangeManager(database.getDatabaseInfo(), isNewTableFlag);
    schemaDDL = new SchemaDDL(schemaChangeMgr, database.getDatabaseInfo());
    if (database != null) {
        isSupportChange = CompatibleUtil.isSupportChangeColumn(database.getDatabaseInfo());
    }
    setSite(site);
    setInput(input);
    setPartName(input.getName());
    setTitleToolTip(input.getName());
    setTitleImage(CommonUIPlugin.getImage("icons/navigator/schema_table.png"));
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) SQLException(java.sql.SQLException) SchemaChangeManager(com.cubrid.cubridmanager.core.cubrid.table.model.SchemaChangeManager) Connection(java.sql.Connection) Collation(com.cubrid.cubridmanager.core.cubrid.database.model.Collation) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) IDatabaseSpec(com.cubrid.common.core.common.model.IDatabaseSpec) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) SchemaDDL(com.cubrid.cubridmanager.core.cubrid.table.model.SchemaDDL) SchemaComment(com.cubrid.common.core.schemacomment.model.SchemaComment) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 9 with Collation

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

Example 10 with Collation

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

the class EditVirtualTableDialog method fillCollationCombo.

private void fillCollationCombo() {
    if (collationList == null || WidgetUtil.disposed(collationCombo)) {
        return;
    }
    String searchCol = null;
    SchemaInfo newSchemaInfo = getNewSchemaInfo();
    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) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

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