当前位置: 首页>>代码示例>>Java>>正文


Java UndoEdit类代码示例

本文整理汇总了Java中org.eclipse.text.edits.UndoEdit的典型用法代码示例。如果您正苦于以下问题:Java UndoEdit类的具体用法?Java UndoEdit怎么用?Java UndoEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UndoEdit类属于org.eclipse.text.edits包,在下文中一共展示了UndoEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performEdits

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
/**
 * Executes the text edits on the given document. Subclasses that override this method should call
 * <code>super.performEdits(document)</code>.
 *
 * @param document the document
 * @return an object representing the undo of the executed edits
 * @exception MalformedTreeException is thrown if the edit tree isn't in a valid state. This
 *     exception is thrown before any edit is executed. So the document is still in its original
 *     state.
 * @exception BadLocationException is thrown if one of the edits in the tree can't be executed.
 *     The state of the document is undefined if this exception is thrown.
 * @since 3.5
 */
protected UndoEdit performEdits(IDocument document)
    throws BadLocationException, MalformedTreeException {
  DocumentRewriteSession session = null;
  try {
    if (document instanceof IDocumentExtension4) {
      session =
          ((IDocumentExtension4) document)
              .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
    }

    LinkedModeModel.closeAllModels(document);
    TextEditProcessor processor = createTextEditProcessor(document, TextEdit.CREATE_UNDO, false);
    return processor.performEdits();

  } finally {
    if (session != null) {
      ((IDocumentExtension4) document).stopRewriteSession(session);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:TextChange.java

示例2: performEdit

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
private void performEdit(IDocument document, long oldFileValue, LinkedList<UndoEdit> editCollector, long[] oldDocValue, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException {
	if (document instanceof IDocumentExtension4) {
		oldDocValue[0]= ((IDocumentExtension4)document).getModificationStamp();
	} else {
		oldDocValue[0]= oldFileValue;
	}

	// perform the changes
	for (int index= 0; index < fUndos.length; index++) {
		UndoEdit edit= fUndos[index];
		UndoEdit redo= edit.apply(document, TextEdit.CREATE_UNDO);
		editCollector.addFirst(redo);
	}

	if (document instanceof IDocumentExtension4 && fDocumentStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP) {
		try {
			((IDocumentExtension4)document).replace(0, 0, "", fDocumentStamp); //$NON-NLS-1$
			setContentStampSuccess[0]= true;
		} catch (BadLocationException e) {
			throw wrapBadLocationException(e);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:CleanUpPostSaveListener.java

示例3: EditorDocumentUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public EditorDocumentUndoChange(String name, ITextEditor editor, UndoEdit undoEdit, boolean doSave) {
	this.name = name;
	this.editorID = editor.getSite().getId();
	this.editorInput = editor.getEditorInput();
	this.undoEdit = undoEdit;
	this.doSave = doSave;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:8,代码来源:EditorDocumentUndoChange.java

示例4: performEdits

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
protected UndoEdit performEdits(IDocument document) throws BadLocationException, MalformedTreeException {
	DocumentRewriteSession session= null;
	try {
		if (document instanceof IDocumentExtension4) {
			session= ((IDocumentExtension4)document).startRewriteSession(
				DocumentRewriteSessionType.UNRESTRICTED);
		}
		return undoEdit.apply(document);
	} finally {
		if (session != null) {
			((IDocumentExtension4)document).stopRewriteSession(session);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:EditorDocumentUndoChange.java

示例5: createUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
/** {@inheritDoc} */
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
  try {
    return new UndoCompilationUnitChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
  } catch (CoreException e) {
    JavaManipulationPlugin.log(e);
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:CompilationUnitChange.java

示例6: perform

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
/** {@inheritDoc} */
public Change perform(IProgressMonitor pm) throws CoreException {
  if (fValidationState == null || fValidationState.isValid(needsSaving(), false).hasFatalError())
    return new NullChange();
  if (pm == null) pm = new NullProgressMonitor();
  ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
  pm.beginTask("", 2); // $NON-NLS-1$
  ITextFileBuffer buffer = null;
  try {
    manager.connect(fFile.getFullPath(), LocationKind.IFILE, new SubProgressMonitor(pm, 1));
    buffer = manager.getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
    IDocument document = buffer.getDocument();
    ContentStamp currentStamp = ContentStamps.get(fFile, document);
    // perform the changes
    LinkedList list = new LinkedList();
    for (int index = 0; index < fUndos.length; index++) {
      UndoEdit edit = fUndos[index];
      UndoEdit redo = edit.apply(document, TextEdit.CREATE_UNDO);
      list.addFirst(redo);
    }

    // try to restore the document content stamp
    boolean success = ContentStamps.set(document, fContentStampToRestore);
    if (needsSaving()) {
      buffer.commit(pm, false);
      if (!success) {
        // We weren't able to restore document stamp.
        // Since we save restore the file stamp instead
        ContentStamps.set(fFile, fContentStampToRestore);
      }
    }
    return createUndoChange((UndoEdit[]) list.toArray(new UndoEdit[list.size()]), currentStamp);
  } catch (BadLocationException e) {
    throw Changes.asCoreException(e);
  } finally {
    if (buffer != null)
      manager.disconnect(fFile.getFullPath(), LocationKind.IFILE, new SubProgressMonitor(pm, 1));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:MultiStateUndoChange.java

示例7: doPerformEdits

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
private UndoEdit doPerformEdits(IDocument document, boolean[] setContentStampSuccess)
    throws MalformedTreeException, BadLocationException, CoreException {
  // perform the changes
  LinkedModeModel.closeAllModels(document);
  UndoEdit redo = fUndo.apply(document, TextEdit.CREATE_UNDO);

  // try to restore the document content stamp
  setContentStampSuccess[0] = ContentStamps.set(document, fContentStampToRestore);
  return redo;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:UndoTextFileChange.java

示例8: perform

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public final Change perform(final IProgressMonitor monitor) throws CoreException {
  monitor.beginTask("", 3); // $NON-NLS-1$

  IDocument document = null;

  try {
    document = acquireDocument(new SubProgressMonitor(monitor, 1));

    final LinkedList undoList = new LinkedList();
    performChanges(document, undoList, false);

    if (needsSaving()) fBuffer.commit(new SubProgressMonitor(monitor, 1), false);

    return new MultiStateUndoChange(
        getName(),
        fFile,
        (UndoEdit[]) undoList.toArray(new UndoEdit[undoList.size()]),
        fContentStamp,
        fSaveMode);

  } catch (BadLocationException exception) {
    throw Changes.asCoreException(exception);
  } finally {
    if (document != null) {
      releaseDocument(document, new SubProgressMonitor(monitor, 1));
    }
    monitor.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:MultiStateTextFileChange.java

示例9: performChangesInSynchronizationContext

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
private void performChangesInSynchronizationContext(
    final IDocument document, final LinkedList undoList, final boolean preview)
    throws BadLocationException {
  DocumentRewriteSession session = null;
  try {
    if (document instanceof IDocumentExtension4)
      session =
          ((IDocumentExtension4) document)
              .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);

    for (final Iterator iterator = fChanges.iterator(); iterator.hasNext(); ) {
      final ComposableBufferChange change = (ComposableBufferChange) iterator.next();

      final UndoEdit edit =
          createTextEditProcessor(
                  change,
                  document,
                  undoList != null ? TextEdit.CREATE_UNDO : TextEdit.NONE,
                  preview)
              .performEdits();
      if (undoList != null) undoList.addFirst(edit);
    }

  } finally {
    if (session != null) ((IDocumentExtension4) document).stopRewriteSession(session);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:MultiStateTextFileChange.java

示例10: CleanUpSaveUndo

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public CleanUpSaveUndo(String name, IFile file, UndoEdit[] undos, long documentStamp, long fileStamp) {
	super(name, file);
	Assert.isNotNull(undos);

	fDocumentStamp= documentStamp;
	fFileStamp= fileStamp;
	fFile= file;
	fUndos= undos;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:CleanUpPostSaveListener.java

示例11: createUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
protected Change createUndoChange(UndoEdit edit) {
	return new EditorDocumentUndoChange(getName(), editor, edit, doSave);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:4,代码来源:EditorDocumentUndoChange.java

示例12: createUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
@Override
protected Change createUndoChange(UndoEdit edit) {
	return new EditorDocumentUndoChange(getName(), editor, edit, doSave);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:5,代码来源:EditorDocumentChange.java

示例13: applyTextEdit

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public UndoEdit applyTextEdit(TextEdit edit) {
  fEdit = edit;
  fUndoEdit = null;
  DocumentAdapter.run(this);
  return fUndoEdit;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:DocumentAdapter.java

示例14: UndoCompilationUnitChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public UndoCompilationUnitChange(
    String name, ICompilationUnit unit, UndoEdit undo, ContentStamp stampToRestore, int saveMode)
    throws CoreException {
  super(name, getFile(unit), undo, stampToRestore, saveMode);
  fCUnit = unit;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:UndoCompilationUnitChange.java

示例15: createUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
/** {@inheritDoc} */
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore)
    throws CoreException {
  return new UndoCompilationUnitChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:UndoCompilationUnitChange.java


注:本文中的org.eclipse.text.edits.UndoEdit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。