Best Practices - associate UI to EObject creation [message #1196587] |
Tue, 19 November 2013 13:42 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
Hi,
I need to associate a custom piece of UI (usually a custom dialog) to several model items (I have a complex model where most of my EObjects derive from a single EObject class (Identifiable), either directly or through a more complex dependency chain).
This should be used at EObject creation to initialize it.
My current solution is to add a couple of custom methods to the base class:
- public Pane getPane() {} returning the actual graphic object (JavaFX).
- public void setFields() {} applying the values from UI to EObject.
I then override these two methods in derived classes needing more complex UI for initialization.
This works.
Problem (an aesthetic one, if you wish) is I am mixing badly Model with UI.
Side problem is I am unable to model the above as Operation since it seems unable to return an arbitrary Object (Pane).
I would not like to keep a separate UI tree mimicking the Model because it's too easy to get out of sync.
Also an "adapter(EObject o)" method filed with "if (o instanceof Xxxx) ..." seems much less readable than current solution.
What is the "Right Way" to implement this?
Note: I am using just the Standalone Model, no edit, no editor; I use plain databinding to connect to my UI, even after EObject creation.
|
|
|
Powered by
FUDForum. Page generated in 0.03906 seconds