/** Creates Annotations for FOP */ private void createFOPAnnotations() throws BadLocationException { AnnotationModelEvent event = new AnnotationModelEvent(this); FSTModel model = project.getFSTModel(); if (model == null) { composer.buildFSTModel(); model = project.getFSTModel(); } if (model == null) { return; } clear(); if (file.getParent() instanceof IFolder) { if (isInBuildFolder((IFolder) file.getParent())) { /* annotations for generated files */ FSTClass clazz = model.getClass(model.getAbsoluteClassName(file)); if (clazz == null) { return; } if (!clazz.hasComposedLines) { clazz.hasComposedLines = true; composer.postCompile(null, file); } for (FSTFeature fstFeature : model.getFeatures()) { FSTRole role = clazz.getRole(fstFeature.getName()); if (role == null) { continue; } for (FSTMethod m : role.getAllMethods()) { createFOPComposedAnnotations(event, fstFeature, m); } for (FSTField f : role.getAllFields()) { createFOPComposedAnnotations(event, fstFeature, f); } } } else { /* annotations for source files */ String featureName = getFeature((IFolder) file.getParent()); if (featureName != null) { FSTFeature fstFeature = model.getFeature(featureName); if (fstFeature != null) { // bar at the left of the editor final int color = fstFeature.getColor(); for (int line = 0; line < document.getNumberOfLines(); line++) { Position position = new Position(document.getLineOffset(line), 1); ColorAnnotation cafh = new ColorAnnotation(color, position, ColorAnnotation.TYPE_IMAGE); cafh.setText(fstFeature.getName()); annotations.add(cafh); event.annotationAdded(cafh); } } } } } }
/** * Creates Annotations for FOP Composed File * * @param event * @param fstFeature * @param m * @throws BadLocationException */ private void createFOPComposedAnnotations( AnnotationModelEvent event, FSTFeature fstFeature, RoleElement<?> m) throws BadLocationException { if (m.getComposedLine() <= 0) { return; } int startline = m.getComposedLine() - 1; int endline = m.getComposedLine() + m.getMethodLength() - 1; int lineOffset = document.getLineOffset(startline); int length = 0; for (int line = startline; line <= endline; line++) { length += document.getLineLength(line); // bar at the left of the editor Position methodposition = new Position(document.getLineOffset(line), document.getLineLength(line)); ColorAnnotation cafh = new ColorAnnotation( m.getRole().getFeature().getColor(), methodposition, ColorAnnotation.TYPE_IMAGE); cafh.setText(m.getRole().getFeature().getName()); annotations.add(cafh); event.annotationAdded(cafh); } Position methodposition = new Position(lineOffset, length); // bar at the right of the editor ColorAnnotation cafho = new ColorAnnotation( m.getRole().getFeature().getColor(), methodposition, ColorAnnotation.TYPE_OVERVIEW); cafho.setText(m.getRole().getFeature().getName()); annotations.add(cafho); event.annotationAdded(cafho); if (highlighting) { // background colors ColorAnnotation cafhh = new ColorAnnotation( m.getRole().getFeature().getColor(), methodposition, ColorAnnotation.TYPE_HIGHLIGHT); cafhh.setText(fstFeature.getName()); annotations.add(cafhh); event.annotationAdded(cafhh); } }