use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class TaskHandlerRun method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
String taskId = event.getParameter("task");
DBTTask task = null;
if (!CommonUtils.isEmpty(taskId)) {
task = NavigatorUtils.getSelectedProject().getTaskManager().getTaskById(taskId);
} else {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof DBTTask) {
task = (DBTTask) element;
}
}
}
if (task != null) {
runTask(task);
}
return null;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class TaskConfigurationWizardPageSettings method activatePage.
@Override
public void activatePage() {
DBTTask currentTask = getWizard().getCurrentTask();
DBTTaskType selectedTaskType = currentTask != null ? currentTask.getType() : getTaskPage().getSelectedTaskType();
if (curTaskType == selectedTaskType) {
return;
}
curTaskType = selectedTaskType;
createTaskSettingsUI();
if (curTaskType == null) {
setTitle(TaskUIMessages.task_config_wizard_page_settings_title_task_prop);
setDescription(TaskUIMessages.task_config_wizard_page_settings_descr_set_task);
} else {
String title = curTaskType.getName();
if (getWizard().getCurrentTask() != null) {
title += " (" + getWizard().getCurrentTask().getName() + ")";
}
setTitle(title);
setDescription(NLS.bind(TaskUIMessages.task_config_wizard_page_settings_config, curTaskType.getName()));
}
setPageComplete(determinePageCompletion());
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
the class RecentTasksMenuContributor method fillContributionItems.
@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
DBPProject project = NavigatorUtils.getSelectedProject();
if (project == null) {
return;
}
DBTTask[] tasks = project.getTaskManager().getAllTasks();
Arrays.sort(tasks, (o1, o2) -> {
DBTTaskRun lr1 = o1.getLastRun();
DBTTaskRun lr2 = o1.getLastRun();
if (lr1 == lr2)
return o1.getCreateTime().compareTo(o2.getCreateTime());
else if (lr1 == null)
return -1;
else if (lr2 == null)
return 1;
else
return lr1.getStartTime().compareTo(lr2.getStartTime());
});
for (int i = 0; i < tasks.length && i <= MAX_ITEMS; i++) {
DBTTask task = tasks[i];
DBPImage taskIcon = task.getType().getIcon();
if (taskIcon == null)
taskIcon = DBIcon.TREE_TASK;
menuItems.add(ActionUtils.makeActionContribution(new Action(task.getName(), DBeaverIcons.getImageDescriptor(taskIcon)) {
@Override
public void run() {
TaskHandlerRun.runTask(task);
}
}, false));
}
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by dbeaver.
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 dbeaver.
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;
}
Aggregations