EmbeddedFactory customization [message #1272980] |
Wed, 19 March 2014 04:16  |
Eclipse User |
|
|
|
Question is about EmbeddedEditor and EmbeddedFactory customization.
I want to customize EmbeddedEditor for my own purposes (for example, I want to hold languageName in it). All I can do now is to create my own implementation of EmbeddedEditorFactory.Builder, and then copy whole 'withParent(...)' method (141 lines) just to rewrite 'new EmbeddedEditor(...)' to 'new MyEmbeddedEditor(...)'.
Maybe the better way to do it in base implementation is to create it in separate method? Like this:
public EmbeddedEditor withParent(final Composite parent) {
/* ... */
final EmbeddedEditor result = createEmbeddedEditor(...);
/* ... */
}
protected EmbeddedEditor createEmbeddedEditor(...) {
return new EmbeddedEditor(...);
}
So, that way, developers can make their own extension of EmbeddedEditor, and then overwrite 'createEmbeddedEditor(...)' method without copypasting half of class.
What do you think?
[Updated on: Thu, 20 March 2014 02:46] by Moderator
|
|
|
Re: EmbeddedFactory customization [message #1276159 is a reply to message #1272980] |
Mon, 24 March 2014 03:05  |
Eclipse User |
|
|
|
Yes, the embedded editor API needs to be overhauled and designed for
better extendability.
Could you file a feature enhancement in bugzilla?
Am 19/03/14 09:16, schrieb Peter N:
> Question is about EmbeddedEditor and EmbeddedFactory customization.
>
> I want to customize EmbeddedEditor for my own purposes (for example, i
> want to hold languageName in it). All i can do now is to create my own
> implementation of EmbeddedEditorFactory.Builder, and then copy whole
> 'withParent(...)' method (141 lines) just to rewrite 'new
> EmbeddedEditor(...)' to 'new MyEmbeddedEditor(...)'.
>
> Maybe the better way to do it in base implementation is to create it in
> separate method? Like this:
>
> public EmbeddedEditor withParent(final Composite parent) {
> /* ... */
> final EmbeddedEditor result = createEmbeddedEditor(...);
> /* ... */
> }
>
> protected EmbeddedEditor createEmbeddedEditor(...) {
> return new EmbeddedEditor(...);
> }
>
>
> So, that way, developers can make their own extension of EmbeddedEditor
> without copypasting half of class.
>
> What do you think?
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
|
|
|
Powered by
FUDForum. Page generated in 0.11907 seconds