Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Get active workbench part in Command IHandler
Get active workbench part in Command IHandler [message #318875] Wed, 08 August 2007 08:54 Go to next message
Eclipse UserFriend
Hello,

I wanna get access to the currently active workbench part when my
command handler is called. I can see that somewhere in
ExecutionEvent.applicationContext it is hidden in a HashMap. But how do
I access this value in a API conform way? Is there any documentation
about the Workbench's applicationContext available?

Thanks in advance,
Phil
Re: Get active workbench part in Command IHandler [message #318950 is a reply to message #318875] Thu, 09 August 2007 09:08 Go to previous message
Eclipse UserFriend
Philipp Kursawe wrote:
> Hello,
>
> I wanna get access to the currently active workbench part when my
> command handler is called. I can see that somewhere in
> ExecutionEvent.applicationContext it is hidden in a HashMap. But how do
> I access this value in a API conform way? Is there any documentation
> about the Workbench's applicationContext available?

In 3.3 you can use HandlerUtil to extract information from the execution
event, the methods are named and typed, and there is usually a form that
throws an exception and a form that just returns null.

In 3.2 most of the same information is there, but you need to extract it
manually. With some checks:
IWorkbenchPart activePart = null;
if (event.getApplicationContext() instanceof IEvaluationContext) {
IEvaluationContext app = (IEvaluationContext) event
.getApplicationContext();
Object obj = app.getVariable(ISources.ACTIVE_PART_NAME);
if (obj instanceof IWorkbenchPart) {
activePart = (IWorkbenchPart) obj;
}
}

http://wiki.eclipse.org/Command_Core_Expressions has an explanation of
the variables available through ISources.

Later,
PW




--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
Previous Topic:Problems view: How to group items programmatically?
Next Topic:What kind of schedulingrule to use?
Goto Forum:
  


Current Time: Wed Jul 16 15:49:58 EDT 2025

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

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

Back to the top