HandlerUtil.getCurrentSelection(event) is null in detached View [message #663804] |
Wed, 06 April 2011 14:34 |
Lorand Lorincz Messages: 35 Registered: April 2011 |
Member |
|
|
Hello,
I'm quite new to RCP Developement, and I'm currently doing Bug Fixing and CR on a RCP Project.
I searched the forum and the internet but couldn't find any similar problem.
The Problem:
I have a Tree view with copy paste capabilities. selecting a TreeItem and pressing Ctrl+C and Ctrl+V copies and pastes the item. This functionality works when my tree window is docked but when i detatch it, it fails.
public class TreeCopyHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
}
}
The problem is that HandlerUtil.getCurrentSelection(event) returns null, when the window is detached. Doing the following solves my problem, but I was wondering if this is a bug or if I'm missing something.
public class TreeCopyHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if(selection == null && (part instanceof ICustomTreeView)){
ICustomTreeView treeView = (ICustomTreeView)part;
selection = treeView.getViewer().getSelection();
}
Thanks in advance.
Lori
[Updated on: Thu, 07 April 2011 14:37] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02971 seconds