Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to get the 'Delete' event in context menu of a selected item in package explorer?
How to get the 'Delete' event in context menu of a selected item in package explorer? [message #486539] Fri, 18 September 2009 06:25 Go to next message
sudhir  is currently offline sudhir Friend
Messages: 7
Registered: September 2009
Junior Member
Hi,



I have overridden "org.eclipse.ui.actions.ActionFactory.DELETE" action and provided more functionality at the time of 'Delete' in my application.



I have written following code to register my own Delete action like below.



private void registerXtpDeleteAction(IViewSite viewSite) {



IActionBars actionBars = viewSite.getActionBars();

if ( actionBars != null ) {

String deleteID = org.eclipse.ui.actions.ActionFactory.DELETE.getId();



orginialDeleteAction = actionBars.getGlobalActionHandler(deleteID);

if ( orginialDeleteAction != null ) {

actionBars.setGlobalActionHandler(deleteID,

new XtpDeleteAction(viewSite.getSelectionProvider()));

}

}

}





The problem is that, XtpDeleteAction only gets activated when I delete it by pressing "Delete" button from keyboard or from menu Edit->delete, but if I right click on a file in package explorer and select "Delete" then it doesn't call my overridden class.



What could be wrong here?

Thanks
Sudhir
Re: How to get the 'Delete' event in context menu of a selected item in package explorer? [message #487019 is a reply to message #486539] Mon, 21 September 2009 14:09 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
sudhir wrote:
> Hi,
>
>
> I have overridden "org.eclipse.ui.actions.ActionFactory.DELETE" action
> and provided more functionality at the time of 'Delete' in my
> application.
>
>
>
> I have written following code to register my own Delete action like
> below.
>
>
>
> private void registerXtpDeleteAction(IViewSite viewSite) {
>
>
>
> IActionBars actionBars = viewSite.getActionBars();
>
> if ( actionBars != null ) {
>
> String deleteID =
> org.eclipse.ui.actions.ActionFactory.DELETE.getId();
>
>
>
> orginialDeleteAction =
> actionBars.getGlobalActionHandler(deleteID);
>
> if ( orginialDeleteAction != null ) {
>
> actionBars.setGlobalActionHandler(deleteID,
>
> new XtpDeleteAction(viewSite.getSelectionProvider()));
>
> }
>
> }
>
> }
>
>
>
>
> The problem is that, XtpDeleteAction only gets activated when I delete
> it by pressing "Delete" button from keyboard or from menu
> Edit->delete, but if I right click on a file in package explorer and
> select "Delete" then it doesn't call my overridden class.
Right. For historic reasons many views fill the the concrete actions
into their context menu and don't invoke the corresponding command.
Hence your trick doesn't work.

Dani
>
>
>
> What could be wrong here?
>
> Thanks
> Sudhir
Re: How to get the 'Delete' event in context menu of a selected item in package explorer? [message #487814 is a reply to message #487019] Thu, 24 September 2009 13:46 Go to previous messageGo to next message
sudhir  is currently offline sudhir Friend
Messages: 7
Registered: September 2009
Junior Member
So what is the workaround then?
Re: How to get the 'Delete' event in context menu of a selected item in package explorer? [message #487843 is a reply to message #487814] Thu, 24 September 2009 14:36 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
sudhir wrote:
> So what is the workaround then?
There's no workaround. The delete action is not supposed to be tweaked
but you could try the
org.eclipse.ltk.core.refactoring.deleteParticipants extension point.

Dani
Previous Topic:Splash screen and transparency
Next Topic:How to enable tooltips for each Table cell?
Goto Forum:
  


Current Time: Thu Apr 25 08:20:42 GMT 2024

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

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

Back to the top