Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » Get event generation source from ExecutionEvent object(Issues in getting the source of generating the Selection event for the Command Handler in multi-threaded environment)
icon5.gif  Get event generation source from ExecutionEvent object [message #1014920] Tue, 26 February 2013 19:29 Go to next message
rrahul s is currently offline rrahul sFriend
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.
Re: Get event generation source from ExecutionEvent object [message #1434627 is a reply to message #1014920] Tue, 30 September 2014 11:00 Go to previous messageGo to next message
Suraj Khurana is currently offline Suraj KhuranaFriend
Messages: 1
Registered: September 2014
Junior Member
Hi,

Use HandlerUtil.getActivePart(eventObj);

Regards,
-Suraj
Re: Get event generation source from ExecutionEvent object [message #1437143 is a reply to message #1434627] Fri, 03 October 2014 23:55 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 612
Registered: July 2009
Senior Member
This is off-topic on this forum
Previous Topic:Access GIT Repository hosted on a Windows 2008 Server in a cloud
Next Topic:Help with git/Egit (noob here), can't push project
Goto Forum:
  


Current Time: Sun Dec 21 14:41:10 GMT 2014

Powered by FUDForum. Page generated in 0.02067 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software