Search in sources :

Example 1 with RedoActionHandler

use of org.eclipse.ui.operations.RedoActionHandler in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method createUndoRedoActions.

/**
 * Creates this editor's undo/redo actions.
 * <p>
 * Subclasses may override or extend.</p>
 *
 * @since 3.1
 */
protected void createUndoRedoActions() {
    IUndoContext undoContext = getUndoContext();
    if (undoContext != null) {
        // Use actions provided by global undo/redo
        // Create the undo action
        OperationHistoryActionHandler undoAction = new UndoActionHandler(getEditorSite(), undoContext);
        PlatformUI.getWorkbench().getHelpSystem().setHelp(undoAction, IAbstractTextEditorHelpContextIds.UNDO_ACTION);
        undoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
        registerUndoRedoAction(ITextEditorActionConstants.UNDO, undoAction);
        // Create the redo action.
        OperationHistoryActionHandler redoAction = new RedoActionHandler(getEditorSite(), undoContext);
        PlatformUI.getWorkbench().getHelpSystem().setHelp(redoAction, IAbstractTextEditorHelpContextIds.REDO_ACTION);
        redoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);
        registerUndoRedoAction(ITextEditorActionConstants.REDO, redoAction);
        // Install operation approvers
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        // The first approver will prompt when operations affecting outside elements are to be undone or redone.
        if (fNonLocalOperationApprover != null)
            history.removeOperationApprover(fNonLocalOperationApprover);
        fNonLocalOperationApprover = getUndoRedoOperationApprover(undoContext);
        history.addOperationApprover(fNonLocalOperationApprover);
        // and it is not the most recent operation in the editor.
        if (fLinearUndoViolationApprover != null)
            history.removeOperationApprover(fLinearUndoViolationApprover);
        fLinearUndoViolationApprover = new LinearUndoViolationUserApprover(undoContext, this);
        history.addOperationApprover(fLinearUndoViolationApprover);
    } else {
        // Use text operation actions (pre 3.1 style)
        ResourceAction action;
        if (getAction(ITextEditorActionConstants.UNDO) == null) {
            // $NON-NLS-1$
            action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Undo.", this, ITextOperationTarget.UNDO);
            action.setHelpContextId(IAbstractTextEditorHelpContextIds.UNDO_ACTION);
            action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
            setAction(ITextEditorActionConstants.UNDO, action);
        }
        if (getAction(ITextEditorActionConstants.REDO) == null) {
            // $NON-NLS-1$
            action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Redo.", this, ITextOperationTarget.REDO);
            action.setHelpContextId(IAbstractTextEditorHelpContextIds.REDO_ACTION);
            action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);
            setAction(ITextEditorActionConstants.REDO, action);
        }
    }
}
Also used : IUndoContext(org.eclipse.core.commands.operations.IUndoContext) OperationHistoryActionHandler(org.eclipse.ui.operations.OperationHistoryActionHandler) LinearUndoViolationUserApprover(org.eclipse.ui.operations.LinearUndoViolationUserApprover) IOperationHistory(org.eclipse.core.commands.operations.IOperationHistory) RedoActionHandler(org.eclipse.ui.operations.RedoActionHandler) UndoActionHandler(org.eclipse.ui.operations.UndoActionHandler)

Example 2 with RedoActionHandler

use of org.eclipse.ui.operations.RedoActionHandler in project cubrid-manager by CUBRID.

the class CUBRIDTextEditor method createActions.

/**
	 * Create actions of editor.
	 *
	 */
protected void createActions() {
    //Do nothing.
    UndoActionHandler undo = new UndoActionHandler(this.getSite(), undoManager.getUndoContext());
    undo.setAccelerator(SWT.CTRL | 'z');
    actions.put(ActionFactory.UNDO.getId(), undo);
    RedoActionHandler redo = new RedoActionHandler(this.getSite(), undoManager.getUndoContext());
    redo.setAccelerator(SWT.CTRL | 'y');
    actions.put(ActionFactory.REDO.getId(), redo);
    actions.put(ActionFactory.CUT.getId(), new TextEditorAction(Messages.menuCut, this, ITextOperationTarget.CUT));
    actions.put(ActionFactory.COPY.getId(), new TextEditorAction(Messages.menuCopy, this, ITextOperationTarget.COPY));
    actions.put(ActionFactory.PASTE.getId(), new TextEditorAction(Messages.menuPast, this, ITextOperationTarget.PASTE));
    actions.put(ActionFactory.FIND.getId(), new FindReplaceAction(Messages.menuFindReplace));
}
Also used : FindReplaceAction(com.cubrid.tool.editor.action.FindReplaceAction) RedoActionHandler(org.eclipse.ui.operations.RedoActionHandler) TextEditorAction(com.cubrid.tool.editor.action.TextEditorAction) UndoActionHandler(org.eclipse.ui.operations.UndoActionHandler)

Aggregations

RedoActionHandler (org.eclipse.ui.operations.RedoActionHandler)2 UndoActionHandler (org.eclipse.ui.operations.UndoActionHandler)2 FindReplaceAction (com.cubrid.tool.editor.action.FindReplaceAction)1 TextEditorAction (com.cubrid.tool.editor.action.TextEditorAction)1 IOperationHistory (org.eclipse.core.commands.operations.IOperationHistory)1 IUndoContext (org.eclipse.core.commands.operations.IUndoContext)1 LinearUndoViolationUserApprover (org.eclipse.ui.operations.LinearUndoViolationUserApprover)1 OperationHistoryActionHandler (org.eclipse.ui.operations.OperationHistoryActionHandler)1