Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Position


    try {
      Position[] positions= event.getDocument().getPositions(fCategory);
      for (int i= 0; i != positions.length; i++) {

        Position position= positions[i];

        if (position.isDeleted())
          continue;

        int posOffset = position.getOffset();
        int posLength = position.getLength()// always zero
        int posEnd    = posOffset + posLength;
        //System.out.printf("  position %s offset:%d\n", position.toString(), posOffset);
       
        if (posOffset > eventOldEndOffset) {
          // position comes way after change - shift
          position.setOffset(posOffset + deltaLength);
        } else if (posOffset < eventOffset) {
          // position comes way before change - leave alone
        } else {
          // position is within replaced text -
          if (fGravity == RIGHT_GRAVITY)
            position.setOffset(eventNewEndOffset);
          else
            position.setOffset(eventOffset);
        }
        //System.out.printf("  position %s offset:%d\n", position.toString(), position.getOffset());
      }
    } catch (BadPositionCategoryException e) {
      // ignore and return
View Full Code Here


    // TODO: Build first a map, and then pass all annotations at once
    Map annotationsToAdd = new HashMap();
   
    while (mAnnotations.hasNext()) {
      AnnotationFS annotationFS = mAnnotations.next();
      annotationsToAdd.put(new EclipseAnnotationPeer(annotationFS), new Position(
              annotationFS.getBegin(), annotationFS.getEnd() - annotationFS.getBegin()));
    }
   
    ((IAnnotationModelExtension) annotationModel).replaceAnnotations(null, annotationsToAdd);
  }
View Full Code Here

      IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
     
      Map<Annotation, Position> addAnnotationMap = new HashMap<Annotation, Position>();
     
      for (AnnotationFS annotation : annotations) {
        addAnnotationMap.put(new EclipseAnnotationPeer(annotation), new Position(annotation.getBegin(),
                annotation.getEnd() - annotation.getBegin()));
      }
     
      annotationModel.replaceAnnotations(null, addAnnotationMap);
    }
View Full Code Here

     
      IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
     
      for (AnnotationFS annotation : annotations) {
        annotationModel.modifyAnnotationPosition(new EclipseAnnotationPeer(annotation),
                new Position(annotation.getBegin(), annotation.getEnd() - annotation.getBegin()));
      }
     
      selectionChanged(getSite().getPage().getActivePart(), mFeatureStructureSelectionProvider.getSelection());
    }
View Full Code Here

        try {

          int offset= document.getLineOffset(line);
          int end= document.getLineOffset(line + length);
          length= end - offset;
          Position p= new Position(offset, length);
          document.addPosition(SEGMENTS, p);
          fContent.add(new Segment(MessageFormat.format(JavaEditorMessages.getString("OutlinePage.segment.title_pattern"), new Object[] { new Integer(offset) }), p)); //$NON-NLS-1$

        } catch (BadPositionCategoryException x) {
        } catch (BadLocationException x) {
View Full Code Here

    Position[] positions= getPositions(fDocument);   
    if (positions == null)
      return null;

    for (int i= positions.length - 1; i >= 0; i--) {
      Position position= positions[i];
      if (offset >= position.getOffset() && offset <= position.getOffset() + position.getLength())
        return positions[i];
    }
   
    return null;
  }
View Full Code Here

      return null;

    TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, offset);
    String currentType= currentPosition == null ? null : currentPosition.getType();

    Position lastPosition= null;
    Position position= getFirstPosition();

    while ((position != null) && (position.getOffset() < offset) && !((TypedPosition) position).getType().equals(currentType)) {
      lastPosition= position;
      position= findNextPosition(positions, position.getOffset());
    }
   
    return lastPosition;
  }
View Full Code Here

  public void documentAboutToBeChanged(DocumentEvent event) {

    IDocument document= event.getDocument();

    Position[] positions= getPositions(document);
    Position position= findCurrentPosition(positions, event.getOffset());

    // modification outside editable position
    if (position == null) {
      // check for destruction of constraints (spacing of at least 1)
      if ((event.getText() == null || event.getText().length() == 0) &&
View Full Code Here

   * Test if ok to modify through UI.
   */
  public boolean anyPositionIncludes(int offset, int length) {
    Position[] positions= getPositions(fDocument);

    Position position= findCurrentPosition(positions, offset);
    if (position == null)
      return false;
   
    return includes(position, offset, length);
  }
View Full Code Here

  private static class PositionComparator implements Comparator {
    /*
     * @see Comparator#compare(Object, Object)
     */
    public int compare(Object object0, Object object1) {
      Position position0= (Position) object0;
      Position position1= (Position) object1;
     
      return position0.getOffset() - position1.getOffset();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.Position

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.