use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class RenameColumnDialog method okPressed.
/**
* Save the new text.
*/
protected void okPressed() {
newName = newText.getText().trim();
TaskExecutor taskExec = new CommonTaskExec(Messages.bind(Messages.renameShellTitle, tableName, column));
RenameTableColumnTask task = new RenameTableColumnTask(database.getDatabaseInfo());
task.setTableName(tableName);
task.setNewName(newName);
task.setOldName(column);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).busyCursorWhile();
if (taskExec.isSuccess()) {
super.okPressed();
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class LongTextCellPopupDialog method exportData.
/**
*
* Export data to file
*
* @param filePath String
*/
private void exportData(final String filePath) {
final String charsetName = fileCharsetCombo.getText();
final String content = columnValueText.getText();
AbstractUITask task = new AbstractUITask() {
boolean isSuccess = false;
public void execute(final IProgressMonitor monitor) {
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), charsetName));
writer.write(content);
writer.flush();
isSuccess = true;
} catch (IOException e) {
errorMsg = e.getMessage();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
// ignore
}
}
}
}
public void cancel() {
//empty
}
public void finish() {
//empty
}
public boolean isCancel() {
return false;
}
public boolean isSuccess() {
return isSuccess;
}
};
TaskExecutor taskExecutor = new CommonTaskExec(Messages.msgExportFieldData);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
CommonUITool.openInformationBox(getShell(), Messages.titleSuccess, Messages.msgExportSuccess);
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class DeleteUserAction method doRun.
public void doRun(ISchemaNode node) {
// FIXME move this logic to core module
CubridDatabase database = node.getDatabase();
if (database == null || node == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
ICubridNode folderNode = database.getChild(childId);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
// if (database.getDatabaseInfo().isHAMode()) {
// CommonUITool.openErrorBox(com.cubrid.cubridmanager.ui.common.Messages.errNoSupportInHA);
// return;
// }
TaskExecutor taskExecutor = new CommonTaskExec(CommonTaskName.DELETE_USER_TASK_NAME);
DropUserTask task = new DropUserTask(database.getDatabaseInfo(), node.getName());
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null) {
TreeViewer treeViewer = navigatorView.getViewer();
if (treeViewer != null) {
//refresh user folder count label
CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node.getParent());
CommonUITool.openInformationBox(com.cubrid.common.ui.common.Messages.titleSuccess, Messages.msgDeleteUserSuccess);
}
}
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class EditUserDialog method execTask.
public boolean execTask(final int buttonId, final ITask[] tasks, Shell shell) {
final Display display = Display.getCurrent();
TaskExecutor taskExecutor = new TaskExecutor() {
public boolean exec(IProgressMonitor monitor) {
for (ITask task : tasks) {
if (task instanceof GetAllClassListTask) {
setAllClassInfoList(((GetAllClassListTask) task).getAllClassInfoList());
} else {
task.execute();
}
if (openErrorBox(null, task.getErrorMsg(), monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
}
if (!monitor.isCanceled()) {
display.syncExec(new Runnable() {
public void run() {
if (buttonId > 0) {
setReturnCode(buttonId);
close();
}
}
});
}
return true;
}
};
for (ITask task : tasks) {
taskExecutor.addTask(task);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
return taskExecutor.isSuccess();
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class CreateTriggerDialog method executeBySocket.
/**
*
* Execute to add or alter trigger by socket
*
* @param buttonId int
*/
private void executeBySocket(int buttonId) {
// FIXME remove
String taskName = null;
String message = null;
ITask executedTask = null;
if (buttonId == IDialogConstants.OK_ID) {
String eventType = getEventType();
String triggerEventTargetTable = triggerTargetTableCombo.getText().trim();
String triggerEventTargetColumn = triggerTargetColumnCombo.getText().trim();
AddTriggerTask task = new AddTriggerTask(database.getServer().getServerInfo());
task.setDbName(database.getName());
task.setTriggerName("\"" + triggerName + "\"");
String eventTime = getEventTime();
task.setConditionTime(TriggerConditionTime.eval(eventTime));
task.setEventType(TriggerEvent.eval(eventType));
String triggerActionType = getActionType();
String triggerAction = triggerActionText.getText().trim();
String crChar = "\r";
String nlChar = "\n";
triggerAction = triggerAction.replaceAll(crChar, "");
triggerAction = triggerAction.replaceAll(nlChar, " ");
task.setAction(Trigger.TriggerAction.eval(triggerActionType), triggerAction);
if (triggerEventTargetTable.length() > 0) {
if (triggerEventTargetColumn.length() > 0) {
task.setEventTarget("\"" + triggerEventTargetTable + "\"(\"" + triggerEventTargetColumn + "\")");
} else {
task.setEventTarget("\"" + triggerEventTargetTable + "\"");
}
}
String actionTime = getActionTime();
if (!actionTime.equals(Messages.actionTimeDefault)) {
// action time selected
task.setActionTime(TriggerActionTime.eval(actionTime));
}
String triggerCondition = triggerConditionText.getText().trim();
triggerCondition = triggerCondition.replaceAll(crChar, "");
triggerCondition = triggerCondition.replaceAll(nlChar, " ");
task.setCondition(triggerCondition);
String triggerStatus = this.getStatus();
task.setStatus(TriggerStatus.eval(triggerStatus));
String strPriority = triggerPriorityText.getText();
task.setPriority(strPriority);
taskName = Messages.bind(Messages.addTriggerTaskName, triggerName);
message = Messages.newTriggerSuccess;
executedTask = task;
} else if (buttonId == ALTER_TRIGGER_OK_ID) {
AlterTriggerTask task = new AlterTriggerTask(database.getServer().getServerInfo());
task.setDbName(database.getName());
task.setTriggerName(trigger.getName());
String triggerStatus = this.getStatus();
task.setStatus(TriggerStatus.eval(triggerStatus));
String strPriority = triggerPriorityText.getText();
task.setPriority(strPriority);
taskName = Messages.bind(Messages.alterTriggerTaskName, trigger.getName());
message = Messages.alterTriggerSuccess;
executedTask = task;
}
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(executedTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
setReturnCode(buttonId);
close();
CommonUITool.openInformationBox(Messages.msgInformation, message);
}
}
Aggregations