use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class DataTransferWizard method performFinish.
@Override
public boolean performFinish() {
saveDialogSettings();
if (!super.performFinish()) {
return false;
}
try {
DBTTask currentTask = getCurrentTask();
if (currentTask == null) {
// Execute directly - without task serialize/deserialize
// We need it because some data producers cannot be serialized properly (e.g. ResultSetDatacontainer - see #7342)
DataTransferWizardExecutor executor = new DataTransferWizardExecutor(getRunnableContext(), DTMessages.data_transfer_wizard_job_name, getSettings());
executor.executeTask();
}
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError(e.getMessage(), DTUIMessages.data_transfer_wizard_message_init_data_transfer, e);
return false;
}
return true;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class AbstractNativeToolWizard method performFinish.
@Override
public boolean performFinish() {
// Save settings
settings.saveSettings(getRunnableContext(), getPreferenceStore());
if (!validateClientFiles()) {
return false;
}
if (getCurrentTask() != null) {
return super.performFinish();
}
showLogPage();
try {
// Execute directly - without task serialize/deserialize
// We need it because some data producers cannot be serialized properly (e.g. ResultSetDatacontainer - see #7342)
DBTTask temporaryTask = getProject().getTaskManager().createTemporaryTask(getTaskType(), getTaskType().getName());
saveConfigurationToTask(temporaryTask);
TaskWizardExecutor executor = new TaskWizardExecutor(getRunnableContext(), temporaryTask, log, logPage.getLogWriter());
executor.executeTask();
return false;
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError(e.getMessage(), "Error running task", e);
return false;
}
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class TaskHandlerCopy method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection) selection;
Object firstElement = structSelection.getFirstElement();
if (firstElement instanceof DBTTask) {
DBTTask oldTask = (DBTTask) firstElement;
for (; ; ) {
EnterNameDialog taskNameDialog = new EnterNameDialog(HandlerUtil.getActiveShell(event), TaskUIMessages.task_handler_copy_name_dialog_enter_task, oldTask.getName());
String newTaskName = taskNameDialog.chooseName();
if (newTaskName == null) {
return null;
}
DBTTaskManager taskManager = oldTask.getProject().getTaskManager();
if (taskManager.getTaskByName(newTaskName) != null) {
UIUtils.showMessageBox(HandlerUtil.getActiveShell(event), "Duplicate task name", "Task '" + newTaskName + "' already exists", SWT.ICON_ERROR);
continue;
}
try {
DBTTask newTask = taskManager.createTask(oldTask.getType(), newTaskName, oldTask.getDescription(), new LinkedHashMap<>(oldTask.getProperties()));
taskManager.updateTaskConfiguration(newTask);
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof DatabaseTasksView) {
UIUtils.asyncExec(() -> {
((DatabaseTasksView) activePart).getTasksTree().getViewer().setSelection(new StructuredSelection(newTask), true);
ActionUtils.runCommand(DatabaseTasksView.EDIT_TASK_CMD_ID, activePart.getSite());
});
}
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError("Task copy error", "Error copying task '" + oldTask.getName() + "'", e);
}
break;
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class TaskHandlerDelete method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
List<DBTTask> tasksToDelete = new ArrayList<>();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection) selection;
for (Iterator<?> iter = structSelection.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof DBTTask) {
tasksToDelete.add((DBTTask) element);
}
}
}
if (!tasksToDelete.isEmpty()) {
if (tasksToDelete.size() == 1) {
if (!UIUtils.confirmAction(HandlerUtil.getActiveShell(event), TaskUIMessages.task_handler_delete_confirm_title_delete_task, NLS.bind(TaskUIMessages.task_handler_delete_confirm_question_delete_task, tasksToDelete.get(0).getName()))) {
return null;
}
} else {
if (!UIUtils.confirmAction(HandlerUtil.getActiveShell(event), TaskUIMessages.task_handler_delete_confirm_title_delete_tasks, NLS.bind(TaskUIMessages.task_handler_delete_confirm_question_delete_tasks, tasksToDelete.size()))) {
return null;
}
}
for (DBTTask task : tasksToDelete) {
try {
task.getProject().getTaskManager().deleteTaskConfiguration(task);
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError(TaskUIMessages.task_handler_delete_error_deleting_task_from_scheduler_title, NLS.bind(TaskUIMessages.task_handler_delete_error_deleting_task_from_scheduler_message, task.getId()), e);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class TaskHandlerRun method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
String taskId = CommonUtils.toString(parameters.get("task"));
if (!CommonUtils.isEmpty(taskId)) {
DBTTask task = NavigatorUtils.getSelectedProject().getTaskManager().getTaskById(taskId);
if (task != null) {
DBPImage taskIcon = task.getType().getIcon();
if (taskIcon == null)
taskIcon = DBIcon.TREE_TASK;
element.setIcon(DBeaverIcons.getImageDescriptor(taskIcon));
element.setText(task.getName());
}
}
}
Aggregations