Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TypedPosition


    if (containsLineDelimiters(type))
      throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.contains.line.delimiters"))); //$NON-NLS-1$

    try {
      fDocument.addPosition(LINKED_POSITION, new TypedPosition(offset, length, type));
    } catch (BadPositionCategoryException e) {
      //PHPeclipsePlugin.log(e);
            e.printStackTrace();
      Assert.isTrue(false);
    }
View Full Code Here


    try {
      Position[] positions= getPositions(fDocument)
      if ((!success) && (positions != null)) {
        // restore
        for (int i= 0; i != positions.length; i++) {
          TypedPosition position= (TypedPosition) positions[i];       
          fDocument.replace(position.getOffset(), position.getLength(), position.getType());
        }
      }   
     
      fDocument.removePositionCategory(LINKED_POSITION);
View Full Code Here

  public Position getPreviousPosition(int offset) {
    Position[] positions= getPositions(fDocument);
    if (positions == null)
      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)) {
View Full Code Here

    // leave(true);
   
    IDocument document= event.getDocument();

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

    // ignore document changes (assume it won't invalidate constraints)
    if (currentPosition == null)
      return;
   
    int deltaOffset= event.getOffset() - currentPosition.getOffset();   

    if (fListener != null) {
      int length= event.getText() == null ? 0 : event.getText().length();
      fListener.setCurrentPosition(currentPosition, deltaOffset + length);   
    }

    for (int i= 0; i != positions.length; i++) {
      TypedPosition p= (TypedPosition) positions[i];     
     
      if (p.getType().equals(currentPosition.getType()) && !p.equals(currentPosition)) {
        Replace replace= new Replace(p, deltaOffset, event.getLength(), event.getText());
        ((IDocumentExtension) document).registerPostNotificationReplace(this, replace);
      }
    }
  }
View Full Code Here

   */
  public void update(DocumentEvent event) {
    int deltaLength= (event.getText() == null ? 0 : event.getText().length()) - event.getLength();

    Position[] positions= getPositions(event.getDocument());
    TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());

    // document change outside positions
    if (currentPosition == null) {
     
      for (int i= 0; i != positions.length; i++) {
        TypedPosition position= (TypedPosition) positions[i];
        int offset= position.getOffset();
       
        if (offset >= event.getOffset())
          position.setOffset(offset + deltaLength);
      }
     
    // document change within a position
    } else {
      int length= currentPosition.getLength();
 
      for (int i= 0; i != positions.length; i++) {
        TypedPosition position= (TypedPosition) positions[i];
        int offset= position.getOffset();
       
        if (position.equals(currentPosition)) {
          position.setLength(length + deltaLength);         
        } else if (offset > currentPosition.getOffset()) {
          position.setOffset(offset + deltaLength);
        }
      }   
    }
  }
View Full Code Here

      leave(true);
      return;
    }

    Position[] positions= getPositions(document);
    TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, command.offset);

    // handle edits outside of a position
    if (currentPosition == null) {
      leave(true);
      return;
    }

    if (! command.doit)
      return;

    command.doit= false;
    command.owner= this;
    command.caretOffset= command.offset + command.length;

    int deltaOffset= command.offset - currentPosition.getOffset();   

    if (fListener != null)
      fListener.setCurrentPosition(currentPosition, deltaOffset + command.text.length());
   
    for (int i= 0; i != positions.length; i++) {
      TypedPosition position= (TypedPosition) positions[i];     
     
      try {
        if (position.getType().equals(currentPosition.getType()) && !position.equals(currentPosition))
          command.addCommand(position.getOffset() + deltaOffset, command.length, command.text, this);
      } catch (BadLocationException e) {
        //PHPeclipsePlugin.log(e);
        e.printStackTrace();
      }
    }
View Full Code Here

      fDocumentChanging= true;
      if (fCachedRedrawState) {
        try {
          int offset= e.getOffset() + e.getLength();
          ITypedRegion region= getPartition(e.getDocument(), offset);
          fRememberedPosition= new TypedPosition(region);
          e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
        } catch (BadLocationException x) {
          // can not happen
        } catch (BadPositionCategoryException x) {
          // should not happen on input elements
View Full Code Here

   */
  public void format() {
    super.format();

    final IDocument document = (IDocument) fDocuments.removeFirst();
    final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();

    if (document != null && partition != null && fRegion != null && fFormatProcessor != null) {
      try {
        fFormatProcessor.formatDocument(document, fRegion.getOffset(), fRegion.getLength());
      }
View Full Code Here

   */
  public void format() {
    super.format();

    final IDocument document = (IDocument) fDocuments.removeFirst();
    final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();

    if (document != null && partition != null) {
      try {

        JSPTranslationUtil translationUtil = new JSPTranslationUtil(document);
View Full Code Here

   */
  public void format() {
    super.format();

    final IDocument document = (IDocument) fDocuments.removeFirst();
    final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();

    if (document != null && partition != null && fRegion != null) {
      try {
        if (document instanceof IStructuredDocument) {
          IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) document);
View Full Code Here

TOP

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

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.