Home » Eclipse Projects » Eclipse Platform » MultiPageEditorActionBarContributor - setGlobalActionHandler not working
MultiPageEditorActionBarContributor - setGlobalActionHandler not working [message #335034] |
Wed, 18 March 2009 04:39 |
Matt Gray Messages: 13 Registered: July 2009 |
Junior Member |
|
|
I've implemented a multipage editor, which has two pages. The first page
has a TextEditor, and the second page has my own custom EditorPart
subclass (called 'SampleView' for want of a better name).
I've set up a MultiPageEditorActionBarContributor subclass to switch the
global action handlers when setActivePage() is called.
For actions such as copy, paste, delete, etc, the 'Edit' menu of the
workbench works correctly - the commands are handled by the actions that I
set in setActivePage(). However, the key bindings are broken - it seems
that they are stuck bound to the text editor.
e.g. if I have my custom editor visible, and select the 'Delete' command
from the edit menu, the delete action is called in my editor. But if I
press the 'delete' key on the keyboard, a character is deleted from the
invisible text editor.
Here's my code for setActivePage(). I can't see why it would be
correctly setting the menu items, but not the corresponding key bindings.
Any help appreciated.
(As an aside, I started with my editor outside the multipage editor
structure, and was using setGlobalActionHandler() successfully to set key
bindings for delete, copy, paste, etc. It's only since putting it inside
a multipage editor and using MultiPageEditorActionBarContributor that it
has gone funny).
public void setActivePage(IEditorPart part) {
if (activeEditorPart == part)
return;
activeEditorPart = part;
IActionBars actionBars = getActionBars();
if (actionBars != null) {
if (part instanceof ITextEditor) {
ITextEditor editor = (ITextEditor) part ;
actionBars.setGlobalActionHandler(
ActionFactory.DELETE.getId(),
getAction(editor, ITextEditorActionConstants.DELETE));
actionBars.setGlobalActionHandler(
ActionFactory.UNDO.getId(),
getAction(editor, ITextEditorActionConstants.UNDO));
actionBars.setGlobalActionHandler(
ActionFactory.REDO.getId(),
getAction(editor, ITextEditorActionConstants.REDO));
actionBars.setGlobalActionHandler(
ActionFactory.CUT.getId(),
getAction(editor, ITextEditorActionConstants.CUT));
actionBars.setGlobalActionHandler(
ActionFactory.COPY.getId(),
getAction(editor, ITextEditorActionConstants.COPY));
actionBars.setGlobalActionHandler(
ActionFactory.PASTE.getId(),
getAction(editor, ITextEditorActionConstants.PASTE));
actionBars.setGlobalActionHandler(
ActionFactory.SELECT_ALL.getId(),
getAction(editor, ITextEditorActionConstants.SELECT_ALL));
actionBars.setGlobalActionHandler(
ActionFactory.FIND.getId(),
getAction(editor, ITextEditorActionConstants.FIND));
actionBars.setGlobalActionHandler(
IDEActionFactory.BOOKMARK.getId(),
getAction(editor, IDEActionFactory.BOOKMARK.getId()));
actionBars.updateActionBars();
} else if (part instanceof SampleView) {
SampleView editor = (SampleView) part;
actionBars.setGlobalActionHandler(
ActionFactory.DELETE.getId(),
getAction(editor, "delete"));
actionBars.setGlobalActionHandler(
ActionFactory.UNDO.getId(),
getAction(editor, "undo"));
actionBars.setGlobalActionHandler(
ActionFactory.CUT.getId(),
getAction(editor, "cut"));
actionBars.setGlobalActionHandler(
ActionFactory.COPY.getId(),
getAction(editor, "copy"));
actionBars.setGlobalActionHandler(
ActionFactory.PASTE.getId(),
getAction(editor, "paste"));
actionBars.updateActionBars();
editor.setDrawingType(drawingType);
}
}
}
|
|
| | |
Goto Forum:
Current Time: Mon Dec 30 16:41:14 GMT 2024
Powered by FUDForum. Page generated in 0.02568 seconds
|