// Is called under synchronized (breakpointToAnnotations)
 private void addAnnotationTo(VisageLineBreakpoint b, FileObject fo) {
   int[] lines = getAnnotationLines(b, fo);
   if (lines == null || lines.length == 0) {
     return;
   }
   String condition;
   if (b instanceof VisageLineBreakpoint) {
     condition = ((VisageLineBreakpoint) b).getCondition();
     //        } else if (b instanceof FieldBreakpoint) {
     //            condition = ((FieldBreakpoint) b).getCondition();
     //        } else if (b instanceof MethodBreakpoint) {
     //            condition = ((MethodBreakpoint) b).getCondition();
   } else {
     throw new IllegalStateException(b.toString());
   }
   boolean isConditional = (condition != null) && condition.trim().length() > 0;
   String annotationType = getAnnotationType(b, isConditional);
   DataObject dataObject;
   try {
     dataObject = DataObject.find(fo);
   } catch (DataObjectNotFoundException donfex) {
     donfex.printStackTrace();
     return;
   }
   LineCookie lc = dataObject.getCookie(LineCookie.class);
   if (lc == null) return;
   List<DebuggerBreakpointAnnotation> annotations = new ArrayList<DebuggerBreakpointAnnotation>();
   for (int l : lines) {
     try {
       Line line = lc.getLineSet().getCurrent(l - 1);
       DebuggerBreakpointAnnotation annotation =
           new DebuggerBreakpointAnnotation(annotationType, line, b.getLineBreakpoint());
       annotations.add(annotation);
     } catch (IndexOutOfBoundsException e) {
     } catch (IllegalArgumentException e) {
     }
   }
   if (annotations.size() == 0) {
     return;
   }
   Set<Annotation> bpAnnotations = breakpointToAnnotations.get(b);
   if (bpAnnotations == null) {
     breakpointToAnnotations.put(b, new WeakSet<Annotation>(annotations));
   } else {
     bpAnnotations.addAll(annotations);
     breakpointToAnnotations.put(b, bpAnnotations);
   }
 }
Esempio n. 2
0
  public static void saveCasa(JbiProject project) {
    // System.out.println("CasaHelper.saveCasa()  (" + Thread.currentThread().getName()  + ")");

    FileObject casaFO = getCasaFileObject(project, false);
    if (casaFO != null) {
      try {
        DataObject casaDO = DataObject.find(casaFO);

        SaveCookie saveCookie = casaDO.getCookie(SaveCookie.class);
        if (saveCookie != null) {
          try {
            saveCookie.save();
          } catch (IOException ex) {
            ex.printStackTrace();
          }
        }
      } catch (DataObjectNotFoundException ex) {
        ex.printStackTrace();
      }
    }
  }