add multiple items to ModelElementList property [message #710256] |
Thu, 04 August 2011 17:16  |
Eclipse User |
|
|
|
one of the property of my model is a ModelElementList,
public ModelElementList<ICreationTemplate> getTemplates()
The property is presented as a list which user click and select.
When user selects one item in UI, I would add dependent items in the SAME
list to the model. What is best way to do this?
I tried a ModelPropertyListener, but seem not working properly:
public class TemplatesValueChangeListener extends ModelPropertyListener {
public void handlePropertyChangedEvent(ModelPropertyChangeEvent event) {
...
//find dependent items and try add to list.
ICreationTemplate c = model.getTemplates().addNewElement();
c.setName( allTemplates.get(name).name );
...
This causes a new item added to UI briefly at the end then removed by Sapphire.
That must be a better way...
|
|
|
|
Re: add multiple items to ModelElementList property [message #710387 is a reply to message #710266] |
Thu, 04 August 2011 20:46  |
Eclipse User |
|
|
|
It turns out adding the listener to the ModelElementList property is definitely
not the right way to handle the use case like this:
the listener is triggered by
ModelElementList.addNewElement(),
when user click the checkbox in UI (or by client call), adding an empty node to list,
with the name property, which I needed to find its dependencies, is not yet set.
What I did was to register the listener to the element (ICreationTemplate) itself,
to get notified when the name is set, and update the list (the parent of the element).
This approach works for me since user can only add/remove item from the list, not change the name property of the element. The listener will be triggered only when they adds.
|
|
|
Powered by
FUDForum. Page generated in 0.26165 seconds