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


Java UndoEdit.apply方法代码示例

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


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

示例1: 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

示例2: 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


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