Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » HandlerUtil.currentSelection returns null
HandlerUtil.currentSelection returns null [message #542337] Thu, 24 June 2010 14:49 Go to next message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
Hello

I'm quite new to RPC dev, and also to this forum. (So I hope "Come here to participate in technical discussions about how to use the Rich Client Platform (RCP)." covers my question as well, if not, please tell me where to post it)

I have the following problem:
1. I have a view with a treeviewer.
2. a command, which adds a new element to the tree
so far, it works.
In the handler, I call
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
to get the current selection so if a node is selected, that one will be the default parent. But! This returns null, even if I already selected a node.
After debugging it turned out that the selection variable is set to a plain "Object" object in the runtime framework, and at this point, in HandlerUtil.getVariable()
return var == IEvaluationContext.UNDEFINED_VARIABLE ? null : var;
null is returned.
I think, this might be the source of the problem, but I don't know why this happens...
My command handler is registered through the plugin.xml for my plugin.
please help me. If more details are required I can post them
thanks
david
Re: HandlerUtil.currentSelection returns null [message #542351 is a reply to message #542337] Thu, 24 June 2010 15:13 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What code did you use in your createPartControl(*) to hook up your
viewer to the system?

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
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: HandlerUtil.currentSelection returns null [message #542357 is a reply to message #542351] Thu, 24 June 2010 15:26 Go to previous messageGo to next message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
This:
fileTree = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
fileTree.setContentProvider(new FileBrowserContentProvider());
fileTree.setLabelProvider(new FileBrowserLabelProvider());
BrowserTreeNode root = initTree();
fileTree.setInput(root);

david
Re: HandlerUtil.currentSelection returns null [message #542430 is a reply to message #542357] Thu, 24 June 2010 19:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

That won't do anything for the workbench window selection. See
http://www.eclipse.org/articles/Article-WorkbenchSelections/ article.html

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
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: HandlerUtil.currentSelection returns null [message #542523 is a reply to message #542430] Fri, 25 June 2010 08:08 Go to previous message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
Thanks! That helped.
david
Previous Topic:RCP headless build, launcher name
Next Topic:Wrapping text in the table
Goto Forum:
  


Current Time: Wed Dec 01 10:26:47 GMT 2021

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

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

Back to the top