When using a CompositeEditor, the Editor Framework resolves the composed editor based on the parameterized type CompositeEditor<T, C, E<C>>. So the type of the composed editor is bound to E<C>. Since the composed editor can be created freely by the developer (in the setValue method of the composite editor), it would be useful to support multiple editor types. As an example take an editor for a container type which contains a polymorphic list.
1. Idea
A possible idea is to let the editor framework resolve an editor (delegate) during runtime, based on the given concrete editor. The editor framework needs to know which editor types it needs to support. So an annotation on the CompositeEditor contains a list of them:
@PossibleEditors({ BooleanField.class, StringField.class })
The code generator can now use this information to generate code like the following:
@Override protected org.noorg.gwt.rf.client.editor.impl.SimpleBeanEditorDelegate createComposedDelegate(Editor e) {
if (e.getClass() instanceof BooleanField)
return new org.noorg.gwt.rf.client.ui.BooleanField_SimpleBeanEditorDelegate();
if (e.getClass() instanceof StringField)
return new org.noorg.gwt.rf.client.ui.StringField_SimpleBeanEditorDelegate();
return null;
}
- Use annotation during generation of EditorData
- Modify code generation in EditorDriverGenerator
What do you guys think? Is this feasable?
Regards,
Stefan