Package org.eclipse.jface.text.source.projection

Examples of org.eclipse.jface.text.source.projection.ProjectionAnnotation


        .getProjectionAnnotationModel();
    Annotation[] deletions = computeDifferences(positions, annotationModel);
    Map<ProjectionAnnotation, Object> additionsMap = new HashMap<ProjectionAnnotation, Object>();
    for (Iterator<Position> i = positions.iterator(); i.hasNext();) {
      Object position = i.next();
      additionsMap.put(new ProjectionAnnotation(), position);
    }
    if ((deletions.length != 0 || additionsMap.size() != 0))
      annotationModel.modifyAnnotations(deletions, additionsMap,
          new Annotation[] {});
  }
View Full Code Here


        Iterator<?> iterator = model.getAnnotationIterator();
        List<Annotation> toCollapse=new ArrayList<Annotation>();
        while (iterator.hasNext()){
          Object next = iterator.next();
          if(next instanceof ProjectionAnnotation){
            ProjectionAnnotation pa = (ProjectionAnnotation) next;
            //foldable regions for strings have been marked by using the TextFoldedRegion class
            //there may indeed be better ways...
            Position position = model.getPosition(pa);
            if(position instanceof TypedFoldedRegion && type==((TypedFoldedRegion) position).getType()){
              pa.markCollapsed();
              toCollapse.add(pa);
            }
          }
        }
        model.modifyAnnotations(null, null, toCollapse.toArray(new Annotation[0]));
View Full Code Here

      List<Annotation> changes=new ArrayList<Annotation>();
      Iterator<?> iterator = model.getAnnotationIterator();
      while (iterator.hasNext()){
        Object next = iterator.next();
        if(next instanceof ProjectionAnnotation){
          ProjectionAnnotation pa = (ProjectionAnnotation) next;
          Position position = model.getPosition(pa);
          if(position instanceof TypedFoldedRegion &&typesToFold.contains(((TypedFoldedRegion) position).getType())){
            pa.markCollapsed();
            changes.add(pa);
          }
        }
      }
      model.modifyAnnotations(null,null, changes.toArray(new Annotation[0]));
View Full Code Here

   */
  protected void updateFoldingStructure(Collapsible[] newCollapsibles) {     
    for (Collapsible collapsible : newCollapsibles) {
      if (m_CollapsibleElements.containsKey(collapsible)) {
        // an existing element
        ProjectionAnnotation annotation = m_CollapsibleElements
            .get(collapsible);
        Position oldPosition = getAnnotation()
            .getPosition(annotation);
        Position newPosition = getElementPosition(collapsible);
        // did the position change?
        if (oldPosition == null || !oldPosition.equals(newPosition)) {
          getAnnotation().modifyAnnotationPosition(annotation,
              newPosition);
        }
      } else {
        // if a new element was found
        ProjectionAnnotation annotation = new ProjectionAnnotation();
        Position position = getElementPosition(collapsible);
        getAnnotation().addAnnotation(annotation, position);
        // add it to the list of known collapsible
        m_CollapsibleElements.put(collapsible, annotation);
      }
    }
    // find deleted elements
    Set<Collapsible> collapsibleSet = m_CollapsibleElements.keySet();
    Iterator<Collapsible> it = collapsibleSet.iterator();
    ArrayList<Collapsible> deletedItems = new ArrayList<Collapsible>();
    while (it.hasNext()) {
      Collapsible collapsible = it.next();
      ProjectionAnnotation annotation = m_CollapsibleElements.get(collapsible);
      // if the element does not exist in the new list, remove it
      boolean bFound=false;
      for(int i=0;i<newCollapsibles.length;i++){
        if (newCollapsibles[i].equals(collapsible)){
          bFound=true;
View Full Code Here

 
  public static void applyModifiedAnnotations(ProjectionAnnotationModel model, List list){
    // apply only modified annotations
    Iterator ite = model.getAnnotationIterator();
    while(ite.hasNext()){
      ProjectionAnnotation annotation = (ProjectionAnnotation)ite.next();
      Position pos = model.getPosition(annotation);
      boolean remove = true;
      for(int i=0;i<list.size();i++){
        FoldingInfo info = (FoldingInfo)list.get(i);
        if(info.getStart() == pos.offset && info.getEnd() == pos.offset + pos.length){
          remove = false;
          list.remove(info);
          break;
        }
      }
      if(remove){
        model.removeAnnotation(annotation);
      }
    }
   
    for(int i=0;i<list.size();i++){
      FoldingInfo info = (FoldingInfo)list.get(i);
      Position pos = new Position(info.getStart(),info.getEnd() - info.getStart());
      model.addAnnotation(new ProjectionAnnotation(), pos);
    }
  }
View Full Code Here

    if (!_collapsedIDs.contains(target)) {
      _collapsedIDs.add(target);

      FuzzyXMLNode selectedNode = _idToNodeMap.get(target);
      ProjectionAnnotationModel model = ((ProjectionViewer) _editor.getViewer()).getProjectionAnnotationModel();
      ProjectionAnnotation lastAnnotation = getAnnotationForNode(selectedNode, model);
      if (lastAnnotation != null) {
        model.collapse(lastAnnotation);
      }
    }
  }
View Full Code Here

    if (_collapsedIDs.contains(target)) {
      _collapsedIDs.remove(target);

      FuzzyXMLNode selectedNode = _idToNodeMap.get(target);
      ProjectionAnnotationModel model = ((ProjectionViewer) _editor.getViewer()).getProjectionAnnotationModel();
      ProjectionAnnotation lastAnnotation = getAnnotationForNode(selectedNode, model);
      if (lastAnnotation != null) {
        model.expand(lastAnnotation);
      }
    }
  }
View Full Code Here

   * @param model the annotation model
   * @return the matching annotation (or null if not found)
   */
  @SuppressWarnings("unchecked")
  protected ProjectionAnnotation getAnnotationForNode(FuzzyXMLNode node, ProjectionAnnotationModel model) {
    ProjectionAnnotation matchingAnnotation = null;
    if (model != null) {
      int index = node.getOffset();
      Iterator<ProjectionAnnotation> annotationsIter = model.getAnnotationIterator();
      while (annotationsIter.hasNext()) {
        ProjectionAnnotation annotation = annotationsIter.next();
        if (model.getPosition(annotation).getOffset() == index) {
          matchingAnnotation = annotation;
        }
      }
    }
View Full Code Here

      IAnnotationModel model = event.getAnnotationModel();
      Annotation[] annotations = event.getChangedAnnotations();
      if (annotations != null) {
        for (Annotation annotation : annotations) {
          if (annotation instanceof ProjectionAnnotation) {
            ProjectionAnnotation projectionAnnotation = (ProjectionAnnotation) annotation;
            Position annotationPosition = model.getPosition(annotation);
            FuzzyXMLNode node = _doc.getElementByOffset(annotationPosition.getOffset());
            String nodeID = _nodeToIDMap.get(node);
            if (nodeID != null) {
              if (projectionAnnotation.isCollapsed()) {
                _browser.execute("collapse('" + nodeID + "');");
              }
              else {
                _browser.execute("expand('" + nodeID + "');");
              }
View Full Code Here

            Annotation[] annotations = new Annotation[positions.size()];
            // this will hold the new annotations along
            // with their corresponding positions
            HashMap newAnnotations = new HashMap();
            for (int i = 0; i < positions.size(); i++) {
                ProjectionAnnotation annotation = new ProjectionAnnotation();
                newAnnotations.put(annotation, positions.get(i));
                annotations[i] = annotation;
            }
            annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
            oldAnnotations = annotations;
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.source.projection.ProjectionAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.