protected ProjectionAnnotation createProjectionAnnotation(boolean isCollapsed, Position foldedRegion) { return new ProjectionAnnotation(isCollapsed); }
/** * 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); } } }
private Image getImage(Display display) { initializeImages(display); return isCollapsed() ? fgCollapsedImage : fgExpandedImage; }
/** * 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 protected boolean skip(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) return !((ProjectionAnnotation) annotation).isCollapsed(); return super.skip(annotation); } }
/** * 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 paint(GC gc, Canvas canvas, Rectangle rectangle) { Image image= getImage(canvas.getDisplay()); if (image != null) { ImageUtilities.drawImage(image, gc, canvas, rectangle, SWT.CENTER, SWT.TOP); if (fIsRangeIndication) { FontMetrics fontMetrics= gc.getFontMetrics(); int delta= (fontMetrics.getHeight() - image.getBounds().height)/2; rectangle.y += delta; rectangle.height -= delta; drawRangeIndication(gc, canvas, rectangle); } } }
@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(); } });
public void markCollapsed() { /* workaround for BUG85874 */ // do not mark collapsed if annotation is not visible if (fIsVisible) { super.markCollapsed(); } } }
private boolean clearCurrentAnnotation() { if (fCurrentAnnotation != null) { fCurrentAnnotation.setRangeIndication(false); fCurrentAnnotation= null; return true; } return false; }
/** * 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 protected boolean skip(Annotation annotation) { if (annotation instanceof ProjectionAnnotation) return !((ProjectionAnnotation) annotation).isCollapsed(); return super.skip(annotation); } }
/** * 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 paint(GC gc, Canvas canvas, Rectangle rectangle) { Image image= getImage(canvas.getDisplay()); if (image != null) { ImageUtilities.drawImage(image, gc, canvas, rectangle, SWT.CENTER, SWT.TOP); if (fIsRangeIndication) { FontMetrics fontMetrics= gc.getFontMetrics(); int delta= (fontMetrics.getHeight() - image.getBounds().height)/2; rectangle.y += delta; rectangle.height -= delta; drawRangeIndication(gc, canvas, rectangle); } } }
@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 boolean clearCurrentAnnotation() { if (fCurrentAnnotation != null) { fCurrentAnnotation.setRangeIndication(false); fCurrentAnnotation= null; return true; } return false; }
public void updateFoldingStructure(List<Position> positions) { final Map<Annotation, Position> newAnnotations = new HashMap<Annotation, Position>(); for (Position position : positions) { newAnnotations.put(new ProjectionAnnotation(), position); } annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null); oldAnnotations = newAnnotations.keySet().toArray(new Annotation[0]); }
/** * 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); } } }
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; }
/** * Expands all annotations that overlap with the given range and are collapsed. Fires a model change event if * requested. * * @param offset the offset of the range * @param length the length of the range * @param fireModelChanged <code>true</code> if a model change event * should be fired, <code>false</code> otherwise * @return <code>true</code> if any annotation has been expanded, <code>false</code> otherwise */ protected boolean expandAll(int offset, int length, boolean fireModelChanged) { boolean expanding= false; Iterator<Annotation> iterator= getAnnotationIterator(); while (iterator.hasNext()) { ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next(); if (annotation.isCollapsed()) { Position position= getPosition(annotation); if (position != null && position.overlapsWith(offset, length) /* || is a delete at the boundary */ ) { annotation.markExpanded(); modifyAnnotation(annotation, false); expanding= true; } } } if (expanding && fireModelChanged) fireModelChanged(); return expanding; }