Get event generation source from ExecutionEvent object [message #1014920] |
Tue, 26 February 2013 19:29 |
rrahul s Messages: 2 Registered: June 2011 |
Junior Member |
|
|
Hello All,
Is there any way to figure out, which view or UI part is the source of the generated ExecutionEvent Event for a Command Handler?
I was writing down the code for an RCP application using typical Command-Handler framework. I've created my own views and have certain commands available in the toolbar. The View is such that you can open multiple instances of the view at the same time.
Several commands execute various actions over the active page over active view, hence using the PlatformUI, I call my method from the view.
This is how the Handler's code look like-
***********************************************
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
if(part instanceof MyView){
MyView view = (MyView)part;
view.callingMyMethods();
}
return null;
}
***********************************************
This code is working fine in case of single threaded application. But few of these toolbar items serve different operations which start execution of seperate threads which display their output in some other view.
In such scenerio, it becomes impossible to use the 'PlatformUI' and get the active part of workbench to execute 'myView.callingMyMethods()', because in that scenerio, as another thread is processing and displaying data over another view, 'myView' wll be no longer the active view. Even after pressing the command button over the toolbar, this Handler is executed, but because of an another parallel thread in execution, focus again jumps to another view where the thread is buzy in displaying the output.
Request all to suggest any alternates possible, so that 'myView.callingMyMethods()' can be executed in for the view from which the command call is generated.
Is there any way to figure out, which view or UI part is the source of the generated Event.
Thanks in advance.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03026 seconds