Skip to main content



      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 02:25 Go to next message
Eclipse UserFriend
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 10:09 Go to previous messageGo to next message
Eclipse UserFriend
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 09:46 Go to previous messageGo to next message
Eclipse UserFriend
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 10:36 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 10:55:43 EDT 2025

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

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

Back to the top