SimpleGraphicalEditor graphicalEditor = (SimpleGraphicalEditor) htmlEditor
.getDesignViewer();
IWorkbenchPartSite site = htmlEditor.getSite();
if (site instanceof IEditorSite) {
IActionBars actionBars = ((IEditorSite) site).getActionBars();
if (enabled) {
// // we always let the text editor to handle UNDO and REDO
// actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO,
// textEditor
// .getAction(ITextEditorActionConstants.UNDO));
// actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO,
// textEditor
// .getAction(ITextEditorActionConstants.REDO));
// lium: the above behavior changed, since we now use
// DesignerUndoRedoAction.
// see comments in DesignerUndoRedoAction
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.UNDO, graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_UNDO));
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.REDO, graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_REDO));
// cut/copy/paste is delegated to design actions
actionBars
.setGlobalActionHandler(
ITextEditorActionConstants.DELETE,
graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_DELETE));
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.CUT, graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_CUT));
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.COPY, graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_COPY));
actionBars
.setGlobalActionHandler(
ITextEditorActionConstants.PASTE,
graphicalEditor
.getAction(IWorkbenchCommandConstants.EDIT_PASTE));
} else {
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.UNDO, null);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.REDO, null);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.DELETE, null);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.CUT, null);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.COPY, null);
actionBars.setGlobalActionHandler(
ITextEditorActionConstants.PASTE, null);
}
}
}