private void restorePosition() { if (storedPosition != null && !storedPosition.isDeleted() && viewer.getDocument() != null) { viewer.setSelectedRange(storedPosition.offset, storedPosition.length); viewer.revealRange(storedPosition.offset, storedPosition.length); } storedPosition = null; }
/** * @since 2.3 */ protected void selectAndRevealQuickfix(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations, List<ICompletionProposal> completionProposals) { if (completionProposals.isEmpty()) { return; } if (invocationContext instanceof QuickAssistInvocationContext && !((QuickAssistInvocationContext) invocationContext).isSuppressSelection()) { ISourceViewer sourceViewer = invocationContext.getSourceViewer(); IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); Iterator<Annotation> iterator = applicableAnnotations.iterator(); while(iterator.hasNext()){ Position pos = annotationModel.getPosition(iterator.next()); if (pos != null) { sourceViewer.setSelectedRange(pos.getOffset(), pos.getLength()); sourceViewer.revealRange(pos.getOffset(), pos.getLength()); break; } } } }
public void highlightElement(int id) { if (myAnnotations != null && !myAnnotations.isEmpty()) { removeAnnotations(myAnnotations.keySet()); } RutaSelectionParser parser = new RutaSelectionParser(); ISourceModule unit = (ISourceModule) getInputModelElement(); ModuleDeclaration parsed = parser.parse(unit); RutaRuleIdVisitor visitor = new RutaRuleIdVisitor(id); try { parsed.traverse(visitor); } catch (Exception e) { } RutaRule rule = visitor.getResult(); myAnnotations = new HashMap<Annotation, Position>(); if (rule != null) { Annotation annotation = new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null); int sourceStart = rule.sourceStart(); int sourceEnd = rule.sourceEnd(); Position position = new Position(sourceStart, sourceEnd - sourceStart); getSourceViewer().revealRange(sourceStart, sourceEnd - sourceStart); myAnnotations.put(annotation, position); } addAnnotations(myAnnotations); }
public void open(IOutlineNode node, ISourceViewer textViewer) { if (node != null) { ITextRegion textRegion = node.getSignificantTextRegion(); if (textRegion != null && textRegion != ITextRegion.EMPTY_REGION) { int offset = textRegion.getOffset(); int length = textRegion.getLength(); textViewer.setRangeIndication(offset, length, true); textViewer.revealRange(offset, length); textViewer.setSelectedRange(offset, length); } else { node.readOnly(new IUnitOfWork.Void<EObject>() { @Override public void process(EObject state) throws Exception { openEObject(state); } }); } } }
/** * Copied from {@link org.eclipse.ui.texteditor.AbstractTextEditor#selectAndReveal(int, int)} and removed selection * functionality. */ public void reveal(int offset, int length) { if (getSourceViewer() == null) return; StyledText widget = getSourceViewer().getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(offset, length); getSourceViewer().revealRange(offset, length); markInNavigationHistory(); } widget.setRedraw(true); }
IRegion originalSelection= fPreviousSelections.get(0); sourceViewer.setSelectedRange(originalSelection.getOffset(), originalSelection.getLength()); sourceViewer.revealRange(originalSelection.getOffset(), originalSelection.getLength()); initializePreviousSelectionList(); return; sourceViewer.revealRange(targetOffset, direction);
IRegion originalSelection= fPreviousSelections.get(0); sourceViewer.setSelectedRange(originalSelection.getOffset(), originalSelection.getLength()); sourceViewer.revealRange(originalSelection.getOffset(), originalSelection.getLength()); initializePreviousSelectionList(); return; sourceViewer.revealRange(targetOffset, direction);
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.suggestions[fLastCompletion.nextSuggestion]); } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // advance the suggestion state fLastCompletion.advance(); // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.next()); //next() will already advance } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.next()); //next() will already advance } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
/** * Selects and reveals the specified ranges in this text editor. * * @param selectionStart the offset of the selection * @param selectionLength the length of the selection * @param revealStart the offset of the revealed range * @param revealLength the length of the revealed range * @since 3.0 */ protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) { if (fSourceViewer == null) return; ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection= (ITextSelection) selection; if (textSelection.getOffset() != 0 || textSelection.getLength() != 0) markInNavigationHistory(); } StyledText widget= fSourceViewer.getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(revealStart, revealLength); fSourceViewer.revealRange(revealStart, revealLength); fSourceViewer.setSelectedRange(selectionStart, selectionLength); markInNavigationHistory(); } widget.setRedraw(true); }
/** * Selects and reveals the specified ranges in this text editor. * * @param selectionStart the offset of the selection * @param selectionLength the length of the selection * @param revealStart the offset of the revealed range * @param revealLength the length of the revealed range * @since 3.0 */ protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) { if (fSourceViewer == null) return; ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection= (ITextSelection) selection; if (textSelection.getOffset() != 0 || textSelection.getLength() != 0) markInNavigationHistory(); } StyledText widget= fSourceViewer.getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(revealStart, revealLength); fSourceViewer.revealRange(revealStart, revealLength); fSourceViewer.setSelectedRange(selectionStart, selectionLength); markInNavigationHistory(); } widget.setRedraw(true); }
/** * Selects and reveals the specified ranges in this text editor. * * @param selectionStart the offset of the selection * @param selectionLength the length of the selection * @param revealStart the offset of the revealed range * @param revealLength the length of the revealed range * @since 3.0 */ protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) { if (fSourceViewer == null) return; ISelection selection= getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection= (ITextSelection) selection; if (textSelection.getOffset() != 0 || textSelection.getLength() != 0) markInNavigationHistory(); } StyledText widget= fSourceViewer.getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(revealStart, revealLength); fSourceViewer.revealRange(revealStart, revealLength); fSourceViewer.setSelectedRange(selectionStart, selectionLength); markInNavigationHistory(); } widget.setRedraw(true); }
getSourceViewer().revealRange(newCaretOffset, 0);
viewer.revealRange(offset, length); viewer.setSelectedRange(offset, length);
sourceViewer.revealRange(offset, length);
sourceViewer.revealRange(targetOffset, selection.getLength());
sourceViewer.revealRange(targetOffset, selection.getLength());
sourceViewer.revealRange(offset, length); sourceViewer.setSelectedRange(offset, length); } finally {
sourceViewer.revealRange(offset, length); sourceViewer.setSelectedRange(offset, length); } finally {