Search in sources :

Example 1 with SchemaPresetSelector

use of eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetSelector in project hale by halestudio.

the class PresetsSource 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 SchemaPresetSelector(parent);
    selector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (description != null) {
                SchemaPreset schema = selector.getSelectedObject();
                if (schema != null && schema.getDescription() != null) {
                    description.setText(schema.getDescription());
                } else {
                    description.setText("");
                }
            }
            updateState(true);
        }
    });
    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);
    // preset label
    label = new Label(parent, SWT.NONE);
    label.setText("Import as");
    labelData.applyTo(label);
    // create provider combo
    ComboViewer providers = createProviders(parent);
    controlData.applyTo(providers.getControl());
    // prevent selector appearing very small
    parent.pack();
    // initial state update
    updateState(true);
}
Also used : GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Composite(org.eclipse.swt.widgets.Composite) SchemaPresetSelector(eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetSelector) SchemaPreset(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Aggregations

SchemaPreset (eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset)1 SchemaPresetSelector (eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetSelector)1 GridDataFactory (org.eclipse.jface.layout.GridDataFactory)1 GridLayoutFactory (org.eclipse.jface.layout.GridLayoutFactory)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)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