示例#1
0
 /**
  * This method is called, when the document is saved or when the document and the number of lines
  * are changed.
  *
  * <p>It removes all annotations and creates new.
  *
  * @param createNew true: builds new FSTModel false: only gets new FSTDirectives
  */
 private void updateAnnotations(boolean createNew) {
   if (!annotations.isEmpty()) {
     clear();
   }
   if (createNew) {
     annotatedPositions = new HashMap<Integer, Position>(docLines);
     if (project.getComposer().getGenerationMechanism()
         == Mechanism.FEATURE_ORIENTED_PROGRAMMING) {
       try {
         createFOPAnnotations();
       } catch (BadLocationException e) {
         CorePlugin.getDefault().logError(e);
       }
     } else {
       createDirectiveList();
       createAnnotations();
     }
   } else {
     if (project.getComposer().getGenerationMechanism()
         == Mechanism.FEATURE_ORIENTED_PROGRAMMING) {
       try {
         createFOPAnnotations();
       } catch (BadLocationException e) {
         CorePlugin.getDefault().logError(e);
       }
     }
     if (!directiveMap.isEmpty()) {
       annotatedPositions.clear();
       updateDirectives();
       createAnnotations();
     }
   }
 }
示例#2
0
  /** 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);
            }
          }
        }
      }
    }
  }
 /**
  * This method is called, when the document is saved or when the document and the number of lines
  * are changed.
  *
  * <p>It removes all annotations and creates new.
  *
  * @param createNew true: builds new FSTModel false: only gets new FSTDirectives
  */
 private void updateAnnotations(boolean createNew) {
   if (!annotations.isEmpty()) {
     clear();
   }
   if (createNew) {
     annotatedPositions = new HashMap<Integer, Position>(docLines);
     createDirectiveList();
     createAnnotations();
   } else if (!directiveMap.isEmpty()) {
     annotatedPositions.clear();
     updateDirectives();
     createAnnotations();
   }
 }