use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class SelectByOnePstmtDataAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
doRun(node);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class EditTableAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISelectionProvider provider = getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
ISchemaNode tableNode = (ISchemaNode) obj[0];
doRun(tableNode, MODE_TABLE_EDIT);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class SerialDashboardEditorPart method openEditSerialDialog.
private void openEditSerialDialog(SerialInfo serialInfo) {
Set<String> typeSet = new HashSet<String>();
typeSet.add(NodeType.SERIAL);
ICubridNode serialNode = CommonUITool.findNode(database, typeSet, serialInfo.getName());
if (serialNode != null) {
EditSerialAction action = (EditSerialAction) ActionManager.getInstance().getAction(EditSerialAction.ID);
if (action.run(database, (ISchemaNode) serialNode) == IDialogConstants.OK_ID) {
refresh();
}
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class ColumnSelectSqlAction method isSupported.
public boolean isSupported(Object obj) {
boolean isPlainSupport = ActionSupportUtil.isSupportMultiSelection(obj, new String[] { NodeType.TABLE_COLUMN }, true);
boolean isSameTable = true;
if (isPlainSupport && obj instanceof Object[]) {
Object[] objArr = (Object[]) obj;
String parentNodeId = "";
for (int i = 0; i < objArr.length; i++) {
ISchemaNode schemaNode = (ISchemaNode) objArr[i];
ICubridNode parent = schemaNode.getParent();
if (i == 0) {
parentNodeId = parent.getId();
} else {
isSameTable = parentNodeId.equals(parent.getId());
}
}
}
return isPlainSupport && isSameTable;
}
Aggregations