use of org.talend.core.ui.composite.ElementsSelectionComposite in project tdi-studio-se by Talend.
the class NameAndLabelsTreeController method createControl.
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
Composite parentComp = new Composite(subComposite, SWT.NONE);
parentComp.setLayoutData(data);
parentComp.setLayout(new GridLayout());
ElementsSelectionComposite<NamedThing> selectionComposite = new ElementsSelectionComposite<NamedThing>(parentComp) {
@Override
protected IBaseLabelProvider getLabelProvider() {
return new LabelProvider() {
@Override
public String getText(Object obj) {
NamedThing nal = (NamedThing) obj;
return nal.getDisplayName();
}
@Override
public Image getImage(Object obj) {
return null;
}
};
}
;
@Override
protected void doSelectionChanged() {
param.setValue(getSelectedElements());
}
@Override
protected List<String> getSelectedElementLabels() {
List<String> labels = new ArrayList<>();
Object value = param.getValue();
if (value instanceof List) {
List<?> values = (List<?>) value;
for (Object valueObj : values) {
if (valueObj instanceof NamedThing) {
labels.add(((NamedThing) valueObj).getName());
}
}
return labels;
}
return null;
}
@Override
protected List<NamedThing> getInitSelectedElements(List<String> selectedElementLabels) {
List<NamedThing> selectedElements = new ArrayList<>();
List<NamedThing> viewerDatas = getViewerData();
for (NamedThing viewerData : viewerDatas) {
if (selectedElementLabels.contains(viewerData.getName())) {
selectedElements.add(viewerData);
}
}
return selectedElements;
}
}.setShowToolbar(true).create();
selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
if (param instanceof GenericElementParameter) {
selectionComposite.setViewerData(ComponentsUtils.getFormalPossibleValues((GenericElementParameter) param));
}
selectionComposite.setCheckedState();
return parentComp;
}
use of org.talend.core.ui.composite.ElementsSelectionComposite in project tdi-studio-se by Talend.
the class NameAndLabelsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite comp = new Composite(composite, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
comp.setLayout(new GridLayout());
selectionComposite = new ElementsSelectionComposite<NamedThing>(comp) {
@Override
protected IBaseLabelProvider getLabelProvider() {
return new LabelProvider() {
@Override
public String getText(Object obj) {
NamedThing nal = (NamedThing) obj;
return nal.getDisplayName();
}
@Override
public Image getImage(Object obj) {
return null;
}
};
}
;
}.setMultipleSelection(false).create();
selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
selectionComposite.setViewerData(nameAndLabels);
Composite customComposite = new Composite(comp, SWT.NONE);
customComposite.setLayout(new GridLayout());
customComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button useCustomBtn = new Button(customComposite, SWT.CHECK);
//$NON-NLS-1$
useCustomBtn.setText(Messages.getString("NameAndLabelsDialog.custom.button"));
useCustomBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateFieldsStatus(useCustomBtn.getSelection());
}
});
//$NON-NLS-1$
customObjNameText = new LabelledText(customComposite, Messages.getString("NameAndLabelsDialog.custom.text"));
updateFieldsStatus(useCustomBtn.getSelection());
if (!isInWizard) {
// set empty quotes to show the user he should fill the name between quotes
//$NON-NLS-1$
customObjNameText.setText("\"\"");
}
return composite;
}
Aggregations