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


Java LinkedPosition类代码示例

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


LinkedPosition类属于org.eclipse.jface.text.link包,在下文中一共展示了LinkedPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: controlUndoBehavior

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
private boolean controlUndoBehavior(int offset, int length) {
	LinkedPosition position = fModel.findPosition(new LinkedPosition(fCurrentTarget.getViewer().getDocument(),
			offset, length, LinkedPositionGroup.NO_STOP));
	if (position != null) {

		// if the last position is not the same and there is an open
		// change: close it.
		if (!position.equals(fPreviousPosition))
			endCompoundChangeIfNeeded();

		beginCompoundChangeIfNeeded();
	}

	fPreviousPosition = position;
	return fPreviousPosition != null;
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:TweakedLinkedModeUI.java

示例2: selectionChanged

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
public void selectionChanged(SelectionChangedEvent event) {
	ISelection selection = event.getSelection();
	if (selection instanceof ITextSelection) {
		ITextSelection textsel = (ITextSelection) selection;
		if (event.getSelectionProvider() instanceof ITextViewer) {
			IDocument doc = ((ITextViewer) event.getSelectionProvider()).getDocument();
			if (doc != null) {
				int offset = textsel.getOffset();
				int length = textsel.getLength();
				if (offset >= 0 && length >= 0) {
					LinkedPosition find = new LinkedPosition(doc, offset, length, LinkedPositionGroup.NO_STOP);
					LinkedPosition pos = fModel.findPosition(find);
					if (pos == null && fExitPosition != null && fExitPosition.includes(find))
						pos = fExitPosition;

					if (pos != null)
						switchPosition(pos, false, false);
				}
			}
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:23,代码来源:TweakedLinkedModeUI.java

示例3: enter

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
/**
 * Starts this UI at position p.
 * 
 * @throws BadLocationException
 *             if p does not exist in the underlying model
 */
public void enter(Position p) throws BadLocationException {
	if (p == null)
		enter();
	else {
		init();

		LinkedPosition initFramePosition = null;
		while (fFramePosition != p) {
			if (initFramePosition == null)
				initFramePosition = fFramePosition;
			next();
			if (foundNotwhere(p, initFramePosition))
				throw new BadLocationException();
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:23,代码来源:TweakedLinkedModeUI.java

示例4: switchViewer

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
private void switchViewer(IDocument oldDoc, IDocument newDoc, LinkedPosition pos) {
	if (oldDoc != newDoc) {

		// redraw current document with new position before switching viewer
		if (fCurrentTarget.fAnnotationModel != null)
			fCurrentTarget.fAnnotationModel.switchToPosition(fModel, pos);

		LinkedModeUITarget target = null;
		for (int i = 0; i < fTargets.length; i++) {
			if (fTargets[i].getViewer().getDocument() == newDoc) {
				target = fTargets[i];
				break;
			}
		}
		if (target != fCurrentTarget) {
			disconnect();
			fCurrentTarget = target;
			target.linkingFocusLost(fFramePosition, target);
			connect();
			ensureAnnotationModelInstalled();
			if (fCurrentTarget != null)
				fCurrentTarget.linkingFocusGained(pos, fCurrentTarget);
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:26,代码来源:TweakedLinkedModeUI.java

示例5: doExit

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
	if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
		LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
		if (position != null) {
			if (event.character == SWT.BS) {
				if (offset - 1 < position.getOffset()) {
					//skip backspace at beginning of linked position
					event.doit= false;
				}
			} else /* event.character == SWT.DEL */ {
				if (offset + 1 > position.getOffset() + position.getLength()) {
					//skip delete at end of linked position
					event.doit= false;
				}
			}
		}
	}

	return null; // don't change behavior
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:22,代码来源:LinkedNamesAssistProposal.java

示例6: setUpLinkedMode

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
/**
	 * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will
	 * exit the mode when <code>closingCharacter</code> is typed and an exit position at
	 * <code>getCursorPosition() + 1</code>.
	 *
	 * @param document the document
	 */
	protected void setUpLinkedMode(IDocument document) {
		try {
			LinkedPositionGroup group= new LinkedPositionGroup();
			group.addPosition(new LinkedPosition(document, getSelectionStart(), getSelectionLength(), LinkedPositionGroup.NO_STOP));

			LinkedModeModel model= new LinkedModeModel();
			model.addGroup(group);
			model.forceInstall();

			LinkedModeUI ui= new LinkedModeUI(model, viewer);
//			ui.setSimpleMode(true);
			ui.setExitPolicy(new ExitPolicy(exitChars));
			ui.setExitPosition(viewer, getCursorPosition() + getReplacementOffset(), 0, Integer.MAX_VALUE);
			ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
			ui.enter();
		} catch (BadLocationException e) {
			log.info(e.getMessage(), e);
		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:ConfigurableCompletionProposal.java

示例7: doExit

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
	showPreview = (event.stateMask & SWT.CTRL) != 0 && (event.character == SWT.CR || event.character == SWT.LF);
	if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
		LinkedPosition position = model.findPosition(new LinkedPosition(document, offset, 0,
				LinkedPositionGroup.NO_STOP));
		if (position != null) {
			if (event.character == SWT.BS) {
				if (offset - 1 < position.getOffset()) {
					// skip backspace at beginning of linked position
					event.doit = false;
				}
			} else /* event.character == SWT.DEL */{
				if (offset + 1 > position.getOffset() + position.getLength()) {
					// skip delete at end of linked position
					event.doit = false;
				}
			}
		}
	}
	return null; // don't change behavior
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:RenameLinkedMode.java

示例8: computePopupLocation

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
protected Point computePopupLocation() {
	if (popup == null || popup.isDisposed())
		return null;

	LinkedPosition position = renameLinkedMode.getCurrentLinkedPosition();
	if (position == null)
		return null;
	ISourceViewer viewer = editor.getInternalSourceViewer();
	ITextViewerExtension5 viewer5 = (ITextViewerExtension5) viewer;
	int widgetOffset = viewer5.modelOffset2WidgetOffset(position.offset);

	StyledText textWidget = viewer.getTextWidget();
	Point pos = textWidget.getLocationAtOffset(widgetOffset);
	Point pSize = getExtent();
	pSize.y += HAH + 1;
	pos.x -= HAO;
	pos.y += textWidget.getLineHeight(widgetOffset);
	Point dPos = textWidget.toDisplay(pos);
	Rectangle displayBounds = textWidget.getDisplay().getClientArea();
	Rectangle dPopupRect = Geometry.createRectangle(dPos, pSize);
	Geometry.moveInside(dPopupRect, displayBounds);
	return new Point(dPopupRect.x, dPopupRect.y);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:RenameRefactoringPopup.java

示例9: sortPositions

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
protected Iterable<LinkedPosition> sortPositions(Iterable<LinkedPosition> linkedPositions,
		final int invocationOffset) {
	Comparator<LinkedPosition> comparator = new Comparator<LinkedPosition>() {

		public int compare(LinkedPosition left, LinkedPosition right) {
			return rank(left) - rank(right);
		}

		private int rank(LinkedPosition o1) {
			int relativeRank = o1.getOffset() + o1.length - invocationOffset;
			if (relativeRank < 0)
				return Integer.MAX_VALUE + relativeRank;
			else
				return relativeRank;
		}
	};
	return ImmutableSortedSet.copyOf(comparator, linkedPositions);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:DefaultLinkedPositionGroupCalculator.java

示例10: setUpLinkedMode

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
/**
 * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will
 * exit the mode when <code>closingCharacter</code> is typed and an exit position at
 * <code>getCursorPosition() + 1</code>.
 *
 * @param document the document
 * @param closingCharacter the exit character
 */
protected void setUpLinkedMode(IDocument document, char closingCharacter) {
	if (getTextViewer() != null && autocloseBrackets()) {
		int offset= getReplacementOffset() + getCursorPosition();
		int exit= getReplacementOffset() + getReplacementString().length();
		try {
			LinkedPositionGroup group= new LinkedPositionGroup();
			group.addPosition(new LinkedPosition(document, offset, 0, LinkedPositionGroup.NO_STOP));

			LinkedModeModel model= new LinkedModeModel();
			model.addGroup(group);
			model.forceInstall();

			LinkedModeUI ui= new EditorLinkedModeUI(model, getTextViewer());
			ui.setSimpleMode(true);
			ui.setExitPolicy(new ExitPolicy(closingCharacter, document));
			ui.setExitPosition(getTextViewer(), exit, 0, Integer.MAX_VALUE);
			ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
			ui.enter();
		} catch (BadLocationException x) {
			JavaPlugin.log(x);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:AbstractJavaCompletionProposal.java

示例11: doExit

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
	if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
		LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
		if (position != null) {
			if (event.character == SWT.BS) {
				if (offset - 1 < position.getOffset()) {
					//skip backspace at beginning of linked position
					event.doit= false;
				}
			} else /* event.character == SWT.DEL */ {
				if (offset + 1 > position.getOffset() + position.getLength()) {
					//skip delete at end of linked position
					event.doit= false;
				}
			}
		}
	}

	return null; // don't change behavior
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:LinkedNamesAssistProposal.java

示例12: startLinkedEdit

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
private void startLinkedEdit(List<IRegion> selections, ITextViewer viewer, Point originalSelection)
		throws BadLocationException {
	final LinkedPositionGroup linkedPositionGroup = new LinkedPositionGroup();
	for (IRegion selection : selections) {
		linkedPositionGroup.addPosition(new LinkedPosition(viewer.getDocument(), selection.getOffset(), selection
				.getLength()));
	}

	LinkedModeModel model = new LinkedModeModel();
	model.addGroup(linkedPositionGroup);
	model.forceInstall();
	//FIXME can add a listener here to listen for the end of linked mode
	//model.addLinkingListener(null);

	LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
	ui.setExitPolicy(new DeleteBlockingExitPolicy(viewer.getDocument()));
	ui.enter();

	// by default the text being edited is selected so restore original selection
	viewer.setSelectedRange(originalSelection.x, originalSelection.y);
}
 
开发者ID:caspark,项目名称:eclipse-multicursor,代码行数:22,代码来源:SelectNextOccurrenceHandler.java

示例13: getLinkedModeModel

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
protected LinkedModeModel getLinkedModeModel(ITextViewer viewer) throws BadLocationException {
	Indexable<SourceRange> sourceSubElements = proposal.getSourceSubElements();
	if(sourceSubElements == null || sourceSubElements.isEmpty()) {
		return null;
	}
	
	LinkedModeModel model = new LinkedModeModel();
	
	IDocument document = viewer.getDocument();
	int replaceOffset = getReplaceOffset();
	
	firstLinkedModeGroupPosition = -1;
	
	for (SourceRange sr : sourceSubElements) {
		LinkedPositionGroup group = new LinkedPositionGroup();
		int posOffset = replaceOffset + sr.getOffset();
		group.addPosition(new LinkedPosition(document, posOffset, sr.getLength()));
		if(firstLinkedModeGroupPosition == -1) {
			firstLinkedModeGroupPosition = posOffset;
		}
		model.addGroup(group);
	}
	
	return model;
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:26,代码来源:LangCompletionProposal.java

示例14: prune

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
/**
 * Prune <code>list</code> of all <code>LinkedPosition</code>s that
 * do not belong to this model's <code>IDocument</code>.
 *
 * @param list the list of positions to prune
 */
private void prune(List list) {
	for (Iterator iter= list.iterator(); iter.hasNext();) {
		LinkedPosition pos= (LinkedPosition) iter.next();
		if (!pos.getDocument().equals(fDocument))
			iter.remove();
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:14,代码来源:LinkedPositionAnnotations.java

示例15: switchPosition

import org.eclipse.jface.text.link.LinkedPosition; //导入依赖的package包/类
private void switchPosition(LinkedPosition pos, boolean select, boolean showProposals) {
	Assert.isNotNull(pos);
	if (pos.equals(fFramePosition))
		return;

	if (fFramePosition != null && fCurrentTarget != null)
		fPositionListener.linkingFocusLost(fFramePosition, fCurrentTarget);

	// undo
	endCompoundChangeIfNeeded();

	redraw(); // redraw current position being left - usually not needed
	IDocument oldDoc = fFramePosition == null ? null : fFramePosition.getDocument();
	IDocument newDoc = pos.getDocument();

	switchViewer(oldDoc, newDoc, pos);
	fFramePosition = pos;

	if (select)
		select();
	if (fFramePosition == fExitPosition && !fIterator.isCycling())
		leave(ILinkedModeListener.NONE);
	else {
		redraw(); // redraw new position
		ensureAnnotationModelInstalled();
	}
	if (showProposals)
		triggerContentAssist();
	if (fFramePosition != fExitPosition && fDoContextInfo)
		triggerContextInfo();

	if (fFramePosition != null && fCurrentTarget != null)
		fPositionListener.linkingFocusGained(fFramePosition, fCurrentTarget);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:36,代码来源:TweakedLinkedModeUI.java


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