use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
the class EditTaskConfigurationDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite formPanel = UIUtils.createComposite(composite, 2);
formPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
ModifyListener modifyListener = e -> {
updateButtons();
};
UIUtils.createLabelText(formPanel, TaskUIMessages.edit_task_config_dialog_label_type, taskType.getCategory().getName() + " / " + taskType.getName(), SWT.BORDER | SWT.READ_ONLY);
boolean taskSaved = task != null && !CommonUtils.isEmpty(task.getId());
taskLabelCombo = UIUtils.createLabelCombo(formPanel, TaskUIMessages.edit_task_config_dialog_label_name, "", SWT.BORDER | (taskSaved ? SWT.READ_ONLY : SWT.NONE));
((GridData) taskLabelCombo.getLayoutData()).widthHint = 300;
if (task != null) {
taskLabelCombo.setText(task.getName());
} else {
taskLabelCombo.add("");
DBTTaskManager taskManager = project.getTaskManager();
allTasks = taskManager.getAllTaskByType(taskType);
for (DBTTask tc : allTasks) {
taskLabelCombo.add(tc.getName());
}
/*
taskLabelCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selectionIndex = taskLabelCombo.getSelectionIndex();
if (selectionIndex == 0) {
task = null;
setTitle("Create task " + taskType.getName());
} else {
task = (TaskImpl) allTasks[selectionIndex - 1];
taskDescriptionText.setText(CommonUtils.notEmpty(task.getDescription()));
setTitle("Edit task " + task.getName());
}
}
});
*/
}
taskLabelCombo.addModifyListener(modifyListener);
if (taskSaved) {
taskLabelCombo.setEnabled(false);
}
// if (!CommonUtils.isEmpty(task.getId())) {
// UIUtils.createLabelText(formPanel, "ID", task.getId(), SWT.BORDER | SWT.READ_ONLY);
// }
taskDescriptionText = UIUtils.createLabelText(formPanel, TaskUIMessages.edit_task_config_dialog_label_descr, task == null ? "" : CommonUtils.notEmpty(task.getDescription()), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
((GridData) taskDescriptionText.getLayoutData()).heightHint = taskDescriptionText.getLineHeight() * 5;
taskDescriptionText.addModifyListener(modifyListener);
UIUtils.asyncExec(() -> taskLabelCombo.setFocus());
return composite;
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
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 serge-rider.
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 serge-rider.
the class TaskConfigurationWizardDialog method openNewTaskDialog.
public static int openNewTaskDialog(IWorkbenchWindow window, DBPProject project, String taskTypeId, IStructuredSelection selection) {
TaskTypeDescriptor taskType = TaskRegistry.getInstance().getTaskType(taskTypeId);
if (taskType == null) {
DBWorkbench.getPlatformUI().showError("Bad task type", "Task type '" + taskTypeId + "' not found");
return IDialogConstants.CANCEL_ID;
}
try {
DBTTask task = project.getTaskManager().createTemporaryTask(taskType, taskType.getName());
task.setProperties(new HashMap<>());
DBTTaskConfigurator configurator = TaskUIRegistry.getInstance().createConfigurator(taskType);
TaskConfigurationWizard configWizard = configurator.createTaskConfigWizard(task);
TaskConfigurationWizardDialog dialog = new TaskConfigurationWizardDialog(window, configWizard, selection);
return dialog.open();
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError("Task create error", "Error creating task '" + taskTypeId + "'", e);
return IDialogConstants.CANCEL_ID;
}
}
use of org.jkiss.dbeaver.model.task.DBTTask in project dbeaver by serge-rider.
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;
}
}
Aggregations