Is there a way to customize the input element for a Faktor-IPS extension property?

42 Views Asked by At

I've sucessfully created a plugin-project defining an extension property for a PolicyCmptType. This extension property is enum-based, so I would like to get a ComboBox as control for it, at the moment a simple Text control is created. Is there an easy way to do so?

1

There are 1 best solutions below

0
On BEST ANSWER

Faktor-IPS allows you to create your own UI-contributions via the Eclipse mechanism of Extension Points. You already used one to create your extension property. For a custom edit field you can use the extension point 'org.faktorips.devtools.core.ui.extensionPropertyEditFieldFactory', implement IExtensionPropertyEditFieldFactory and set your extension property's id as the 'propertyId'.

To create an EditField, you first create the Combo with the UIToolkit and then configure the data binding with a ComboViewerField:

 @Override
public EditField<?> newEditField(IIpsObjectPartContainer ipsObjectPart,
        Composite extensionArea,
        UIToolkit toolkit) {
    Combo combo = toolkit.createCombo(extensionArea);
    ComboViewerField<VariationOperand> comboViewerField = new ComboViewerField<VariationOperand>(combo,
            VariationOperand.class);
    comboViewerField.setLabelProvider(new DefaultLabelProvider());
    comboViewerField.setInput(VariationOperand.values());
    return comboViewerField;
}

You can also create your own LabelProvider to customize how the values are displayed.