Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » KeyBinding for delete
KeyBinding for delete [message #1005917] Tue, 29 January 2013 10:00 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Hi,

I am working with a RCP application. I have defined my scheme extending from org.eclipse.ui.defaultAcceleratorConfiguration.
I have defined key for command org.eclipse.ui.edit.delete(M2+DEL).
In my view(containing treeviewer) when user press delete then action is performed but i want it to be performed with (shift + delete) as defined in scheme.

If user tries edit menu then short cut for delete is shift + delete, then why delete key is still working as shortcut?

Do you know what is problematic here?

Cheers,

[Updated on: Tue, 29 January 2013 10:03]

Report message to a moderator

Re: KeyBinding for delete [message #1005922 is a reply to message #1005917] Tue, 29 January 2013 10:09 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
hi, post here your key binding
also, are you running your product with your defined scheme?
Re: KeyBinding for delete [message #1005933 is a reply to message #1005922] Tue, 29 January 2013 10:48 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Hi,

Yes i am running my product with my defined scheme(plugin_customization.ini file is added). Actually i have some other key definitions as well and they are working fine but not delete.

<extension
point="org.eclipse.ui.bindings">
<scheme
id="MyScheme"
name="MyScheme"
parentId="org.eclipse.ui.defaultAcceleratorConfiguration">
</scheme>
<key
commandId="org.eclipse.ui.file.saveAll"
schemeId="MyScheme"
sequence="M1+S">
</key>
<key
commandId="org.eclipse.ui.edit.delete"
schemeId="MyScheme"
sequence="M2+DEL">
</key>
</extension>

This is define in main plugin and my view is constructed by other plugin and main pluigin contains all other plugins as dependency.

thanks!
Re: KeyBinding for delete [message #1005939 is a reply to message #1005933] Tue, 29 January 2013 10:59 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Do you have this code in your ActionBarAdvisor class?

@Override
protected void makeActions(final IWorkbenchWindow window) {
	// Creates the actions and registers them.
	// Registering is needed to ensure that key bindings work.
	// The corresponding commands keybindings are defined in the plugin.xml
	// file.
	// Registering also provides automatic disposal of the actions when
	// the window is closed.

	register(ActionFactory.UNDO.create(window));
	register(ActionFactory.REDO.create(window));
	register(ActionFactory.DELETE.create(window));
        ...
}

as defined in https://bugs.eclipse.org/bugs/show_bug.cgi?id=270007
Re: KeyBinding for delete [message #1005946 is a reply to message #1005939] Tue, 29 January 2013 11:30 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Yes ActionBarAdvisor class contains this code.

I just want to add that key binding for org.eclipse.ui.file.saveAll command works fine but not org.eclipse.ui.edit.delete.


thanks!

[Updated on: Tue, 29 January 2013 11:47]

Report message to a moderator

Re: KeyBinding for delete [message #1005964 is a reply to message #1005946] Tue, 29 January 2013 12:24 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
How do you contribute the delete to menu?
Re: KeyBinding for delete [message #1005972 is a reply to message #1005964] Tue, 29 January 2013 12:49 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
protected void fillMenuBar(IMenuManager menuBar) {

MenuManager fileMenu = new MenuManager("&File", "file");
MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);

menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menuBar.add(fileMenu);
menuBar.add(editMenu);

fileMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
fileMenu.add(exitAction);

// Edit
editMenu.add(undoAction);
editMenu.add(redoAction);
editMenu.add(deleteAction);
editMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

}
Re: KeyBinding for delete [message #1005975 is a reply to message #1005972] Tue, 29 January 2013 13:04 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
What is deleteAction? How do you create it?
Re: KeyBinding for delete [message #1005980 is a reply to message #1005975] Tue, 29 January 2013 13:16 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
In the same class.. in makeActions method. Here comes rest of the class

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
public static final String TOOLBAR_MAIN = "main";
public static final String TOOLBAR_EDIT = "edit";
private IWorkbenchAction exitAction;
private IWorkbenchAction saveAllAction;
private IWorkbenchAction saveAsAction;
private IWorkbenchAction undoAction;
private IWorkbenchAction redoAction;
private IWorkbenchAction deleteAction;
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(IWorkbenchWindow window) {
exitAction = ActionFactory.QUIT.create(window);
undoAction = ActionFactory.UNDO.create(window);
redoAction = ActionFactory.REDO.create(window);
deleteAction = ActionFactory.DELETE.create(window);
saveAllAction = ActionFactory.SAVE_ALL.create(window);
saveAsAction = ActionFactory.SAVE_AS.create(window);
register(undoAction);
register(redoAction);
register(deleteAction);
register(saveAsAction);
register(ActionFactory.CUT.create(window));
register(ActionFactory.COPY.create(window));
register(ActionFactory.PASTE.create(window));
register(ActionFactory.SELECT_ALL.create(window));

}
}

thanks alot for helping
Re: KeyBinding for delete [message #1005986 is a reply to message #1005980] Tue, 29 January 2013 13:30 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
And the code where you register the global action handler for that retarget action?
Re: KeyBinding for delete [message #1005990 is a reply to message #1005986] Tue, 29 January 2013 13:42 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
This is from view class.

@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
IActionBars bars = site.getActionBars();
UndoAction actionUndo = new UndoAction(site.getWorkbenchWindow(), this);
RedoAction actionRedo = new RedoAction(site.getWorkbenchWindow(), this);
deleteAction = new DeleteAction(site.getWorkbenchWindow(), this);
bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
bars.setGlobalActionHandler(ActionFactory.UNDO.getId(), actionUndo);
bars.setGlobalActionHandler(ActionFactory.REDO.getId(), actionRedo);
bars.updateActionBars();
}




this is action class



public class DeleteAction extends Action implements ISelectionListener {

private IWorkbenchWindow window;
private IWorkbenchPart part;
private IUndoContext context;
public DeleteAction(IWorkbenchWindow window, IWorkbenchPart part) {
this.window = window;
this.part = part;
setActionDefinitionId(ActionFactory.DELETE.getId());
window.getSelectionService().addSelectionListener(this);
setText("Delete View");
setEnabled(false);
}

@Override

public void run() {...
....
}

}


thanks!
Re: KeyBinding for delete [message #1005991 is a reply to message #1005990] Tue, 29 January 2013 13:49 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Try to change

setActionDefinitionId(ActionFactory.DELETE.getId());

to

setActionDefinitionId(ActionFactory.DELETE.getCommandId());
Re: KeyBinding for delete [message #1005993 is a reply to message #1005991] Tue, 29 January 2013 13:56 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Hi,

I have tried that but it does not make any difference... and when i select the object to delete and open edit menu then delete menu item's short cut is shift + delete which is correct one but still delete key works and other key definition for saveAll action works fine.. it is very strange for me. Can you predict what is wrong here?
Re: KeyBinding for delete [message #1005996 is a reply to message #1005993] Tue, 29 January 2013 14:01 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
So both DEL and SHIFT + DEL triggers the Delete action?
Re: KeyBinding for delete [message #1005997 is a reply to message #1005996] Tue, 29 January 2013 14:04 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
yes both trigger the action...

Re: KeyBinding for delete [message #1006001 is a reply to message #1005997] Tue, 29 January 2013 14:15 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hmm...I really don't know. Maybe some part of the View has added a KeyListener to a control of it.
For example GEF's EditPartViewer could do that.
Previous Topic:Dragging Editor Disposes it
Next Topic:Dynamic contents in Application Coolbar
Goto Forum:
  


Current Time: Thu Apr 18 12:26:48 GMT 2024

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

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

Back to the top