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);
}
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) {
}
}
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"));
}
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();
}
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);
}
}
Aggregations