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


Java IDocumentUndoManager.endCompoundChange方法代码示例

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


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

示例1: applyEdits

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
/**
 * Method will apply all edits to document as single modification. Needs to
 * be executed in UI thread.
 *
 * @param document
 *            document to modify
 * @param edits
 *            list of LSP TextEdits
 */
public static void applyEdits(IDocument document, TextEdit edit) {
	if (document == null) {
		return;
	}

	IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	if (manager != null) {
		manager.beginCompoundChange();
	}
	try {
		RewriteSessionEditProcessor editProcessor = new RewriteSessionEditProcessor(document, edit,
				org.eclipse.text.edits.TextEdit.NONE);
		editProcessor.performEdits();
	} catch (MalformedTreeException | BadLocationException e) {
		EditorConfigPlugin.logError(e);
	}
	if (manager != null) {
		manager.endCompoundChange();
	}
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:30,代码来源:MarkerUtils.java

示例2: removeComment

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
private void removeComment(IDocument doc, int offset) {
	try {
		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();

		ITypedRegion par = TextUtilities.getPartition(doc, Partitions.MK_PARTITIONING, offset, false);
		int beg = par.getOffset();
		int len = par.getLength();

		String comment = doc.get(beg, len);
		int eLen = markerLen(comment);
		int bLen = eLen + 1;

		MultiTextEdit edit = new MultiTextEdit();
		edit.addChild(new DeleteEdit(beg, bLen));
		edit.addChild(new DeleteEdit(beg + len - eLen, eLen));
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure removing comment " + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:23,代码来源:ToggleHiddenCommentHandler.java

示例3: applyEdits

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
/**
 * Method will apply all edits to document as single modification. Needs to
 * be executed in UI thread.
 * 
 * @param document
 *            document to modify
 * @param edits
 *            list of TypeScript {@link CodeEdit}.
 * @throws TypeScriptException
 * @throws BadLocationException
 * @throws MalformedTreeException
 */
public static void applyEdits(IDocument document, List<CodeEdit> codeEdits)
		throws TypeScriptException, MalformedTreeException, BadLocationException {
	if (document == null || codeEdits.isEmpty()) {
		return;
	}

	IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	if (manager != null) {
		manager.beginCompoundChange();
	}

	try {
		TextEdit edit = toTextEdit(codeEdits, document);
		// RewriteSessionEditProcessor editProcessor = new
		// RewriteSessionEditProcessor(document, edit,
		// org.eclipse.text.edits.TextEdit.NONE);
		// editProcessor.performEdits();
		edit.apply(document);
	} finally {
		if (manager != null) {
			manager.endCompoundChange();
		}
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:37,代码来源:DocumentUtils.java

示例4: replaceAll

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
/**
 * Replace all occurrences
 */
private void replaceAll() {
	boolean allState = isReplaceAll(); 
	IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(getDocument());
	try {
		paused = false;
		setReplaceAll(true);	// force flag so we don't re-enter the undoer during case replacement
		if (undoer != null) {
			undoer.beginCompoundChange();
		}
		replaceIt();
		while (findNext(getSearchStr())){
			replaceIt();
		}
	} finally {
		setReplaceAll(allState);
		if (undoer != null) {
			undoer.endCompoundChange();
		}
	}
	finish();
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:25,代码来源:SearchReplaceMinibuffer.java

示例5: format

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
public static void format(FluentMkEditor editor, ITextSelection sel) {
	IDocument doc = editor.getDocument();
	if (doc == null || doc.getLength() == 0) return;
	docLength = doc.getLength();

	IPreferenceStore store = editor.getPrefsStore();
	cols = store.getInt(Prefs.EDITOR_FORMATTING_COLUMN);
	tabWidth = store.getInt(Prefs.EDITOR_TAB_WIDTH);

	try {
		PageRoot model = editor.getPageModel();
		List<PagePart> parts = model.getPageParts();
		if (sel != null && sel.getLength() > 0) {
			parts = selectedParts(model, sel);
		}

		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();
		TextEdit edit = new MultiTextEdit();
		for (PagePart part : parts) {
			formatPagePart(part, edit);
		}
		edit.apply(editor.getDocument());
		undoMgr.endCompoundChange();
	} catch (Exception ex) {
		Log.error("Bad location error occurred during formatting", ex);
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:29,代码来源:MkFormatter.java

示例6: remove

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
private void remove(int beg, int len, int markLen) {
	try {
		IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
		undoMgr.beginCompoundChange();

		MultiTextEdit edit = new MultiTextEdit();
		edit.addChild(new DeleteEdit(beg - markLen, markLen));
		edit.addChild(new DeleteEdit(beg + len, markLen));
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure removing mark" + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:15,代码来源:AbstractMarksHandler.java

示例7: addComment

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
private void addComment(IDocument doc, int beg, int len) {
	IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
	undoMgr.beginCompoundChange();

	MultiTextEdit edit = new MultiTextEdit();
	edit.addChild(new InsertEdit(beg, getCommentBeg()));
	edit.addChild(new InsertEdit(beg + len, getCommentEnd()));
	try {
		edit.apply(doc);
		undoMgr.endCompoundChange();
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure creating comment " + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:15,代码来源:ToggleHiddenCommentHandler.java

示例8: caseReplace

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
/**
 * Case-based replacement - after the initial find has already happened
 * 
 * @param replacer - the replacement string (may be regexp)
 * @param index - offset of find
 * @param all - all if true, else initial
 * @return - the replacement region
 * 
 * @throws BadLocationException
 */
private IRegion caseReplace(String replacer, int index, boolean all) throws BadLocationException {
	IRegion result = null;
	IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(getDocument());
	try {
		if (!isReplaceAll() && undoer != null) {
			undoer.beginCompoundChange();
		}
		IFindReplaceTarget target = getTarget();
		// first replace with (possible regexp) string
		((IFindReplaceTargetExtension3)target).replaceSelection(replacer, isRegexp());
		// adjust case of actual replacement string
		replacer = target.getSelectionText();
		String caseReplacer = replacer;
		if (all) {
			caseReplacer = caseReplacer.toUpperCase();
		} else {
			caseReplacer = caseReplacer.trim();
			caseReplacer = Character.toUpperCase(caseReplacer.charAt(0)) + 
			caseReplacer.substring(1,caseReplacer.length()).toString();
			// now update the replacement string with the re-cased part
			caseReplacer = replacer.replaceFirst(replacer.trim(), caseReplacer);
		}
		int ind = target.findAndSelect(index, replacer, true, false, false);
		if (ind > -1) {
			target.replaceSelection(caseReplacer);
		}
	}  finally {
		if (!isReplaceAll() && undoer != null) {
			undoer.endCompoundChange();
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:44,代码来源:SearchReplaceMinibuffer.java

示例9: toggle

import org.eclipse.text.undo.IDocumentUndoManager; //导入方法依赖的package包/类
private void toggle(int beg, int len) {
	// if surrounded by marks, remove them
	String mark = isMarked(beg, len);
	if (qualified(mark)) {
		remove(beg, len, mark.length());
		return;
	}

	if (mark == null || mark.charAt(0) == markSpec[1].charAt(0)) {
		mark = markSpec[0];
	} else {
		mark = markSpec[1];
	}

	// add surrounding marks
	IDocumentUndoManager undoMgr = DocumentUndoManagerRegistry.getDocumentUndoManager(doc);
	undoMgr.beginCompoundChange();
	MultiTextEdit edit = new MultiTextEdit();
	edit.addChild(new InsertEdit(beg, mark));
	edit.addChild(new InsertEdit(beg + len, mark));

	// // remove any included marks
	// if (len > 0) {
	// try {
	// String text = doc.get(beg, len);
	// Pattern srch = Pattern.compile(Pattern.quote(markSpec[0]));
	// Matcher matcher = srch.matcher(text);
	// while (matcher.find()) {
	// int start = matcher.start();
	// int stop = matcher.end();
	// edit.addChild(new DeleteEdit(beg + start, stop - start + 1));
	// }
	// } catch (MalformedTreeException | BadLocationException e) {}
	// }

	try {
		edit.apply(doc);
		undoMgr.endCompoundChange();
		editor.setCursorOffset(cpos + markSpec[0].length());
	} catch (MalformedTreeException | BadLocationException e) {
		Log.error("Failure applying mark" + e.getMessage());
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:44,代码来源:AbstractMarksHandler.java


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