use of com.cubrid.common.ui.cubrid.serial.dialog.CreateOrEditSerialDialog 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;
}
use of com.cubrid.common.ui.cubrid.serial.dialog.CreateOrEditSerialDialog in project cubrid-manager by CUBRID.
the class CreateSerialAction method run.
/**
* run create serial
* @param database
*/
public void run(CubridDatabase database) {
CreateOrEditSerialDialog dialog = new CreateOrEditSerialDialog(getShell(), true);
dialog.setDatabase(database);
ISelectionProvider provider = getSelectionProvider();
if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSerialFolderLoader.SERIAL_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
// FIXME move this logic to core module
String serialName = dialog.getSerialName().toLowerCase(Locale.getDefault());
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + serialName;
SerialInfo serialInfo = new SerialInfo();
serialInfo.setName(serialName);
serialInfo.setOwner(userInfo.getName());
ICubridNode newNode = CubridSerialFolderLoader.createSerialNode(id, serialInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
}
}
Aggregations