Java 类org.eclipse.jface.text.IUndoManager 实例源码

项目:bts    文件:LinkedEditingUndoSupport.java   
public void undoDocumentChanges() {
    final ISourceViewer viewer = editor.getInternalSourceViewer();
    try {
        editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
            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 (Exception e) {
        LOG.error(e.getMessage(), e);
    }
}
项目:birt    文件:JSEditor.java   
/**
 * Saves input code to model
 */
private void saveModel( )
{
    if ( isCodeModified( ) && editObject instanceof DesignElementHandle )
    {
        saveEditorContentsDE( (DesignElementHandle) editObject,
                isSaveScript );
    }

    setIsModified( false );

    ( (IFormPage) getParentEditor( ) ).getEditor( )
            .editorDirtyStateChanged( );

    firePropertyChange( PROP_DIRTY );

    SourceViewer viewer = getViewer( );
    IUndoManager undoManager = viewer == null ? null
            : viewer.getUndoManager( );

    if ( undoManager != null )
    {
        undoManager.endCompoundChange( );
    }
    cleanPoint = getUndoLevel( );
}
项目:tlaplus    文件:TLAEditor.java   
private IUndoContext getUndoContext() {
    if (getSourceViewer() instanceof ITextViewerExtension6) {
        IUndoManager undoManager = ((ITextViewerExtension6) getSourceViewer()).getUndoManager();
        if (undoManager instanceof IUndoManagerExtension)
            return ((IUndoManagerExtension) undoManager).getUndoContext();
    }
    return null;
}
项目:fluentmark    文件:AbstractDocumentCommand.java   
public void execute(IUndoManager undoManager, IDocument document) throws CoreException {
    if (!isEnabled()) {
        throw new IllegalStateException();
    }
    try {
        undoManager.beginCompoundChange();
        try {
            doCommand(document);
        } finally {
            undoManager.endCompoundChange();
        }
    } catch (BadLocationException e) {
        throw new CoreException(FluentMkUI.getDefault().createStatus(IStatus.ERROR, e));
    }
}
项目:bts    文件:LinkedEditingUndoSupport.java   
public void startRecording(XtextEditor editor) {
    this.editor = editor;
    ISourceViewer viewer = editor.getInternalSourceViewer();
    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();
            startingUndoOperation = operationHistory.getUndoOperation(undoContext);
        }
    }
}
项目:vTM-eclipse    文件:TrafficScriptConf.java   
/**
 * Creates the undo manager (uses the undo level of general text editors)
 */
/* Override */
public IUndoManager getUndoManager( ISourceViewer sourceViewer )
{      
   TextViewerUndoManager undoManager = new TextViewerUndoManager( 
      PreferenceManager.getExternalPreferenceInt( 
         ExternalPreference.EDITOR_UNDO_LEVEL
      )
   );

   editor.setUndoManager( undoManager );
   return undoManager;
}
项目:birt    文件:DecoratedScriptEditor.java   
public void setScript( String script )
{
    try
    {
        IDocumentProvider provider = getDocumentProvider( );

        if ( provider != null )
        {
            IDocument document = provider.getDocument( getEditorInput( ) );

            if ( document != null )
            {
                document.set( script == null ? "" : script ); //$NON-NLS-1$
                return;
            }
        }
        input = createScriptInput( script );
    }
    finally
    {
        ISourceViewer viewer = getSourceViewer( );

        if ( viewer instanceof SourceViewer )
        {
            IUndoManager undoManager = ( (SourceViewer) viewer ).getUndoManager( );

            if ( undoManager != null )
            {
                undoManager.reset( );
            }
        }
    }
}
项目:birt    文件:ScriptEditor.java   
public void setScript( String script )
{
    try
    {
        IDocumentProvider provider = getDocumentProvider( );

        if ( provider != null )
        {
            IDocument document = provider.getDocument( getEditorInput( ) );

            if ( document != null )
            {
                document.set( script == null ? "" : script ); //$NON-NLS-1$
                return;
            }
        }
        input = createScriptInput( script );
    }
    finally
    {
        ISourceViewer viewer = getSourceViewer( );

        if ( viewer instanceof SourceViewer )
        {
            IUndoManager undoManager = ( (SourceViewer) viewer ).getUndoManager( );

            if ( undoManager != null )
            {
                undoManager.reset( );
            }
        }
    }
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelSourceViewerConfiguration.java   
@Override
public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
    return null;
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelSourceViewerConfiguration.java   
@Override
public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
    return null;
}
项目:typescript.java    文件:RenameLinkedMode.java   
public void start() {
    if (getActiveLinkedMode() != null) {
        // for safety; should already be handled in RenameJavaElementAction
        fgActiveLinkedMode.startFullDialog();
        return;
    }

    ISourceViewer viewer = fEditor.getViewer();
    IDocument document = viewer.getDocument();

    ITypeScriptFile tsFile = fEditor.getTypeScriptFile();
    tsFile.setDisableChanged(true);
    fOriginalSelection = viewer.getSelectedRange();
    int offset = fOriginalSelection.x;

    try {
        fLinkedPositionGroup = new LinkedPositionGroup();
        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();
                fStartingUndoOperation = operationHistory.getUndoOperation(undoContext);
            }
        }

        // Find occurrences
        List<OccurrencesResponseItem> occurrences = tsFile.occurrences(offset).get(1000, TimeUnit.MILLISECONDS);

        // Create Eclipse linked position from the occurrences list.
        int start, length;
        for (int i = 0; i < occurrences.size(); i++) {
            OccurrencesResponseItem item = occurrences.get(i);
            start = tsFile.getPosition(item.getStart());
            length = tsFile.getPosition(item.getEnd()) - start;
            LinkedPosition linkedPosition = new LinkedPosition(document, start, length, i);
            if (i == 0) {
                fOriginalName = document.get(start, length);
                fNamePosition = linkedPosition;
            }
            fLinkedPositionGroup.addPosition(linkedPosition);
        }

        fLinkedModeModel = new LinkedModeModel();
        fLinkedModeModel.addGroup(fLinkedPositionGroup);
        fLinkedModeModel.forceInstall();
        fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
        fLinkedModeModel.addLinkingListener(new EditorSynchronizer());

        LinkedModeUI ui = new EditorLinkedModeUI(fLinkedModeModel, viewer);
        ui.setExitPosition(viewer, offset, 0, Integer.MAX_VALUE);
        ui.setExitPolicy(new ExitPolicy(document));
        ui.enter();

        viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y); // by
                                                                                // default,
                                                                                // full
                                                                                // word
                                                                                // is
                                                                                // selected;
                                                                                // restore
                                                                                // original
                                                                                // selection

        if (viewer instanceof IEditingSupportRegistry) {
            IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
            registry.register(fFocusEditingSupport);
        }

        openSecondaryPopup();
        // startAnimation();
        fgActiveLinkedMode = this;

    } catch (Exception e) {
        JSDTTypeScriptUIPlugin.log(e);
    }
}
项目:gwt-eclipse-plugin    文件:DelegatingTextViewer.java   
public void setUndoManager(IUndoManager undoManager) {
  originalTextViewer.setUndoManager(undoManager);
}
项目:velocity-edit    文件:Configuration.java   
@Override
public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
    return new TextViewerUndoManager(unDoLimit);
}
项目:strutsclipse    文件:MockTextViewer.java   
@Override
public void setUndoManager(IUndoManager undoManager) {
}
项目:Pydev    文件:ScriptConsoleViewerWrapper.java   
@Override
public void setUndoManager(IUndoManager undoManager) {
    viewer.setUndoManager(undoManager);
}
项目:Pydev    文件:ScriptConsoleViewerWrapper.java   
public IUndoManager getUndoManager() {
    return viewer.getUndoManager();
}