Search in sources :

Example 1 with CodeListSelector

use of eu.esdihumboldt.hale.ui.codelist.inspire.internal.CodeListSelector 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)

Aggregations

CodeListRef (eu.esdihumboldt.hale.common.inspire.codelists.CodeListRef)1 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 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1