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);
}
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);
}
}
}
Aggregations