Search in sources :

Example 1 with DBTTaskConfigurator

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;
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBTTaskConfigurator(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) TaskTypeDescriptor(org.jkiss.dbeaver.registry.task.TaskTypeDescriptor)

Example 2 with DBTTaskConfigurator

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBTTaskConfigurator(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with DBTTaskConfigurator

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);
        }
    }
}
Also used : DBTTaskConfigPanel(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigPanel) DBTTaskConfigurator(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator)

Example 4 with DBTTaskConfigurator

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;
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBTTaskConfigurator(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) TaskTypeDescriptor(org.jkiss.dbeaver.registry.task.TaskTypeDescriptor)

Example 5 with DBTTaskConfigurator

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DBTTaskConfigurator(org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

DBTTaskConfigurator (org.jkiss.dbeaver.tasks.ui.DBTTaskConfigurator)6 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 DBException (org.jkiss.dbeaver.DBException)2 DBTTask (org.jkiss.dbeaver.model.task.DBTTask)2 TaskTypeDescriptor (org.jkiss.dbeaver.registry.task.TaskTypeDescriptor)2 DBTTaskConfigPanel (org.jkiss.dbeaver.tasks.ui.DBTTaskConfigPanel)2