Search in sources :

Example 1 with TaskImpl

use of org.jkiss.dbeaver.registry.task.TaskImpl 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;
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) Date(java.util.Date) DBTTaskType(org.jkiss.dbeaver.model.task.DBTTaskType) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) NotNull(org.jkiss.code.NotNull) BaseDialog(org.jkiss.dbeaver.ui.dialogs.BaseDialog) LinkedHashMap(java.util.LinkedHashMap) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) DBTTaskManager(org.jkiss.dbeaver.model.task.DBTTaskManager) Map(java.util.Map) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) TaskImpl(org.jkiss.dbeaver.registry.task.TaskImpl) GridData(org.eclipse.swt.layout.GridData) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) CommonUtils(org.jkiss.utils.CommonUtils) Text(org.eclipse.swt.widgets.Text) TaskUIMessages(org.jkiss.dbeaver.tasks.ui.internal.TaskUIMessages) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) DBIcon(org.jkiss.dbeaver.model.DBIcon) DBException(org.jkiss.dbeaver.DBException) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) DBTTaskManager(org.jkiss.dbeaver.model.task.DBTTaskManager) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) GridData(org.eclipse.swt.layout.GridData)

Example 2 with TaskImpl

use of org.jkiss.dbeaver.registry.task.TaskImpl in project dbeaver by dbeaver.

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;
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) Date(java.util.Date) DBTTaskType(org.jkiss.dbeaver.model.task.DBTTaskType) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) NotNull(org.jkiss.code.NotNull) BaseDialog(org.jkiss.dbeaver.ui.dialogs.BaseDialog) LinkedHashMap(java.util.LinkedHashMap) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) DBTTaskManager(org.jkiss.dbeaver.model.task.DBTTaskManager) Map(java.util.Map) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) TaskImpl(org.jkiss.dbeaver.registry.task.TaskImpl) GridData(org.eclipse.swt.layout.GridData) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) CommonUtils(org.jkiss.utils.CommonUtils) Text(org.eclipse.swt.widgets.Text) TaskUIMessages(org.jkiss.dbeaver.tasks.ui.internal.TaskUIMessages) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) DBIcon(org.jkiss.dbeaver.model.DBIcon) DBException(org.jkiss.dbeaver.DBException) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) DBTTaskManager(org.jkiss.dbeaver.model.task.DBTTaskManager) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) GridData(org.eclipse.swt.layout.GridData)

Aggregations

Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 SWT (org.eclipse.swt.SWT)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 GridData (org.eclipse.swt.layout.GridData)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Shell (org.eclipse.swt.widgets.Shell)2 Text (org.eclipse.swt.widgets.Text)2 NotNull (org.jkiss.code.NotNull)2 DBException (org.jkiss.dbeaver.DBException)2 DBIcon (org.jkiss.dbeaver.model.DBIcon)2 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)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 TaskImpl (org.jkiss.dbeaver.registry.task.TaskImpl)2