[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: Refresh View after wizard finishes.
|
That sounds like an interesting technique. Can you please tell me what interface should my class inplement in order to become a model listener?
I think that's the normal MVC way since the model should not know the
GUI components directly and therefore the only way I know is to
implement a listener-observer pattern.
Just define your own model specific interface - could also be generic
for every model I think. And the implement it in your ContentProvider
(or even better if you have a TreeView in the changed node) and register
it than as listener to your model.
The model then has to implement addXXX and removeXXX listener methods
and just fire change events when something happens.
Here is some very simple example code:
public interface IModelListener {
/**
* @param event
*/
abstract void modelChanged(ModelEvent event);
}
public class ModelEvent extends EventObject {
// add whatever you want to send with the event here
}
...SomeContentProvider implements IModelListener {
public void modelChanged(ModelEvent event) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
if (getViewer() instanceof TreeViewer) {
((TreeViewer)
getViewer()).refresh(CustomerCategory.this);
} else {
getViewer().refresh();
}
}
});
}
}
Hope that helps to clear up my thoughts. :D
--
>
> emedia-solutions wolf
> Wedeler Landstrasse 63
> 22559 Hamburg
>
>> phone: (+49) 40 550 083 70
>> web: http://www.emedia-solutions-wolf.de
>> mail: markus@xxxxxxxxxxxxxxxxxxxxxxxx
>> pgp: http://wwwkeys.de.pgp.net
>