use of com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoTask in project cubrid-manager by CUBRID.
the class EditSerialAction method run.
/**
* Open the editSerial dialog and edit serial
*/
public int run(CubridDatabase database, final ISchemaNode node) {
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadSerialTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
SerialInfo serialInfo = null;
if (task instanceof GetSerialInfoTask) {
GetSerialInfoTask getSerialInfoTask = (GetSerialInfoTask) task;
serialInfo = getSerialInfoTask.getSerialInfo(node.getLabel());
}
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (serialInfo == null) {
openErrorBox(shell, Messages.errNameNotExist, monitor);
return false;
}
node.setModelObj(serialInfo);
}
return true;
}
};
DatabaseInfo databaseInfo = database.getDatabaseInfo();
GetSerialInfoTask task = new GetSerialInfoTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return IDialogConstants.CANCEL_ID;
}
boolean isEditorAble = ActionSupportUtil.isSupportSinSelCheckDbUser(node, NodeType.SERIAL);
CreateOrEditSerialDialog dialog = new CreateOrEditSerialDialog(getShell(), isEditorAble);
dialog.setEditedNode(node);
dialog.setDatabase(database);
if (dialog.open() == IDialogConstants.OK_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
Aggregations