Search in sources :

Example 6 with TaskConfigurationWizardDialog

use of org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizardDialog 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;
}
Also used : DBTTask(org.jkiss.dbeaver.model.task.DBTTask) ISelection(org.eclipse.jface.viewers.ISelection) TaskConfigurationWizardDialog(org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizardDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TaskConfigurationWizard(org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizard) DBTTaskType(org.jkiss.dbeaver.model.task.DBTTaskType)

Aggregations

TaskConfigurationWizardDialog (org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizardDialog)6 ExecutionException (org.eclipse.core.commands.ExecutionException)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 DBException (org.jkiss.dbeaver.DBException)2 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DBTTask (org.jkiss.dbeaver.model.task.DBTTask)2 DBTTaskManager (org.jkiss.dbeaver.model.task.DBTTaskManager)2 DBTTaskType (org.jkiss.dbeaver.model.task.DBTTaskType)2 TaskConfigurationWizard (org.jkiss.dbeaver.tasks.ui.wizard.TaskConfigurationWizard)2 DialogSettingsMap (org.jkiss.dbeaver.ui.DialogSettingsMap)2