use of eu.esdihumboldt.hale.ui.common.definition.viewer.PropertyPathContentProvider in project hale by halestudio.
the class MergeParameterPage method createContent.
@Override
protected void createContent(Composite page) {
// set layout of page
page.setLayout(new GridLayout());
Label name = new Label(page, SWT.NONE);
name.setText(parameter.getDisplayName());
// create checkbox tree viewer
viewer = new CheckboxTreeViewer(page, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
// comparator
viewer.setComparator(new DefinitionComparator());
// label provider
viewer.setLabelProvider(labelProvider);
// content provider
viewer.setContentProvider(new PropertyPathContentProvider(SchemaSpaceID.SOURCE));
// check state listener
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
// add/remove it from/to set of selected properties
EntityDefinition eventSource = (EntityDefinition) event.getElement();
if (event.getChecked())
selection.add(eventSource);
else
selection.remove(eventSource);
}
});
// for now filter everything after first level
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return parentElement == sourceType;
}
});
if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY))
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return !filtered.contains(element);
}
});
Cell unfinishedCell = getWizard().getUnfinishedCell();
if (unfinishedCell.getSource() != null) {
sourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
}
viewer.setInput(sourceType);
// add initial selection
if (sourceType != null && initialSelection != null) {
for (String propertyPath : initialSelection) {
EntityDefinition entity = getEntityDefinition(propertyPath, sourceType);
if (entity != null) {
selection.add(entity);
} else {
log.warn("Could not find child for property path " + propertyPath);
}
}
viewer.setCheckedElements(selection.toArray());
}
}
Aggregations