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

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


                && line.equals(lines[lines.length-1])) {
            // Figure out the viewer offset for the start of the line.
            int widgetLineStart = this.textWidget.getContent().getOffsetAtLine(widgetLine + lineCount);
            int viewerLineStart = this.fViewer.widgetOffset2ModelOffset(widgetLineStart);
          
            ProjectionAnnotationModel model = this.fViewer.getProjectionAnnotationModel();
            Iterator i = model.getAnnotationIterator();
            while (i.hasNext()) {
                ProjectionAnnotation annotation = (ProjectionAnnotation)i.next();
                Position pos = model.getPosition(annotation);
                /* Check if the line is the start line of a collapsed
                 * region.
                 */
                if (pos.offset == viewerLineStart
                        && annotation.isCollapsed()) {
View Full Code Here


   * @return
   */
  public void createAnnotationList(int selectionOffset, int length) {
      annotationList = new ArrayList();
      // Projection Annotations
      ProjectionAnnotationModel pModel = viewer.getProjectionAnnotationModel();
        Iterator i = pModel.getAnnotationIterator();
       
       
        while (i.hasNext()) {
            Object o = i.next();
            if (o instanceof ProjectionAnnotation) {
                ProjectionAnnotation annotation = (ProjectionAnnotation)o;
                Position pos = pModel.getPosition(annotation);
               
                // The annotation is completely inside the selection
                if (pos.offset >= selectionOffset
                        && pos.offset <= selectionOffset + length) {
                    boolean collapsed = annotation.isCollapsed();
                    pModel.expand(annotation);
                    Position newPos = new Position(pos.offset-selectionOffset,pos.length);
                    annotationList.add(new AnnotationPosition(annotation,newPos,collapsed));
                   
                    // Remove the annotation for now.
                    pModel.removeAnnotation(annotation);
                }
                // The annotation starts in the selection, but doesn't end in it.
                else if(pos.offset >= selectionOffset
                        && pos.offset <= selectionOffset + length
                        && pos.offset + pos.length >= selectionOffset + length) {
                    pModel.removeAnnotation(annotation);
                }
                // The annotation ends in the selection, but doesn't start in it
                else if (pos.offset + pos.length >= selectionOffset
                        && pos.offset + pos.length <= selectionOffset + length) {
                    pModel.removeAnnotation(annotation);
                }
               
            }
        }

View Full Code Here

          return;
      }
      Object[] allAnnotations = annotationList.toArray();
      ArrayList collapsedAnnotations = new ArrayList();
      try {
      ProjectionAnnotationModel pModel = viewer.getProjectionAnnotationModel();
      IAnnotationModel aModel = viewer.getAnnotationModel();
      for(int i=0;i<allAnnotations.length;i++) {
          AnnotationPosition ap = (AnnotationPosition)allAnnotations[i];
          Position p = new Position(ap.position().offset+offset,ap.position().length);
          if (ap.annotation() instanceof ProjectionAnnotation) {
              pModel.addAnnotation(ap.annotation(),p);
            
              // Don't collapse this in here in case there are
              // non-collapsed nested annotations
              // that haven't been added to the model yet.
              if (ap.collapsed()) {
                  collapsedAnnotations.add(ap.annotation());
              }
             
          }
          else {
              aModel.addAnnotation(ap.annotation(),p);
          }
      }
     
      // Now collapse the annotations that were collapsed before
      Object[] annotations = collapsedAnnotations.toArray();
      for (int x =0;x<annotations.length;x++) {
          pModel.collapse((ProjectionAnnotation)annotations[x]);
      }
      }
      catch (Exception e) {
          e.printStackTrace();
      }
View Full Code Here

        IDocument document = viewer.getDocument();

        try
        {
            ProjectionAnnotationModel projectionAnnotationModel = ( ProjectionAnnotationModel ) editor
                .getAdapter( ProjectionAnnotationModel.class );
            if ( projectionAnnotationModel == null )
                return;

            // create folding regions of current LDIF model; mark comments
            // and
            // folded lines as collapsed
            Map positionToAnnotationMap = createFoldingRegions( editor.getLdifModel(), document );

            // compare with current annotation model (--> toAdd, toDelete)
            List annotationsToDeleteList = new ArrayList();
            Map annotationsToAddMap = new HashMap();
            this.computeDifferences( projectionAnnotationModel, positionToAnnotationMap, annotationsToDeleteList,
                annotationsToAddMap );
            Annotation[] annotationsToDelete = ( Annotation[] ) annotationsToDeleteList
                .toArray( new Annotation[annotationsToDeleteList.size()] );

            // update annotation model
            if ( !annotationsToDeleteList.isEmpty() || !annotationsToAddMap.isEmpty() )
            {
                projectionAnnotationModel.modifyAnnotations( annotationsToDelete, annotationsToAddMap,
                    new Annotation[0] );
            }

        }
        catch ( BadLocationException e )
View Full Code Here

    @SuppressWarnings({"unchecked", "rawtypes"})
    private Map<IModelElement, Object> computeCurrentStructure(
            FoldingStructureComputationContext ctx)
    {
        Map<IModelElement, Object> map = new HashMap<IModelElement, Object>();
        ProjectionAnnotationModel model = ctx.getModel();
        Iterator e = model.getAnnotationIterator();

        while (e.hasNext()) {

            Object annotation = e.next();
            if (annotation instanceof TwigProjectionAnnotation) {
                TwigProjectionAnnotation java = (TwigProjectionAnnotation) annotation;
                Position position = model.getPosition(java);
                Assert.isNotNull(position);
                List<Tuple> list = (List<Tuple>) map.get(java.getElement());
                if (list == null) {
                    list = new ArrayList<Tuple>(2);
                    map.put(java.getElement(), list);
View Full Code Here

    private FoldingStructureComputationContext createContext(
            boolean allowCollapse)
    {
        if (!isInstalled())
            return null;
        ProjectionAnnotationModel model = getModel();
        if (model == null)
            return null;
        IDocument doc = getDocument();
        if (doc == null)
            return null;
View Full Code Here

    for(Annotation a : annotations.keySet().toArray(ANNOTATION_ARRAY)) {
      Position p = annotations.get(a);
      if (!intersectsRegion(p , region)) annotations.remove(a);
    }
    // Adjust the page
      ProjectionAnnotationModel annotationModel = viewer.getProjectionAnnotationModel();
      if (annotationModel==null) return;
    annotationModel.modifyAnnotations(deletedAnnotations.toArray(ANNOTATION_ARRAY), annotations, null);
    // Remember old values
    oldAnnotations.putAll(annotations);
    for (Annotation a : deletedAnnotations) {
      oldAnnotations.remove(a)
    }   
View Full Code Here

          if (viewer instanceof StructuredTextEditor
              && ((StructuredTextEditor) viewer).getTextViewer() != null) {

            IStructuredDocument document = ((StructuredTextEditor) viewer).getModel()
                .getStructuredDocument();
            ProjectionAnnotationModel annotationModel = ((StructuredTextEditor) viewer)
                .getTextViewer().getProjectionAnnotationModel();

            if (element != null) {
              Object modelElement = (Object) BRIDGE.getObjectForHandle(element
                  .getHandleIdentifier());
View Full Code Here

    if (!enabled || !ContextCorePlugin.getContextManager().isContextActive()) {
      workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
          if (viewer instanceof StructuredTextEditor
              && ((StructuredTextEditor) viewer).getTextViewer() != null) {
            ProjectionAnnotationModel annotationModel = ((StructuredTextEditor) viewer)
                .getTextViewer().getProjectionAnnotationModel();
            if (annotationModel != null) {
              expandDocument(annotationModel);
            }
          }
        }
      });
    }
    else if (editor.getEditorInput() == null
        || !(editor.getEditorInput() instanceof IFileEditorInput)) {
      return;
    }
    else {

      IFileEditorInput editorInput = (IFileEditorInput) editor.getEditorInput();
      IFile file = editorInput.getFile();

      if (file != null && BeansContextStructureBridge.isBeansConfig(file)) {

        final IBeansConfig beansConfig = BeansCorePlugin.getModel().getConfig(file);

        workbench.getDisplay().asyncExec(new Runnable() {

          public void run() {
            if (viewer instanceof StructuredTextEditor
                && ((StructuredTextEditor) viewer).getTextViewer() != null) {

              ProjectionAnnotationModel annotationModel = ((StructuredTextEditor) viewer)
                  .getTextViewer().getProjectionAnnotationModel();
              collapseDocument(annotationModel);

              IStructuredDocument document = ((StructuredTextEditor) viewer)
                  .getModel().getStructuredDocument();
View Full Code Here

TOP

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

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.