@Override public void setRangeIndication(int start, int length, boolean moveCursor) { if (moveCursor) { setSelectedRange(start, 0); revealRange(start, length); } if (fRangeIndicator != null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); } }
@Override public void setRangeIndication(int start, int length, boolean moveCursor) { if (moveCursor) { setSelectedRange(start, 0); revealRange(start, length); } if (fRangeIndicator != null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); } }
public void setSelection(Position position) { if (position != null) getSourceViewer().setSelectedRange(position.getOffset(), position.getLength()); }
private void handlePropertySelection() { Object selection = fPropertiesViewer.getStructuredSelection().getFirstElement(); if (selection instanceof ModelChangeElement && fSourceViewer.getDocument() != null) { ModelChangeElement element = (ModelChangeElement) selection; int offset = element.getOffset(); int length = element.getLength(); fSourceViewer.setSelectedRange(offset, length); fSourceViewer.revealRange(offset, length); } }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
private void updateSourceView(IStructuredSelection selection) { NLSSubstitution first= (NLSSubstitution) selection.getFirstElement(); if (first != null) { Region region= first.getNLSElement().getPosition(); fSourceViewer.setSelectedRange(region.getOffset(), region.getLength()); fSourceViewer.revealRange(region.getOffset(), region.getLength()); } }
/** * Sets the input of the source viewer to the given document and reveals the * region determined by the given parameter region. * * @param document the document to present * @param region the region to reveal. */ protected void setInput(IDocument document, IRegion region) { Control ctrl= getControl(); if (ctrl != null && ctrl.isDisposed()) ctrl= null; try { if (ctrl != null) ctrl.setRedraw(false); fSourceViewer.setInput(document); if (region != null && document != null) { int offset= region.getOffset(); int length= region.getLength(); if (offset >= 0 && length >= 0) { fSourceViewer.setSelectedRange(offset, length); fSourceViewer.revealRange(offset, length); } } } finally { if (ctrl != null) ctrl.setRedraw(true); } }
/** * Restores a previously saved selection in the document. * <p> * If no selection was previously saved, nothing happens. * * @since 3.0 */ protected void restoreSelection() { if (!fSelections.isEmpty()) { final IDocument document= getDocument(); final Position position= fSelections.pop(); try { document.removePosition(fSelectionCategory, position); Point currentSelection= getSelectedRange(); if (currentSelection == null || currentSelection.x != position.getOffset() || currentSelection.y != position.getLength()) { if (position instanceof ColumnPosition && getTextWidget().getBlockSelection()) { setSelection(new BlockTextSelection(document, document.getLineOfOffset(position.getOffset()), ((ColumnPosition) position).fStartColumn, document.getLineOfOffset(position.getOffset() + position.getLength()), ((ColumnPosition) position).fEndColumn, getTextWidget().getTabs())); } else { setSelectedRange(position.getOffset(), position.getLength()); } } if (fSelections.isEmpty()) clearRememberedSelection(); } catch (BadPositionCategoryException exception) { // Should not happen } catch (BadLocationException x) { // Should not happen } } }
/** * Restores a previously saved selection in the document. * <p> * If no selection was previously saved, nothing happens. * * @since 3.0 */ protected void restoreSelection() { if (!fSelections.isEmpty()) { final IDocument document= getDocument(); final Position position= fSelections.pop(); try { document.removePosition(fSelectionCategory, position); Point currentSelection= getSelectedRange(); if (currentSelection == null || currentSelection.x != position.getOffset() || currentSelection.y != position.getLength()) { if (position instanceof ColumnPosition && getTextWidget().getBlockSelection()) { setSelection(new BlockTextSelection(document, document.getLineOfOffset(position.getOffset()), ((ColumnPosition) position).fStartColumn, document.getLineOfOffset(position.getOffset() + position.getLength()), ((ColumnPosition) position).fEndColumn, getTextWidget().getTabs())); } else { setSelectedRange(position.getOffset(), position.getLength()); } } if (fSelections.isEmpty()) clearRememberedSelection(); } catch (BadPositionCategoryException exception) { // Should not happen } catch (BadLocationException x) { // Should not happen } } }
private void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) { ISelection selection = getSelectionProvider().getSelection(); if (selection instanceof ITextSelection) { ITextSelection textSelection = (ITextSelection) selection; if (textSelection.getOffset() != 0 || textSelection.getLength() != 0) markInNavigationHistory(); } StyledText widget= MergeSourceViewer.this.getSourceViewer().getTextWidget(); widget.setRedraw(false); { adjustHighlightRange(revealStart, revealLength); MergeSourceViewer.this.getSourceViewer().revealRange(revealStart, revealLength); MergeSourceViewer.this.getSourceViewer().setSelectedRange(selectionStart, selectionLength); markInNavigationHistory(); } widget.setRedraw(true); }
private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }
/** * Sets the font for this viewer sustaining selection and scroll position. */ private void setViewerFont() { Font font= JFaceResources.getFont(SYMBOLIC_FONT_NAME); if (fViewer.getDocument() != null) { Point selection= fViewer.getSelectedRange(); int topIndex= fViewer.getTopIndex(); StyledText styledText= fViewer.getTextWidget(); Control parent= fViewer.getControl(); parent.setRedraw(false); styledText.setFont(font); fViewer.setSelectedRange(selection.x , selection.y); fViewer.setTopIndex(topIndex); if (parent instanceof Composite) { Composite composite= (Composite) parent; composite.layout(true); } parent.setRedraw(true); } else { StyledText styledText= fViewer.getTextWidget(); styledText.setFont(font); } }
private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }
private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }
/** * Sets the font for this viewer sustaining selection and scroll position. */ private void setViewerFont() { Font font= JFaceResources.getFont(SYMBOLIC_FONT_NAME); if (fViewer.getDocument() != null) { Point selection= fViewer.getSelectedRange(); int topIndex= fViewer.getTopIndex(); StyledText styledText= fViewer.getTextWidget(); Control parent= fViewer.getControl(); parent.setRedraw(false); styledText.setFont(font); fViewer.setSelectedRange(selection.x , selection.y); fViewer.setTopIndex(topIndex); if (parent instanceof Composite) { Composite composite= (Composite) parent; composite.layout(true); } parent.setRedraw(true); } else { StyledText styledText= fViewer.getTextWidget(); styledText.setFont(font); } }
/** * Sets the font for this viewer sustaining selection and scroll position. */ private void setViewerFont() { Font font= JFaceResources.getFont(SYMBOLIC_FONT_NAME); if (fViewer.getDocument() != null) { Point selection= fViewer.getSelectedRange(); int topIndex= fViewer.getTopIndex(); StyledText styledText= fViewer.getTextWidget(); Control parent= fViewer.getControl(); parent.setRedraw(false); styledText.setFont(font); fViewer.setSelectedRange(selection.x , selection.y); fViewer.setTopIndex(topIndex); if (parent instanceof Composite) { Composite composite= (Composite) parent; composite.layout(true); } parent.setRedraw(true); } else { StyledText styledText= fViewer.getTextWidget(); styledText.setFont(font); } }
private void setViewerFont() { Font font = getFont(getViewerFontName()); SourceViewer viewer = getSourceViewer(); if (viewer.getDocument() != null) { Point selection = viewer.getSelectedRange(); int topIndex = viewer.getTopIndex(); StyledText styledText = viewer.getTextWidget(); Control parent = viewer.getControl(); parent.setRedraw(false); styledText.setFont(font); viewer.setSelectedRange(selection.x, selection.y); viewer.setTopIndex(topIndex); if (parent instanceof Composite) { Composite composite = (Composite) parent; composite.layout(true); } parent.setRedraw(true); } else { StyledText styledText = viewer.getTextWidget(); styledText.setFont(font); } }