use of org.jkiss.dbeaver.model.task.DBTTaskCategory in project dbeaver by dbeaver.
the class TaskConfigurationWizardPageTask method addTaskCategories.
private void addTaskCategories(TreeItem parentItem, DBTTaskCategory[] categories) {
List<DBTTaskCategory> allCats = Arrays.asList(categories);
allCats.sort(Comparator.comparing(DBTTaskCategory::getName));
for (DBTTaskCategory cat : categories) {
if (!isTaskCategoryApplicable(cat)) {
continue;
}
TreeItem item = parentItem == null ? new TreeItem(taskCategoryTree, SWT.NONE) : new TreeItem(parentItem, SWT.NONE);
item.setText(0, cat.getName());
item.setImage(0, DBeaverIcons.getImage(cat.getIcon() == null ? DBIcon.TREE_TASK : cat.getIcon()));
item.setText(1, CommonUtils.notEmpty(cat.getDescription()));
item.setData(cat);
addTaskCategories(item, cat.getChildren());
addTaskTypes(item, cat);
item.setExpanded(true);
}
}
use of org.jkiss.dbeaver.model.task.DBTTaskCategory in project dbeaver by serge-rider.
the class TaskConfigurationWizardPageTask method createControl.
@Override
public void createControl(Composite parent) {
boolean taskSaved = task != null && !CommonUtils.isEmpty(task.getId());
Composite composite = UIUtils.createComposite(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite formPanel = UIUtils.createControlGroup(composite, TaskUIMessages.task_config_wizard_page_task_label_task_type, task == null ? 1 : 2, GridData.FILL_BOTH, 0);
formPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite infoPanel = UIUtils.createComposite(formPanel, 2);
infoPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ModifyListener modifyListener = e -> updatePageCompletion();
taskLabelText = UIUtils.createLabelText(infoPanel, TaskUIMessages.task_config_wizard_page_task_text_label_name, task == null ? "" : CommonUtils.notEmpty(task.getName()), SWT.BORDER);
if (taskSaved) {
taskLabelText.setEditable(false);
// taskLabelText.setEnabled(false);
}
taskLabelText.addModifyListener(e -> {
taskName = taskLabelText.getText();
modifyListener.modifyText(e);
});
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_descr).setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
taskDescriptionText = new Text(infoPanel, SWT.BORDER | SWT.MULTI);
taskDescriptionText.setText(task == null ? "" : CommonUtils.notEmpty(task.getDescription()));
taskDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// ((GridData) taskDescriptionText.getLayoutData()).heightHint = taskDescriptionText.getLineHeight() * 6;
taskDescriptionText.addModifyListener(e -> {
taskDescription = taskDescriptionText.getText();
modifyListener.modifyText(e);
});
if (task != null && !CommonUtils.isEmpty(task.getId())) {
UIUtils.createLabelText(infoPanel, TaskUIMessages.task_config_wizard_page_task_text_label_task_id, task.getId(), SWT.BORDER | SWT.READ_ONLY);
}
UIUtils.asyncExec(() -> (taskSaved ? taskDescriptionText : taskLabelText).setFocus());
if (task != null) {
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_category);
Composite catPanel = UIUtils.createComposite(infoPanel, 2);
UIUtils.createLabel(catPanel, task.getType().getCategory().getIcon());
UIUtils.createLabel(catPanel, task.getType().getCategory().getName());
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_type);
Composite typePanel = UIUtils.createComposite(infoPanel, 2);
UIUtils.createLabel(typePanel, task.getType().getIcon());
UIUtils.createLabel(typePanel, task.getType().getName());
}
}
if (task == null) {
taskCategoryTree = new Tree(formPanel, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
gd.widthHint = 200;
taskCategoryTree.setLayoutData(gd);
taskCategoryTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = taskCategoryTree.getSelection();
if (selection.length == 1) {
Object itemData = selection[0].getData();
if (itemData instanceof DBTTaskType) {
if (selectedTaskType == itemData) {
return;
}
selectedTaskType = (DBTTaskType) itemData;
selectedCategory = selectedTaskType.getCategory();
} else {
if (selectedCategory == itemData && selectedTaskType == null) {
return;
}
selectedCategory = (DBTTaskCategory) itemData;
selectedTaskType = null;
}
updateTaskTypeSelection();
}
}
});
TreeColumn nameColumn = new TreeColumn(taskCategoryTree, SWT.LEFT);
nameColumn.setText("Task");
TreeColumn descColumn = new TreeColumn(taskCategoryTree, SWT.RIGHT);
descColumn.setText("Description");
addTaskCategories(null, TaskRegistry.getInstance().getRootCategories());
taskCategoryTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if (canFlipToNextPage()) {
getWizard().getContainer().buttonPressed(IDialogConstants.NEXT_ID);
}
}
});
UIUtils.asyncExec(() -> UIUtils.packColumns(taskCategoryTree, true, new float[] { 0.3f, 0.7f }));
taskCategoryTree.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(taskCategoryTree, true, new float[] { 0.3f, 0.7f });
taskCategoryTree.removeControlListener(this);
}
});
}
}
setPageComplete(determinePageCompletion());
setControl(composite);
}
use of org.jkiss.dbeaver.model.task.DBTTaskCategory in project dbeaver by serge-rider.
the class TaskConfigurationWizardPageTask method addTaskCategories.
private void addTaskCategories(TreeItem parentItem, DBTTaskCategory[] categories) {
List<DBTTaskCategory> allCats = Arrays.asList(categories);
allCats.sort(Comparator.comparing(DBTTaskCategory::getName));
for (DBTTaskCategory cat : categories) {
if (!isTaskCategoryApplicable(cat)) {
continue;
}
TreeItem item = parentItem == null ? new TreeItem(taskCategoryTree, SWT.NONE) : new TreeItem(parentItem, SWT.NONE);
item.setText(0, cat.getName());
item.setImage(0, DBeaverIcons.getImage(cat.getIcon() == null ? DBIcon.TREE_TASK : cat.getIcon()));
item.setText(1, CommonUtils.notEmpty(cat.getDescription()));
item.setData(cat);
addTaskCategories(item, cat.getChildren());
addTaskTypes(item, cat);
item.setExpanded(true);
}
}
use of org.jkiss.dbeaver.model.task.DBTTaskCategory in project dbeaver by dbeaver.
the class TaskConfigurationWizardPageTask method createControl.
@Override
public void createControl(Composite parent) {
boolean taskSaved = task != null && !CommonUtils.isEmpty(task.getId());
Composite composite = UIUtils.createComposite(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite formPanel = UIUtils.createControlGroup(composite, TaskUIMessages.task_config_wizard_page_task_label_task_type, task == null ? 1 : 2, GridData.FILL_BOTH, 0);
formPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite infoPanel = UIUtils.createComposite(formPanel, 2);
infoPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ModifyListener modifyListener = e -> updatePageCompletion();
taskLabelText = UIUtils.createLabelText(infoPanel, TaskUIMessages.task_config_wizard_page_task_text_label_name, task == null ? "" : CommonUtils.notEmpty(task.getName()), SWT.BORDER);
if (taskSaved) {
taskLabelText.setEditable(false);
// taskLabelText.setEnabled(false);
}
taskLabelText.addModifyListener(e -> {
taskName = taskLabelText.getText();
modifyListener.modifyText(e);
});
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_descr).setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
taskDescriptionText = new Text(infoPanel, SWT.BORDER | SWT.MULTI);
taskDescriptionText.setText(task == null ? "" : CommonUtils.notEmpty(task.getDescription()));
taskDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// ((GridData) taskDescriptionText.getLayoutData()).heightHint = taskDescriptionText.getLineHeight() * 6;
taskDescriptionText.addModifyListener(e -> {
taskDescription = taskDescriptionText.getText();
modifyListener.modifyText(e);
});
if (task != null && !CommonUtils.isEmpty(task.getId())) {
UIUtils.createLabelText(infoPanel, TaskUIMessages.task_config_wizard_page_task_text_label_task_id, task.getId(), SWT.BORDER | SWT.READ_ONLY);
}
UIUtils.asyncExec(() -> (taskSaved ? taskDescriptionText : taskLabelText).setFocus());
if (task != null) {
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_category);
Composite catPanel = UIUtils.createComposite(infoPanel, 2);
UIUtils.createLabel(catPanel, task.getType().getCategory().getIcon());
UIUtils.createLabel(catPanel, task.getType().getCategory().getName());
UIUtils.createControlLabel(infoPanel, TaskUIMessages.task_config_wizard_page_task_control_label_type);
Composite typePanel = UIUtils.createComposite(infoPanel, 2);
UIUtils.createLabel(typePanel, task.getType().getIcon());
UIUtils.createLabel(typePanel, task.getType().getName());
}
}
if (task == null) {
taskCategoryTree = new Tree(formPanel, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
gd.widthHint = 200;
taskCategoryTree.setLayoutData(gd);
taskCategoryTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = taskCategoryTree.getSelection();
if (selection.length == 1) {
Object itemData = selection[0].getData();
if (itemData instanceof DBTTaskType) {
if (selectedTaskType == itemData) {
return;
}
selectedTaskType = (DBTTaskType) itemData;
selectedCategory = selectedTaskType.getCategory();
} else {
if (selectedCategory == itemData && selectedTaskType == null) {
return;
}
selectedCategory = (DBTTaskCategory) itemData;
selectedTaskType = null;
}
updateTaskTypeSelection();
}
}
});
TreeColumn nameColumn = new TreeColumn(taskCategoryTree, SWT.LEFT);
nameColumn.setText("Task");
TreeColumn descColumn = new TreeColumn(taskCategoryTree, SWT.RIGHT);
descColumn.setText("Description");
addTaskCategories(null, TaskRegistry.getInstance().getRootCategories());
taskCategoryTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if (canFlipToNextPage()) {
getWizard().getContainer().buttonPressed(IDialogConstants.NEXT_ID);
}
}
});
UIUtils.asyncExec(() -> UIUtils.packColumns(taskCategoryTree, true, new float[] { 0.3f, 0.7f }));
taskCategoryTree.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(taskCategoryTree, true, new float[] { 0.3f, 0.7f });
taskCategoryTree.removeControlListener(this);
}
});
}
}
setPageComplete(determinePageCompletion());
setControl(composite);
}
Aggregations