use of eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef in project hale by halestudio.
the class CodeListSelectionDialog method createViewer.
/**
* @see AbstractViewerSelectionDialog#createViewer(Composite)
*/
@Override
protected TreeViewer createViewer(Composite parent) {
PatternFilter patternFilter = new PatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
tree.getViewer().setComparator(new CodeListComparator());
// set filter to only accept code list selection (must be set after
// pattern filter is created)
setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof CodeListRef;
}
} });
return tree.getViewer();
}
use of eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef in project hale by halestudio.
the class CodeListLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
StyledString text;
if (element instanceof CodeListRef) {
CodeListRef cl = (CodeListRef) element;
text = new StyledString(cl.getName());
String schema = cl.getSchemaName();
if (schema != null) {
text.append(" (" + schema + ")", StyledString.COUNTER_STYLER);
}
//
// String tag = cl.getTag();
// if (tag != null) {
// text.append(" (" + tag + ")", StyledString.DECORATIONS_STYLER);
// }
} else {
text = new StyledString(getText(element));
}
cell.setImage(getImage(element));
cell.setText(text.toString());
cell.setStyleRanges(text.getStyleRanges());
super.update(cell);
}
use of eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef in project hale by halestudio.
the class RegistrySource method createControls.
/**
* @see ImportSource#createControls(Composite)
*/
@Override
public void createControls(Composite parent) {
GridLayoutFactory parentLayout = GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false);
parentLayout.applyTo(parent);
GridDataFactory labelData = //
GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER);
GridDataFactory controlData = //
GridDataFactory.swtDefaults().align(SWT.FILL, //
SWT.CENTER).grab(true, false);
// preset label
Label label = new Label(parent, SWT.NONE);
label.setText("Select preset:");
labelData.applyTo(label);
// preset selector
selector = new CodeListSelector(parent);
selector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (description != null) {
CodeListRef schema = selector.getSelectedObject();
if (schema != null && schema.getDescription() != null) {
description.setText(schema.getDescription());
} else {
description.setText("");
}
}
updateState();
}
});
controlData.applyTo(selector.getControl());
// skipper
Composite empty = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().hint(1, 1).applyTo(empty);
// description label
description = new Label(parent, SWT.WRAP);
GridDataFactory.fillDefaults().grab(true, true).applyTo(description);
// prevent selector appearing very small
parent.pack();
// initial configuration (fixed values)
getConfiguration().setContentType(HalePlatform.getContentTypeManager().getContentType(INSPIRECodeListConstants.CONTENT_TYPE_ID));
getConfiguration().setProviderFactory(IOProviderExtension.getInstance().getFactory(INSPIRECodeListConstants.PROVIDER_ID));
// initial state update
updateState();
}
use of eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef in project hale by halestudio.
the class CodeListContentProvider method inputChanged.
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// populate map
categorized.clear();
if (newInput instanceof Iterable<?>) {
for (Object item : (Iterable<?>) newInput) {
if (item instanceof CodeListRef) {
CodeListRef ref = (CodeListRef) item;
categorized.put(getCategory(ref), ref);
}
}
}
}
Aggregations