Search in sources :

Example 1 with BooleanEditor

use of eu.esdihumboldt.hale.ui.common.editors.BooleanEditor in project hale by halestudio.

the class EditorChooserEditor method editorSelected.

/**
 * Handles a selection change.
 *
 * @param newEditor the new selection
 */
@SuppressWarnings("unchecked")
private void editorSelected(Entry newEditor) {
    if (newEditor.scriptId.equals(currentScriptId))
        return;
    String currentValue = "";
    boolean oldValid = false;
    if (currentEditor != null) {
        currentValue = currentEditor.getAsText();
        oldValid = currentEditor.isValid();
        currentEditor.setPropertyChangeListener(null);
        currentEditor.getControl().dispose();
    }
    currentScriptId = newEditor.scriptId;
    if ("default".equals(currentScriptId)) {
        if (Boolean.class.equals(binding))
            currentEditor = (AttributeEditor<T>) new BooleanEditor(composite);
        else
            currentEditor = createDefaultEditor(composite);
    } else
        currentEditor = (AttributeEditor<T>) newEditor.scriptUI.createEditor(composite, binding);
    currentEditor.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    if (currentValue != null)
        currentEditor.setAsText(currentValue);
    currentEditor.setVariables(properties);
    currentEditor.setPropertyChangeListener(this);
    if (currentEditor.isValid() != oldValid)
        fireStateChanged(IS_VALID, oldValid, currentEditor.isValid());
    composite.getParent().layout(true, true);
}
Also used : BooleanEditor(eu.esdihumboldt.hale.ui.common.editors.BooleanEditor) AttributeEditor(eu.esdihumboldt.hale.ui.common.AttributeEditor) AbstractAttributeEditor(eu.esdihumboldt.hale.ui.common.editors.AbstractAttributeEditor)

Example 2 with BooleanEditor

use of eu.esdihumboldt.hale.ui.common.editors.BooleanEditor in project hale by halestudio.

the class DefaultAttributeEditorFactory method createEditor.

@Override
public AttributeEditor<?> createEditor(Composite parent, PropertyDefinition property, EntityDefinition entityDef, boolean allowScripts) {
    TypeDefinition type = property.getPropertyType();
    if (!type.getConstraint(HasValueFlag.class).isEnabled())
        return null;
    else {
        if (allowScripts) {
            EditorChooserEditor<Object> result = new PropertyEditorChooserEditor(parent, property, entityDef);
            result.selectDefaultEditor();
            return result;
        } else {
            Class<?> binding = type.getConstraint(Binding.class).getBinding();
            if (Boolean.class.equals(binding))
                return new BooleanEditor(parent);
            else
                return new DefaultPropertyEditor(parent, property, entityDef);
        }
    }
}
Also used : Binding(eu.esdihumboldt.hale.common.schema.model.constraint.type.Binding) BooleanEditor(eu.esdihumboldt.hale.ui.common.editors.BooleanEditor) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

BooleanEditor (eu.esdihumboldt.hale.ui.common.editors.BooleanEditor)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 Binding (eu.esdihumboldt.hale.common.schema.model.constraint.type.Binding)1 AttributeEditor (eu.esdihumboldt.hale.ui.common.AttributeEditor)1 AbstractAttributeEditor (eu.esdihumboldt.hale.ui.common.editors.AbstractAttributeEditor)1