本文整理汇总了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);
}
}
}
示例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));
}
}