Search in sources :

Example 1 with CodeListRef

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();
}
Also used : PatternFilter(org.eclipse.ui.dialogs.PatternFilter) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Viewer(org.eclipse.jface.viewers.Viewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) CodeListRef(eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)

Example 2 with CodeListRef

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);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) CodeListRef(eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)

Example 3 with CodeListRef

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();
}
Also used : GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Composite(org.eclipse.swt.widgets.Composite) CodeListSelector(eu.esdihumboldt.hale.ui.codelist.inspire.internal.CodeListSelector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) CodeListRef(eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)

Example 4 with CodeListRef

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);
            }
        }
    }
}
Also used : CodeListRef(eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)

Aggregations

CodeListRef (eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)4 CodeListSelector (eu.esdihumboldt.hale.ui.codelist.inspire.internal.CodeListSelector)1 GridDataFactory (org.eclipse.jface.layout.GridDataFactory)1 GridLayoutFactory (org.eclipse.jface.layout.GridLayoutFactory)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 StyledString (org.eclipse.jface.viewers.StyledString)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 FilteredTree (org.eclipse.ui.dialogs.FilteredTree)1 PatternFilter (org.eclipse.ui.dialogs.PatternFilter)1