org.eclipse.jface.text.ITextSelection#equals ( )源码实例Demo

下面列出了org.eclipse.jface.text.ITextSelection#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: e4macs   文件: ExecuteCommandHandler.java
/**
 * Call execute on checkers with an additional listener for selection change during execution
 *  
 * @param editor
 * @param checkers
 */
protected void executeWithSelectionCheck(final ITextEditor editor, IWithSelectionCheck checkers) {

	ISelectionChangedListener listener = new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			ExecuteCommandHandler.this.showResultMessage(editor);
			removeListener(event.getSelectionProvider(),this);
		}
	};
	ITextSelection before = getCurrentSelection(editor);
	try {
		addListener(editor.getSelectionProvider(),listener);
		checkers.execute();
	} finally {
		if (before.equals(getCurrentSelection(editor))) {
			// remove it if the selection did not change
			removeListener(editor.getSelectionProvider(),listener);
		}
	}
}
 
源代码2 项目: e4macs   文件: BackwardUpListHandler.java
/**
 * Find the next matching bracket
 * 
 * @param document
 * @param selection
 * @return The bracketed region or null
 * @throws BadLocationException
 */
private IRegion matchBracket(IDocument document, ITextSelection selection, int endList) throws BadLocationException {
	
	if (selection == null) {
		return null;
	}
	
	int offset = selection.getOffset();
	if (isOpen(document.getChar(offset))) {
		// go to the end and check that it is past the initial ending
		IRegion end = getBracketMatch(document,offset+1);

		if (end == null) {
			return null;
		} else {
			offset = end.getOffset();
			if (offset + end.getLength() < endList) {
				if (--offset > -1) {
					// back up and recurse 
					return matchBracket(document,new TextSelection(document,offset,0),endList);
				} else {
					return null;
				}
			} else {
				return end;
			}
		}
	} else if (offset - 1 > 0 && isClose(document.getChar(offset-1))) {
		// if at the end of a sub-list, jump to the beginning and recurse
		IRegion begin = getBracketMatch(document,offset);
		return matchBracket(document,new TextSelection(document,begin.getOffset(),0),endList);
	} 			
	ITextSelection nextSexp = getNextSexp(document, selection,false,UP);
	if (selection.equals(nextSexp)) { 
		return null;
	}
	// if neither begin or end, look backward for next one and recurse
	return matchBracket(document,nextSexp,endList);
}
 
源代码3 项目: e4macs   文件: SexpHandler.java
@Override
protected ITextSelection getCmdSelection(ITextEditor editor,
		ITextSelection selection) throws ExecutionException {
	ITextSelection cSelection = getCurrentSelection(editor);
	if (!cSelection.equals(selection)) {
		return cSelection;
	} else {
		return super.getCmdSelection(editor, selection);
	}
}
 
源代码4 项目: e4macs   文件: EmacsMovementHandler.java
@Override
protected ITextSelection getCmdSelection(ITextEditor editor,
		ITextSelection selection) throws ExecutionException {
	ITextSelection cSelection = getCurrentSelection(editor);
	if (!cSelection.equals(selection)) {
		return cSelection;
	} else {
		return super.getCmdSelection(editor, selection);
	}
}