use of com.cubrid.cubridmanager.core.cubrid.serial.task.CreateOrEditSerialTask in project cubrid-manager by CUBRID.
the class CreateOrEditSerialDialog method createSerial.
/**
* Execute task and create serial
*
* @param buttonId the button id
*/
private void createSerial(final int buttonId) {
// FIXME move this logic to core module
serialName = serialNameText.getText();
final String startVal = startValText.getText();
final String incrementVal = incrementValText.getText();
final String minVal = minValText.getText();
final String maxVal = maxValText.getText();
final boolean isNoMinValue = noMinValueBtn.getSelection();
final boolean isNoMaxValue = noMaxValueBtn.getSelection();
final boolean isCycle = cycleButton.getSelection();
final String cacheCount = isSupportCache ? cacheCountText.getText().trim() : null;
final boolean isNoCache = isSupportCache ? noCacheBtn.getSelection() : false;
if (editedNode == null) {
taskName = Messages.bind(Messages.createSerialTaskName, serialName);
} else {
taskName = Messages.bind(Messages.editSerialTaskName, serialName);
}
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
if (task instanceof CreateOrEditSerialTask) {
CreateOrEditSerialTask createSerialTask = (CreateOrEditSerialTask) task;
if (editedNode == null) {
createSerialTask.createSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
} else {
createSerialTask.editSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
}
}
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
return false;
}
if (openErrorBox(getShell(), msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
DatabaseInfo databaseInfo = database.getDatabaseInfo();
CreateOrEditSerialTask task = new CreateOrEditSerialTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
setReturnCode(buttonId);
close();
}
}
Aggregations