本文整理汇总了Java中org.eclipse.jface.text.DocumentRewriteSessionType类的典型用法代码示例。如果您正苦于以下问题:Java DocumentRewriteSessionType类的具体用法?Java DocumentRewriteSessionType怎么用?Java DocumentRewriteSessionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentRewriteSessionType类属于org.eclipse.jface.text包,在下文中一共展示了DocumentRewriteSessionType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyAllInSameDocument
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
* Applies all given changes to the given document. This method assumes that 'changes' contains only changes
* intended for the given document; the actual URI stored in the changes is ignored.
*/
public void applyAllInSameDocument(Collection<? extends IAtomicChange> changes, IDocument document)
throws BadLocationException {
DocumentRewriteSession rewriteSession = null;
try {
// prepare
if (document instanceof IDocumentExtension4) {
rewriteSession = ((IDocumentExtension4) document).startRewriteSession(
DocumentRewriteSessionType.UNRESTRICTED);
}
// perform replacements
for (IAtomicChange currRepl : changes) {
currRepl.apply(document);
}
} finally {
// cleanup
if (rewriteSession != null)
((IDocumentExtension4) document).stopRewriteSession(rewriteSession);
}
}
示例2: setDocumentText
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
* Sets text to a document
* @param document
* @param message
* @param append
* @throws BadLocationException
* Has to be run from non-UI thread
*/
public static synchronized void setDocumentText(final Document document, final String message,
final boolean append) {
UIHelper.runUIAsync(new Runnable() {
public void run() {
try {
DocumentRewriteSession rewriteSession;
if (append && !isDefaultLabel(document)) {
rewriteSession = document.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
// append to existing document (0 length is valid and means message is going to be appended)
document.replace(document.getLength(), 0, message + ((message.endsWith(CR)) ? EMPTY : CR));
} else {
rewriteSession = document.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
// replace of complete document
document.replace(0, document.getLength(), message + ((message.endsWith(CR)) ? EMPTY : CR));
}
document.stopRewriteSession(rewriteSession);
} catch (BadLocationException ignored) {
}
}
});
}
示例3: performEdits
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的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);
}
}
}
示例4: performEdits
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的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);
}
}
}
示例5: startRewriteSession
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType) {
Object lockObject = getLockObject();
if (lockObject == null) {
return super.startRewriteSession(sessionType);
}
synchronized (lockObject) {
return super.startRewriteSession(sessionType);
}
}
示例6: performChangesInSynchronizationContext
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的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);
}
}
示例7: startWrite
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
* Starts a rewrite session (keep things in a single undo/redo)
*/
public static DocumentRewriteSession startWrite(IDocument doc) {
if (doc instanceof IDocumentExtension4) {
IDocumentExtension4 d = (IDocumentExtension4) doc;
return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
}
return null;
}
示例8: TagBasedTLCOutputIncrementalParser
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
public TagBasedTLCOutputIncrementalParser(Model model, int prio, boolean isTraceExplorer, Mode mode, final long size)
{
// create the document
document = new LargeTextStoreDocument(size);
this.analyzer = new TagBasedTLCAnalyzer(document);
this.source = new CachingTLCOutputSource(model, prio);
// set up the partitioner
FastPartitioner partitioner = new FastPartitioner(new TagBasedTLCOutputTokenScanner(),
TagBasedTLCOutputTokenScanner.CONTENT_TYPES);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
// now register the listener, responsible for evaluating the partitioning information
document.addDocumentPartitioningListener(new TLCOutputPartitionChangeListener(mode));
/*
* Register the process source
*
* There are two different source registries, one for trace exploration
* and one for model checking. The source must be added to the
* appropriate registry.
*/
if (isTraceExplorer)
{
TLCOutputSourceRegistry.getTraceExploreSourceRegistry().addTLCOutputSource(this.source);
} else
{
if (mode == Mode.BATCH) {
// TLC always appends to the document. Therefore, we can tell the
// document to use a more efficient rewrite mode which reduces the time
// taken to execute replace operations from minutes and hours to
// seconds.
// Its down side is that the ResultPage is only updated when the
// complete log file is fully parsed, whereas in incremental
// mode, it (potentially) updates after each line.
document.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
}
TLCOutputSourceRegistry.getModelCheckSourceRegistry().addTLCOutputSource(this.source);
}
}
示例9: startRewriteSession
import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
@Override
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType)
throws IllegalStateException {
throw new RuntimeException("not implemented");
}