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