private boolean isCaptionLine(Position position, IDocument document, int line) { if (position.getOffset() > -1 && position.getLength() > -1) { try { int captionOffset; if (position instanceof IProjectionPosition) captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document); else captionOffset= 0; int startLine= document.getLineOfOffset(position.getOffset() + captionOffset); return line == startLine; } catch (BadLocationException x) { } } return false; }
/** * Computes the regions that must be collapsed when the given position is * the position of an expanded projection annotation. * * @param position the position * @return the ranges that must be collapsed, or <code>null</code> if * there are none * @since 3.1 */ IRegion[] computeCollapsedRegions(Position position) { try { IDocument document= getDocument(); if (document == null) return null; if (position instanceof IProjectionPosition) { IProjectionPosition projPosition= (IProjectionPosition) position; return projPosition.computeProjectionRegions(document); } int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new IRegion[] {new Region(offset, length)}; return null; } catch (BadLocationException x) { return null; } }
/** * Computes the regions that must be collapsed when the given position is * the position of an expanded projection annotation. * * @param position the position * @return the ranges that must be collapsed, or <code>null</code> if * there are none * @since 3.1 */ IRegion[] computeCollapsedRegions(Position position) { try { IDocument document= getDocument(); if (document == null) return null; if (position instanceof IProjectionPosition) { IProjectionPosition projPosition= (IProjectionPosition) position; return projPosition.computeProjectionRegions(document); } int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new IRegion[] {new Region(offset, length)}; return null; } catch (BadLocationException x) { return null; } }
private boolean isCaptionLine(Position position, IDocument document, int line) { if (position.getOffset() > -1 && position.getLength() > -1) { try { int captionOffset; if (position instanceof IProjectionPosition) captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document); else captionOffset= 0; int startLine= document.getLineOfOffset(position.getOffset() + captionOffset); return line == startLine; } catch (BadLocationException x) { } } return false; }
/** * Computes the collapsed region anchor for the given position. Assuming * that the position is the position of an expanded projection annotation, * the anchor is the region that is still visible after the projection * annotation has been collapsed. * * @param position the position * @return the collapsed region anchor */ public Position computeCollapsedRegionAnchor(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int captionOffset= position.getOffset(); if (position instanceof IProjectionPosition) captionOffset+= ((IProjectionPosition) position).computeCaptionOffset(document); IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); } catch (BadLocationException x) { } return null; }
/** * Computes the collapsed region anchor for the given position. Assuming * that the position is the position of an expanded projection annotation, * the anchor is the region that is still visible after the projection * annotation has been collapsed. * * @param position the position * @return the collapsed region anchor */ public Position computeCollapsedRegionAnchor(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int captionOffset= position.getOffset(); if (position instanceof IProjectionPosition) captionOffset+= ((IProjectionPosition) position).computeCaptionOffset(document); IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); } catch (BadLocationException x) { } return null; }
int captionOffset; if (position instanceof IProjectionPosition) captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document); else captionOffset= 0;
int captionOffset; if (position instanceof IProjectionPosition) captionOffset= ((IProjectionPosition) position).computeCaptionOffset(document); else captionOffset= 0;