use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
the class SQLToolTaskWizard method performFinish.
@Override
public boolean performFinish() {
if (isRunTaskOnFinish()) {
// Only if task is not temporary
saveConfigurationToTask(getCurrentTask());
return super.performFinish();
}
try {
// Execute task in wizard
DBTTask task = getCurrentTask();
saveConfigurationToTask(task);
pageStatus.clearLog();
getContainer().showPage(pageStatus);
TaskWizardExecutor executor = new SQLTaskExecutor(task);
executor.executeTask();
if (taskHandler.needsRefreshOnFinish()) {
refreshOnFinish();
}
return false;
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError(e.getMessage(), TasksSQLUIMessages.sql_tool_task_wizard_message_error_running_task, e);
return false;
}
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
the class TaskHandlerEdit method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof DBTTask) {
DBTTask task = (DBTTask) element;
DBTTaskType taskTypeDescriptor = task.getType();
if (!TaskUIRegistry.getInstance().supportsConfigurator(taskTypeDescriptor)) {
DBWorkbench.getPlatformUI().showError("No configurator", "Task '" + taskTypeDescriptor.getName() + "' has no configurator");
return null;
}
try {
TaskConfigurationWizard wizard = TaskUIRegistry.getInstance().createConfigurator(taskTypeDescriptor).createTaskConfigWizard(task);
if (wizard != null) {
TaskConfigurationWizardDialog dialog = new TaskConfigurationWizardDialog(HandlerUtil.getActiveWorkbenchWindow(event), wizard);
dialog.setEditMode(true);
dialog.open();
}
} catch (Throwable e) {
DBWorkbench.getPlatformUI().showError("Task configuration", "Error opening task '" + task.getName() + "' configuration editor", e);
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
the class TaskHandlerProperties 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 element = structSelection.getFirstElement();
if (element instanceof DBTTask) {
EditTaskConfigurationDialog dialog = new EditTaskConfigurationDialog(HandlerUtil.getActiveShell(event), (DBTTask) element);
dialog.open();
}
}
return null;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
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());
}
}
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
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;
}
Aggregations