@Override protected boolean skip(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) return !((ProjectionAnnotation) annotation).isCollapsed(); return super.skip(annotation); } }
@Override protected boolean skip(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) return !((ProjectionAnnotation) annotation).isCollapsed(); return super.skip(annotation); } }
private Image getImage(Display display) { initializeImages(display); return isCollapsed() ? fgCollapsedImage : fgExpandedImage; }
private Image getImage(Display display) { initializeImages(display); return isCollapsed() ? fgCollapsedImage : fgExpandedImage; }
private ProjectionAnnotation[] computeCollapsedNestedAnnotations(int offset, int length) { List<ProjectionAnnotation> annotations= new ArrayList<>(5); Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(offset, length, false, false); while (e.hasNext()) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); if (position == null) { // annotation might already be deleted, we will be informed later on about this deletion continue; } annotations.add(annotation); } } if (annotations.size() > 0) { ProjectionAnnotation[] result= new ProjectionAnnotation[annotations.size()]; annotations.toArray(result); return result; } return null; }
private ProjectionAnnotation[] computeCollapsedNestedAnnotations(int offset, int length) { List<ProjectionAnnotation> annotations= new ArrayList<>(5); Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(offset, length, false, false); while (e.hasNext()) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); if (position == null) { // annotation might already be deleted, we will be informed later on about this deletion continue; } annotations.add(annotation); } } if (annotations.size() > 0) { ProjectionAnnotation[] result= new ProjectionAnnotation[annotations.size()]; annotations.toArray(result); return result; } return null; }
/** * Changes the state of the given annotation to collapsed. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void collapse(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (!projection.isCollapsed()) { projection.markCollapsed(); modifyAnnotation(projection, true); } } }
/** * Changes the state of the given annotation to expanded. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void expand(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (projection.isCollapsed()) { projection.markExpanded(); modifyAnnotation(projection, true); } } }
/** * Changes the state of the given annotation to collapsed. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void collapse(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (!projection.isCollapsed()) { projection.markCollapsed(); modifyAnnotation(projection, true); } } }
/** * Changes the state of the given annotation to expanded. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void expand(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (projection.isCollapsed()) { projection.markExpanded(); modifyAnnotation(projection, true); } } }
@Override public void setRangeIndication(int offset, int length, boolean moveCursor) { IRegion rangeIndication= getRangeIndication(); if (moveCursor && fProjectionAnnotationModel != null && (rangeIndication == null || offset != rangeIndication.getOffset() || length != rangeIndication.getLength())) { List<ProjectionAnnotation> expand= new ArrayList<>(2); // expand the immediate affected collapsed regions Iterator<Annotation> iterator= fProjectionAnnotationModel.getAnnotationIterator(); while (iterator.hasNext()) { ProjectionAnnotation annotation= (ProjectionAnnotation)iterator.next(); if (annotation.isCollapsed() && willAutoExpand(fProjectionAnnotationModel.getPosition(annotation), offset, length)) expand.add(annotation); } if (!expand.isEmpty()) { Iterator<ProjectionAnnotation> e= expand.iterator(); while (e.hasNext()) fProjectionAnnotationModel.expand(e.next()); } } super.setRangeIndication(offset, length, moveCursor); }
/** * Toggles the expansion state of the given annotation. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void toggleExpansionState(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (projection.isCollapsed()) projection.markExpanded(); else projection.markCollapsed(); modifyAnnotation(projection, true); } }
@Override public void setRangeIndication(int offset, int length, boolean moveCursor) { IRegion rangeIndication= getRangeIndication(); if (moveCursor && fProjectionAnnotationModel != null && (rangeIndication == null || offset != rangeIndication.getOffset() || length != rangeIndication.getLength())) { List<ProjectionAnnotation> expand= new ArrayList<>(2); // expand the immediate affected collapsed regions Iterator<Annotation> iterator= fProjectionAnnotationModel.getAnnotationIterator(); while (iterator.hasNext()) { ProjectionAnnotation annotation= (ProjectionAnnotation)iterator.next(); if (annotation.isCollapsed() && willAutoExpand(fProjectionAnnotationModel.getPosition(annotation), offset, length)) expand.add(annotation); } if (!expand.isEmpty()) { Iterator<ProjectionAnnotation> e= expand.iterator(); while (e.hasNext()) fProjectionAnnotationModel.expand(e.next()); } } super.setRangeIndication(offset, length, moveCursor); }
/** * Toggles the expansion state of the given annotation. An appropriate * annotation model change event is sent out. * * @param annotation the annotation */ public void toggleExpansionState(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) { ProjectionAnnotation projection= (ProjectionAnnotation) annotation; if (projection.isCollapsed()) projection.markExpanded(); else projection.markCollapsed(); modifyAnnotation(projection, true); } }
private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, boolean fireRedraw) throws BadLocationException { for (int i= 0; i < removedAnnotations.length; i++) { ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i]; if (annotation.isCollapsed()) { Position expanded= event.getPositionOfRemovedAnnotation(annotation); expand(expanded.getOffset(), expanded.getLength(), fireRedraw); } } }
private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, boolean fireRedraw) throws BadLocationException { for (int i= 0; i < removedAnnotations.length; i++) { ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i]; if (annotation.isCollapsed()) { Position expanded= event.getPositionOfRemovedAnnotation(annotation); expand(expanded.getOffset(), expanded.getLength(), fireRedraw); } } }
@Override public void mouseMove(MouseEvent e) { boolean redraw= false; ProjectionAnnotation annotation= findAnnotation(toDocumentLineNumber(e.y), false); if (annotation != fCurrentAnnotation) { if (fCurrentAnnotation != null) { fCurrentAnnotation.setRangeIndication(false); redraw= true; } fCurrentAnnotation= annotation; if (fCurrentAnnotation != null && !fCurrentAnnotation.isCollapsed()) { fCurrentAnnotation.setRangeIndication(true); redraw= true; } } if (redraw) redraw(); } });
@Override public void mouseMove(MouseEvent e) { boolean redraw= false; ProjectionAnnotation annotation= findAnnotation(toDocumentLineNumber(e.y), false); if (annotation != fCurrentAnnotation) { if (fCurrentAnnotation != null) { fCurrentAnnotation.setRangeIndication(false); redraw= true; } fCurrentAnnotation= annotation; if (fCurrentAnnotation != null && !fCurrentAnnotation.isCollapsed()) { fCurrentAnnotation.setRangeIndication(true); redraw= true; } } if (redraw) redraw(); } });
private void processChanges(Annotation[] annotations, boolean fireRedraw, List<Position> coverage) throws BadLocationException { for (int i= 0; i < annotations.length; i++) { ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i]; Position position= fProjectionAnnotationModel.getPosition(annotation); if (position == null) continue; if (!covers(coverage, position)) { if (annotation.isCollapsed()) { coverage.add(position); IRegion[] regions= computeCollapsedRegions(position); if (regions != null) for (int j= 0; j < regions.length; j++) collapse(regions[j].getOffset(), regions[j].getLength(), fireRedraw); } else { expand(position.getOffset(), position.getLength(), fireRedraw); } } } }
private void processChanges(Annotation[] annotations, boolean fireRedraw, List<Position> coverage) throws BadLocationException { for (int i= 0; i < annotations.length; i++) { ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i]; Position position= fProjectionAnnotationModel.getPosition(annotation); if (position == null) continue; if (!covers(coverage, position)) { if (annotation.isCollapsed()) { coverage.add(position); IRegion[] regions= computeCollapsedRegions(position); if (regions != null) for (int j= 0; j < regions.length; j++) collapse(regions[j].getOffset(), regions[j].getLength(), fireRedraw); } else { expand(position.getOffset(), position.getLength(), fireRedraw); } } } }