Search in sources :

Example 6 with ITextViewerExtension6

use of org.eclipse.jface.text.ITextViewerExtension6 in project xtext-eclipse by eclipse.

the class LinkedEditingUndoSupport method undoDocumentChanges.

public void undoDocumentChanges() {
    final ISourceViewer viewer = editor.getInternalSourceViewer();
    try {
        editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                if (viewer instanceof ITextViewerExtension6) {
                    IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
                    if (undoManager instanceof IUndoManagerExtension) {
                        IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
                        IUndoContext undoContext = undoManagerExtension.getUndoContext();
                        IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
                        while (undoManager.undoable()) {
                            if (startingUndoOperation != null && startingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
                                return;
                            undoManager.undo();
                        }
                    }
                }
            }
        });
        syncUtil.waitForReconciler(editor);
    } catch (InterruptedException e) {
        // cancelled by user, ok
        return;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
}
Also used : IUndoContext(org.eclipse.core.commands.operations.IUndoContext) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IUndoManager(org.eclipse.jface.text.IUndoManager) ITextViewerExtension6(org.eclipse.jface.text.ITextViewerExtension6) IOperationHistory(org.eclipse.core.commands.operations.IOperationHistory) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IUndoManagerExtension(org.eclipse.jface.text.IUndoManagerExtension)

Aggregations

ITextViewerExtension6 (org.eclipse.jface.text.ITextViewerExtension6)6 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)4 IUndoManager (org.eclipse.jface.text.IUndoManager)3 IOperationHistory (org.eclipse.core.commands.operations.IOperationHistory)2 IUndoContext (org.eclipse.core.commands.operations.IUndoContext)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IUndoManagerExtension (org.eclipse.jface.text.IUndoManagerExtension)2 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)2 Point (org.eclipse.swt.graphics.Point)2 IColumnSupport (org.eclipse.ui.texteditor.rulers.IColumnSupport)2 RulerColumnDescriptor (org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IAction (org.eclipse.jface.action.IAction)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)1 ITextViewerExtension8 (org.eclipse.jface.text.ITextViewerExtension8)1 IOverviewRulerExtension (org.eclipse.jface.text.source.IOverviewRulerExtension)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)1