Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer....
HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896201] Tue, 17 July 2012 14:40 Go to next message
Michael Dougherty is currently offline Michael DoughertyFriend
Messages: 8
Registered: July 2012
Junior Member
Can anybody maybe help me out?

I am using the rcpmail template but changing it for my own purposes. This refers to the navigation view on the side.

I have added a listviewer, as the objects I am working with are my own created classes. Upon double clicking on an item in the list the regular View refreshes with information about the object.

Anyways, so I'm trying to implement a command that deletes an object from the list. You click on an object, right-click it to bring up the popup-menu, and then you can delete it. It is deleted and the view is refreshed.

Now normally this works fine, albeit not exactly how I wanted it (I would have loved if I could have had it work like the navigation view in Eclipse where if you hover over an object it is highlighted, and from there you can right-click it to bring up the menu for that object...I have to click to highlight and then right click...)

The problem comes if I double click on an object. If I double click, and then I select another object in the list, the delete function always deletes the previous object that I had double clicked, and never the object that is currently being selected, despite I am getting the object from HandlerUtil.getCurrentSelection(event).

A System.out.println statement in the NavigationView class tells me that the listviewer.getSelection() is returning the correct Object....so why is HandlerUtil.getCurrentSelection thinking that the item double clicked is currently selected when it isnt? And why does it have no trouble if I dont double click?

Can anybody help me solve this, and as an added bonus, maybe mention how to get the list viewer to highlight when you hover over items, and to allow you to right-click items without single clicking them first?

I kind of suck at this so keep explanations simple...haha....thanks a lot
Re: HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896204 is a reply to message #896201] Tue, 17 July 2012 14:49 Go to previous messageGo to next message
becks m is currently offline becks mFriend
Messages: 59
Registered: June 2012
Member
For the first issue, Try getting the current selection from listViewer.getSelection()

Do you want to right click to show pop up menu or what ?
Re: HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896206 is a reply to message #896204] Tue, 17 July 2012 14:56 Go to previous messageGo to next message
Michael Dougherty is currently offline Michael DoughertyFriend
Messages: 8
Registered: July 2012
Junior Member
Well I guess I could do that Id just have to make everything in the view static, I hope that is alright

Yeah basically I would like to be able to right click on an item, rather than having to select it and THEN right click it.
Re: HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896210 is a reply to message #896206] Tue, 17 July 2012 15:08 Go to previous messageGo to next message
becks m is currently offline becks mFriend
Messages: 59
Registered: June 2012
Member
You can add pop up menu from plugin.xml and add handler to it.

From Extensions add "org.eclipse.ui.menus" then add new "menuContribution" with locationURi:popup:YOURViewId

Then right click on menuContribution - > add menu and add a command handler for it
Re: HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896211 is a reply to message #896210] Tue, 17 July 2012 15:10 Go to previous messageGo to next message
Michael Dougherty is currently offline Michael DoughertyFriend
Messages: 8
Registered: July 2012
Junior Member
Thats what I've done, but that put a popup on the whole view, where I want the popup to be specifically for objects on the list. To do that I said visible when count is one....but now I have to click an item and THEN right-click it.
Re: HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer.... [message #896259 is a reply to message #896211] Tue, 17 July 2012 18:52 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Did you make your listViewer your view selection provider? Did you use the listViewer when you registered a MenuManager as a context menu?

PW


Previous Topic:Call to a command defined in another plugin
Next Topic:execute many times Progress bar show error
Goto Forum:
  


Current Time: Fri Apr 26 17:45:45 GMT 2024

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

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

Back to the top