Package org.eclipse.wst.sse.core.internal.provisional.events

Examples of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent


      else {
        canHandle = false;
      }

    }
    RegionChangedEvent result = null;

    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      fLength += lengthDifference;

      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
    }

    return result;
  }
View Full Code Here


    return result;
  }

  // need an adjust text length API before this can be used
  static public StructuredDocumentEvent updateModel(ITextRegion region, Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
    RegionChangedEvent result = null;
    // if the region is an easy type (e.g. attribute value),
    // and the requested changes are all
    // alphanumeric, then make the change here locally.
    // (This can obviously be made more sophisticated as the need arises,
    // but should
    // always follow this pattern.)
    if (Debug.debugStructuredDocument) {
      System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
      System.out.println("\t\t\tregion type is " + region.getType()); //$NON-NLS-1$
    }
    boolean canHandle = false;
    // note: we'll always handle deletes from these
    // regions ... if its already that region,
    // deleting something from it won't change its
    // type. (remember, the calling program needs
    // to insure we are not called, if not all contained
    // on one region.
    if ((changes == null) || (changes.length() == 0)) {
      // delete case
      // We can not do the quick delete, if
      // if all the text in a region is to be deleted.
      // Or, if the delete starts in the white space region.
      // In these cases, a reparse is needed.
      // Minor note, we use textEnd-start since it always
      // less than or equal to end-start. This might
      // cause us to miss a few cases we could have handled,
      // but will prevent us from trying to handle funning cases
      // involving whitespace.
      if ((region.getStart() >= region.getTextEnd()) || (Math.abs(lengthToReplace) >= region.getTextEnd() - region.getStart())) {
        canHandle = false;
      } else {
        canHandle = true;
      }
    } else {
      if ((RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(region, parent, changes, requestStart, lengthToReplace)) {
        canHandle = true;
      } else {
        canHandle = false;
      }
    }
    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      region.adjustLength(lengthDifference);
      // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
      // If we are handling as whitespace, there is no need to increase
      // the text length, only
      // the total length is changing.
      if (!RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, region.getStart(), lengthToReplace)) {
        //        region.adjustTextLength(lengthDifference);
      }
      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, region, changes, requestStart, lengthToReplace);
    }
    return result;
  }
View Full Code Here

    // TODO: this is a pretty lame method, since XML Content can have a
    // much
    // better rule for region update, but this is what previous
    // (unfactored)
    // version had, so I'll carry it over, of now.
    RegionChangedEvent result = null;
    // if the region is an easy type (e.g. attribute value),
    // and the requested changes are all
    // alphanumeric, then make the change here locally.
    // (This can obviously be made more sophisticated as the need arises,
    // but should
    // always follow this pattern.)
    if (Debug.debugStructuredDocument) {
      System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
      System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
    }
    boolean canHandle = false;
    // note: we'll always handle deletes from these
    // regions ... if its already that region,
    // deleting something from it won't change its
    // type. (remember, the calling program needs
    // to insure we are not called, if not all contained
    // on one region.
    if ((changes == null) || (changes.length() == 0)) {
      // delete case
      // We can not do the quick delete, if
      // if all the text in a region is to be deleted.
      // Or, if the delete starts in the white space region.
      // In these cases, a reparse is needed.
      // Minor note, we use textEnd-start since it always
      // less than or equal to end-start. This might
      // cause us to miss a few cases we could have handled,
      // but will prevent us from trying to handle funning cases
      // involving whitespace.
      if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
        canHandle = false;
      } else {
        canHandle = true;
      }
    } else {
      if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
        canHandle = true;
      } else {
        canHandle = false;
      }

    }
    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      fLength += lengthDifference;
      // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
      // If we are handling as whitespace, there is no need to increase
      // the text length, only
      // the total length is changing.
      // don't need for content region
      //      if (!RegionUpdateRule.canHandleAsWhiteSpace(this, changes,
      // fStart, lengthToReplace)) {
      //        fTextLength += lengthDifference;
      //      }
      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
    }

    return result;
  }
View Full Code Here

    // TODO: this is a pretty lame method, since XML CData region can have
    // a much
    // better rule for region update, but this is what previous
    // (unfactored)
    // version had, so I'll carry it over, of now.
    RegionChangedEvent result = null;
    // if the region is an easy type (e.g. attribute value),
    // and the requested changes are all
    // alphanumeric, then make the change here locally.
    // (This can obviously be made more sophisticated as the need arises,
    // but should
    // always follow this pattern.)
    if (Debug.debugStructuredDocument) {
      System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
      System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
    }
    boolean canHandle = false;
    // note: we'll always handle deletes from these
    // regions ... if its already that region,
    // deleting something from it won't change its
    // type. (remember, the calling program needs
    // to insure we are not called, if not all contained
    // on one region.
    if ((changes == null) || (changes.length() == 0)) {
      // delete case
      // We can not do the quick delete, if
      // if all the text in a region is to be deleted.
      // Or, if the delete starts in the white space region.
      // In these cases, a reparse is needed.
      // Minor note, we use textEnd-start since it always
      // less than or equal to end-start. This might
      // cause us to miss a few cases we could have handled,
      // but will prevent us from trying to handle funning cases
      // involving whitespace.
      if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
        canHandle = false;
      } else {
        canHandle = true;
      }
    } else {
      if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
        canHandle = true;
      } else {
        canHandle = false;
      }

    }
    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
      // If we are handling as whitespace, there is no need to increase
      // the text length, only
      // the total length is changing.
      if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
        fTextLength += lengthDifference;
      }
      fLength += lengthDifference;
      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
    }

    return result;
  }
View Full Code Here

  public String toString() {
    return RegionToStringUtil.toString(this);
  }

  public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
    RegionChangedEvent result = null;
    // if the region is an easy type (e.g. attribute value),
    // and the requested changes are all
    // alphanumeric, then make the change here locally.
    // (This can obviously be made more sophisticated as the need arises,
    // but should
    // always follow this pattern.)
    if (Debug.debugStructuredDocument) {
      System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
      System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
    }
    boolean canHandle = false;
    // note: we'll always handle deletes from these
    // regions ... if its already that region,
    // deleting something from it won't change its
    // type. (remember, the calling program needs
    // to insure we are not called, if not all contained
    // on one region.
    if ((changes == null) || (changes.length() == 0)) {
      // delete case
      // We can not do the quick delete, if
      // if all the text in a region is to be deleted.
      // Or, if the delete starts in the white space region.
      // In these cases, a reparse is needed.
      // Minor note, we use textEnd-start since it always
      // less than or equal to end-start. This might
      // cause us to miss a few cases we could have handled,
      // but will prevent us from trying to handle funning cases
      // involving whitespace.
      if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
        canHandle = false;
      } else {
        canHandle = true;
      }
    } else {
      if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
        canHandle = true;
      } else {
        canHandle = false;
      }
    }
    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
      // If we are handling as whitespace, there is no need to increase
      // the text length, only
      // the total length is changing.
      if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
        fTextLength += lengthDifference;
      }
      // update length (and end) after above check for white space,
      // since
      // it looks to determine if at end of region.
      fLength += lengthDifference;
      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
    }
    return result;
  }
View Full Code Here

  public String toString() {
    return RegionToStringUtil.toString(this);
  }

  public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
    RegionChangedEvent result = null;
    // if the region is an easy type (e.g. attribute value),
    // and the requested changes are all
    // alphanumeric, then make the change here locally.
    // (This can obviously be made more sophisticated as the need arises,
    // but should
    // always follow this pattern.)
    if (Debug.debugStructuredDocument) {
      System.out.println("\t\tContextRegion::updateModel"); //$NON-NLS-1$
      System.out.println("\t\t\tregion type is " + fType); //$NON-NLS-1$
    }
    boolean canHandle = false;
    // note: we'll always handle deletes from these
    // regions ... if its already that region,
    // deleting something from it won't change its
    // type. (remember, the calling program needs
    // to insure we are not called, if not all contained
    // on one region.
    if ((changes == null) || (changes.length() == 0)) {
      // delete case
      // We can not do the quick delete, if
      // if all the text in a region is to be deleted.
      // Or, if the delete starts in the white space region.
      // In these cases, a reparse is needed.
      // Minor note, we use textEnd-start since it always
      // less than or equal to end-start. This might
      // cause us to miss a few cases we could have handled,
      // but will prevent us from trying to handle funning cases
      // involving whitespace.
      if ((fStart >= getTextEnd()) || (Math.abs(lengthToReplace) >= getTextEnd() - getStart())) {
        canHandle = false;
      } else {
        canHandle = true;
      }
    } else {
      if ((RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(this, parent, changes, requestStart, lengthToReplace)) {
        canHandle = true;
      } else {
        canHandle = false;
      }

    }
    if (canHandle) {
      // at this point, we still have the old region. We won't create a
      // new instance, we'll just update the one we have, by changing
      // its end postion,
      // The parent flatnode, upon return, has responsibility
      // for updating sibling regions.
      // and in turn, the structuredDocument itself has responsibility
      // for
      // updating the text store and down stream flatnodes.
      if (Debug.debugStructuredDocument) {
        System.out.println("change handled by region"); //$NON-NLS-1$
      }
      int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
      // Note: we adjust both end and text end, because for any change
      // that is in only the trailing whitespace region, we should not
      // do a quick change,
      // so 'canHandle' should have been false for those case.
      // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above
      // If we are handling as whitespace, there is no need to increase
      // the text length, only
      // the total length is changing.
      if (!RegionUpdateRule.canHandleAsWhiteSpace(this, parent, changes, requestStart, lengthToReplace)) {
        fTextLength += lengthDifference;
      }
      fLength += lengthDifference;
      result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, this, changes, requestStart, lengthToReplace);
    }

    return result;
  }
View Full Code Here

      IStructuredDocumentRegion oldNode, IStructuredDocumentRegion newNode) {
    final StructuredDocumentEvent event = super.regionCheck(oldNode,
        newNode);

    if (event instanceof RegionChangedEvent) {
      RegionChangedEvent changedEvent = (RegionChangedEvent) event;

      if (changedEvent.getRegion().getType() == PHPRegionContext.PHP_CONTENT) {
        oldNode.setRegions(newNode.getRegions());
      }
    }
    return event;
  }
View Full Code Here

    {
        final StructuredDocumentEvent event = super.regionCheck(oldNode,
                newNode);

        if (event instanceof RegionChangedEvent) {
            RegionChangedEvent changedEvent = (RegionChangedEvent) event;

            if (changedEvent.getRegion().getType() == TwigRegionContext.TWIG_CONTENT
                    || changedEvent.getRegion().getType() == TwigRegionContext.TWIG_COMMENT) {
                oldNode.setRegions(newNode.getRegions());
            }
        }
        return event;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent

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.