use of org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator 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.tasks.ui.DBTTaskConfigurator in project dbeaver by serge-rider.
the class TaskConfigurationWizardPageTask method getTaskWizard.
public TaskConfigurationWizard getTaskWizard() throws DBException {
if (!(getWizard() instanceof TaskConfigurationWizardStub)) {
// We already have it
return getWizard();
}
TaskConfigurationWizard realWizard = taskWizards.get(selectedTaskType);
if (realWizard == null) {
DBTTaskConfigurator configurator = TaskUIRegistry.getInstance().createConfigurator(selectedTaskType);
if (task == null) {
task = (TaskImpl) selectedProject.getTaskManager().createTask(selectedTaskType, CommonUtils.notEmpty(taskName), taskDescription, new LinkedHashMap<>());
}
realWizard = configurator.createTaskConfigWizard(task);
IWorkbenchWindow workbenchWindow = UIUtils.getActiveWorkbenchWindow();
IWorkbenchPart activePart = workbenchWindow.getActivePage().getActivePart();
ISelection selection = activePart == null || activePart.getSite() == null || activePart.getSite().getSelectionProvider() == null ? null : activePart.getSite().getSelectionProvider().getSelection();
realWizard.setContainer(getContainer());
realWizard.init(workbenchWindow.getWorkbench(), selection instanceof IStructuredSelection ? (IStructuredSelection) selection : null);
taskWizards.put(selectedTaskType, realWizard);
}
return realWizard;
}
use of org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator in project dbeaver by serge-rider.
the class TaskConfigurationWizardPageSettings method createTaskSettingsUI.
private void createTaskSettingsUI() {
UIUtils.disposeChildControls(taskSettingsPlaceholder);
if (curTaskType != null && TaskUIRegistry.getInstance().supportsConfigurator(curTaskType)) {
try {
DBTTaskConfigurator configurator = TaskUIRegistry.getInstance().createConfigurator(curTaskType);
DBTTaskConfigPanel configPage = configurator.createInputConfigurator(UIUtils.getDefaultRunnableContext(), curTaskType);
if (configPage != null) {
taskConfigPanel = configPage;
TaskConfigurationWizard taskWizard = getTaskPage().getTaskWizard();
taskConfigPanel.createControl(taskSettingsPlaceholder, taskWizard, this::updatePageCompletion);
if (getWizard().getCurrentTask() != null) {
taskConfigPanel.loadSettings();
}
taskSettingsPlaceholder.layout(true, true);
}
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Task configurator error", "Error creating task configuration UI", e);
}
}
}
use of org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator in project dbeaver by dbeaver.
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.tasks.ui.DBTTaskConfigurator in project dbeaver by dbeaver.
the class TaskConfigurationWizardPageTask method getTaskWizard.
public TaskConfigurationWizard getTaskWizard() throws DBException {
if (!(getWizard() instanceof TaskConfigurationWizardStub)) {
// We already have it
return getWizard();
}
TaskConfigurationWizard realWizard = taskWizards.get(selectedTaskType);
if (realWizard == null) {
DBTTaskConfigurator configurator = TaskUIRegistry.getInstance().createConfigurator(selectedTaskType);
if (task == null) {
task = (TaskImpl) selectedProject.getTaskManager().createTask(selectedTaskType, CommonUtils.notEmpty(taskName), taskDescription, new LinkedHashMap<>());
}
realWizard = configurator.createTaskConfigWizard(task);
IWorkbenchWindow workbenchWindow = UIUtils.getActiveWorkbenchWindow();
IWorkbenchPart activePart = workbenchWindow.getActivePage().getActivePart();
ISelection selection = activePart == null || activePart.getSite() == null || activePart.getSite().getSelectionProvider() == null ? null : activePart.getSite().getSelectionProvider().getSelection();
realWizard.setContainer(getContainer());
realWizard.init(workbenchWindow.getWorkbench(), selection instanceof IStructuredSelection ? (IStructuredSelection) selection : null);
taskWizards.put(selectedTaskType, realWizard);
}
return realWizard;
}
Aggregations