Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » HandlerUtil.currentSelection returns null
HandlerUtil.currentSelection returns null [message #542337] Thu, 24 June 2010 10:49 Go to next message
Eclipse UserFriend
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 11:13 Go to previous messageGo to next message
Eclipse UserFriend
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 11:26 Go to previous messageGo to next message
Eclipse UserFriend
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 15:16 Go to previous messageGo to next message
Eclipse UserFriend
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 04:08 Go to previous message
Eclipse UserFriend
Thanks! That helped.
david
Previous Topic:RCP headless build, launcher name
Next Topic:Wrapping text in the table
Goto Forum:
  


Current Time: Fri Jul 25 15:46:38 EDT 2025

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

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

Back to the top