Search in sources :

Example 1 with PropertyField

use of eu.esdihumboldt.hale.ui.function.generic.pages.internal.PropertyField in project hale by halestudio.

the class PropertyEntitiesPage method createHeader.

/**
 * @see EntitiesPage#createHeader(Composite)
 */
@Override
protected Control createHeader(Composite parent) {
    Group typeSelectionGroup = new Group(parent, SWT.NONE);
    typeSelectionGroup.setText("Type");
    typeSelectionGroup.setLayout(new GridLayout());
    sourceTargetSelector = new SourceTargetTypeSelector(typeSelectionGroup);
    sourceTargetSelector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    // set initial selection
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.SOURCE), SchemaSpaceID.SOURCE);
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.TARGET), SchemaSpaceID.TARGET);
    // add selection listener
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.SOURCE);
            for (PropertyField field : getFunctionFields()) {
                if (field.getSchemaSpace() == SchemaSpaceID.SOURCE) {
                    field.setParentType(selectedType);
                }
            }
        }
    }, SchemaSpaceID.SOURCE);
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.TARGET);
            for (PropertyField field : getFunctionFields()) if (field.getSchemaSpace() == SchemaSpaceID.TARGET)
                field.setParentType(selectedType);
        }
    }, SchemaSpaceID.TARGET);
    return typeSelectionGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyField(eu.esdihumboldt.hale.ui.function.generic.pages.internal.PropertyField) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SourceTargetTypeSelector(eu.esdihumboldt.hale.ui.function.common.SourceTargetTypeSelector)

Aggregations

TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 SourceTargetTypeSelector (eu.esdihumboldt.hale.ui.function.common.SourceTargetTypeSelector)1 PropertyField (eu.esdihumboldt.hale.ui.function.generic.pages.internal.PropertyField)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Group (org.eclipse.swt.widgets.Group)1