Accessing/updating UI elements in other Parts + best practices? [message #1070249] |
Wed, 17 July 2013 10:43  |
Eclipse User |
|
|
|
Fairly simple question here: I have an application where one Part is a TableViewer and another Part which contains form fields (spinners, combo boxes, text fields, etc.). The form Part updates based on the current selection in the TableViewer Part, implemented using @Optional @Named(IServiceConstants.ACTIVE_SELECTION).
What I want is for an Update button in the form Part to reflect the changes in my TableViewer, but I am not quite sure of how to manipulate the TableViewer part via the form Part.
What is the E4 best practice to accomplish manipulation of other parts? I have looked around quite a bit already but I am running into a lot of E3 stuff that doesn't really help me. Also, if anyone has any pointers/tutorials on how to maintain/separate my TableViewers data separate from the actual Part code, that would be appreciated.
Thanks!
[Updated on: Wed, 17 July 2013 11:35] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: Accessing/updating UI elements in other Parts + best practices? [message #1074122 is a reply to message #1073928] |
Fri, 26 July 2013 02:50   |
Eclipse User |
|
|
|
Quote:Ok so I have got that working, but it doesn't solve that I have two Parts that so far, are unable to communicate.
You have to think at it differently: you should avoid having two parts "communicating" together, this is in general not a so good practice. However, the views are displaying some data (which should be always accessible, so not stored in your views). Databinding will take care of updating your views when the model changes.
So, in this case you don't need to communicate between views anymore.
In your particular example, are you sure that the list of objects has to be stored within your view ? It means that the lifetime of those objects is the same as the lifetime of the view, e.g. if you close the view, you don't have your objects anymore. Is that what you really want ? If you reopen your view, your list will be recreated (so the user has lost all its changes).
Anyway, your code should technically work (if databinding is implemented properly), since your second view receive the selected object and modifies it (unless you are making a copy of it). So, it this element is modified, databinding in the first view should be notified when this object changes and update the table viewer accordingly.
|
|
|
Re: Accessing/updating UI elements in other Parts + best practices? [message #1074332 is a reply to message #1074122] |
Fri, 26 July 2013 10:17  |
Eclipse User |
|
|
|
I am not sure where else I could instantiate my model, since I am using the eclipse application model, there is no place for it to live really unless I am mistaken? This is a fairly simple app (3-5 Parts total) so they are not closeable. I was also going to implement the Dirtyable features to allow for saving anyways.
It does work, ONLY if the changes to the object are made within
void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) MyOwnObject object) {
// Populate text boxes based on selection
}
If I make a shallow copy to be used in public void widgetSelected(SelectionEvent e) and do the changes in there, it does update in the tableviewer, but then when you select another row or alter the UI, the change disappears.
|
|
|
Powered by
FUDForum. Page generated in 0.18696 seconds