• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UndoEdit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: UndoDocumentChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
public UndoDocumentChange(String name, IDocument document, UndoEdit undo) {
  fName = name;
  fUndo = undo;
  fDocument = document;
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:UndoDocumentChange.java


示例17: performEdits

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
private UndoEdit performEdits() throws BadLocationException, MalformedTreeException {
  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  ITextFileBuffer fileBuffer = fileBufferManager.getTextFileBuffer(fDocument);
  if (fileBuffer == null || !fileBuffer.isSynchronizationContextRequested()) {
    return fUndo.apply(fDocument, TextEdit.CREATE_UNDO);
  }

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final UndoEdit[] result = new UndoEdit[1];
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              result[0] = fUndo.apply(fDocument, TextEdit.CREATE_UNDO);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }

  return result[0];
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:UndoDocumentChange.java


示例18: performEdits

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
protected UndoEdit performEdits(final IDocument document)
    throws BadLocationException, MalformedTreeException {
  ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();

  ITextFileBuffer fileBuffer = fileBufferManager.getTextFileBuffer(document);
  if (fileBuffer == null || !fileBuffer.isSynchronizationContextRequested()) {
    return super.performEdits(document);
  }

  /** The lock for waiting for computation in the UI thread to complete. */
  final Lock completionLock = new Lock();
  final UndoEdit[] result = new UndoEdit[1];
  final BadLocationException[] exception = new BadLocationException[1];
  Runnable runnable =
      new Runnable() {
        public void run() {
          synchronized (completionLock) {
            try {
              result[0] = DocumentChange.super.performEdits(document);
            } catch (BadLocationException e) {
              exception[0] = e;
            } finally {
              completionLock.fDone = true;
              completionLock.notifyAll();
            }
          }
        }
      };

  synchronized (completionLock) {
    fileBufferManager.execute(runnable);
    while (!completionLock.fDone) {
      try {
        completionLock.wait(500);
      } catch (InterruptedException x) {
      }
    }
  }

  if (exception[0] != null) {
    throw exception[0];
  }

  return result[0];
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:DocumentChange.java


示例19: createUndoChange

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


示例20: createUndoChange

import org.eclipse.text.edits.UndoEdit; //导入依赖的package包/类
/** {@inheritDoc} */
protected final Change createUndoChange(UndoEdit edit) {
  return createUndoChange(edit, fContentStamp);
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:TextFileChange.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CacheManipulator类代码示例发布时间:2022-05-22
下一篇:
Java JavaTextTools类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap