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