Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » HandlerUtil.getCurrentSelection(event) is null in detached View
HandlerUtil.getCurrentSelection(event) is null in detached View [message #663804] Wed, 06 April 2011 10:34 Go to next message
Lorand Lorincz is currently offline 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 10:37]

Report message to a moderator

Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #663899 is a reply to message #663804] Wed, 06 April 2011 14:26 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What version of eclipse is your RCP app based on?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #663985 is a reply to message #663899] Thu, 07 April 2011 01:24 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
On 06/04/11 11:56 PM, Paul Webster wrote:
> What version of eclipse is your RCP app based on?

Also are you on Linux?

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #663995 is a reply to message #663804] Thu, 07 April 2011 02:41 Go to previous messageGo to next message
Lorand Lorincz is currently offline Lorand Lorincz
Messages: 35
Registered: April 2011
Member
Sorry guys, forgot those details.
OS: Win7 using Eclipse 3.3 with java 5
Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664086 is a reply to message #663995] Thu, 07 April 2011 08:50 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/07/2011 02:41 AM, Loris wrote:
> Sorry guys, forgot those details.

Eclipse 3.3? 3.6.2 is out, and we're working on 3.7/4.1.

The source provider (that fills out the details retrieved by
HandlerUtil) was fixed in 3.4 or 3.5 to handle detached windows better.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664088 is a reply to message #663804] Thu, 07 April 2011 08:57 Go to previous messageGo to next message
Lorand Lorincz is currently offline Lorand Lorincz
Messages: 35
Registered: April 2011
Member
Unfortunatelly I can't use a newer version of Eclipse, it's my clients request to work with Eclipse 3.3.

Should I file a bug in Bugzilla? Maybe it will be usefull for other users to know abaout this limitation in 3.3.

I guess I will use my workaround to get the selection, that if you don't have any other sugestions or a better solution.

Thanks,

Lori
Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664099 is a reply to message #664088] Thu, 07 April 2011 09:18 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/07/2011 08:57 AM, Loris wrote:
> Should I file a bug in Bugzilla? Maybe it will be usefull for other
> users to know abaout this limitation in 3.3.

There is a bug filed, and marked fixed with a target milestone.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212292

>
> I guess I will use my workaround to get the selection, that if you don't
> have any other sugestions or a better solution.

you'll have to go with your solution for now.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664104 is a reply to message #664099] Thu, 07 April 2011 09:44 Go to previous messageGo to next message
Lorand Lorincz is currently offline Lorand Lorincz
Messages: 35
Registered: April 2011
Member
Paul Webster wrote on Thu, 07 April 2011 09:18


There is a bug filed, and marked fixed with a target milestone.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212292



Don't know how I missed that.
Just one more question and I'm done. Is it posible to deactivate the detach option for some view, or maybe all view in an RCP app?

Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664254 is a reply to message #664104] Fri, 08 April 2011 01:53 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
On 07/04/11 7:14 PM, Loris wrote:
> Don't know how I missed that. Just one more question and I'm done. Is it
> posible to deactivate the detach option for some view, or maybe all view
> in an RCP app?

Yes. See the constant ENABLE_DETACHED_VIEWS in
IWorkbenchPreferenceConstants.

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: HandlerUtil.getCurrentSelection(event) is null in detached View [message #664277 is a reply to message #663804] Fri, 08 April 2011 04:46 Go to previous message
Lorand Lorincz is currently offline Lorand Lorincz
Messages: 35
Registered: April 2011
Member
Thank you all for your help.

Lori
Previous Topic:How to find out activated part upon null selection
Next Topic:ipreferencestore help
Goto Forum:
  


Current Time: Sat Aug 30 02:27:24 EDT 2014

Powered by FUDForum. Page generated in 0.01831 seconds