Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITypedRegion


    }
    return null;
  }

  private ITypedRegion getPartition(IDocument document, ITextSelection textSelection) {
    ITypedRegion region = null;
    if (textSelection != null) {
      try {
        region = document.getPartition(textSelection.getOffset());
      }
      catch (BadLocationException e) {
View Full Code Here


            try
            {
                LdifParser parser = new LdifParser();
                IDocument document = viewer.getDocument();
                ITypedRegion partition = document.getPartition( cursorPos );

                // now use position relative to partition
                int offset = partition.getOffset();
                int relativePos = cursorPos - offset;

                // parse partition
                String s = document.get( partition.getOffset(), partition.getLength() );
                LdifFile model = parser.parse( s );
                LdifContainer container = LdifFile.getContainer( model, relativePos );
                if ( container != null )
                {
                    LdifPart part = LdifFile.getContainerContent( container, relativePos );
View Full Code Here

   * @return String
   */
  protected String getPartitionType(StructuredTextViewer viewer, int documentPosition) {
    IDocument document = viewer.getDocument();
    String partitionType = null;
    ITypedRegion partition = null;
    try {
      partition = document.getPartition(documentPosition);
      partitionType = partition.getType();
    }
    catch (BadLocationException e) {
      partitionType = null;
    }
    return partitionType;
View Full Code Here

      TextPresentation presentation= new TextPresentation(damage, 1000);

      ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false);
      for (int i= 0; i < partitioning.length; i++) {
        ITypedRegion r= partitioning[i];
        IPresentationRepairer repairer= getRepairer(r.getType());
        if (repairer != null)
          repairer.createPresentation(presentation, r);
      }

      return presentation;
View Full Code Here

    IRegion damage= null;
    try {
      int offset= e.getOffset();
      if (isDeletion)
        offset= Math.max(0, offset - 1);
      ITypedRegion partition= getPartition(e.getDocument(), offset);
      IPresentationDamager damager= getDamager(partition.getType());
      if (damager == null)
        return null;

      IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
View Full Code Here

      length= e.getText().length();
      if (length > 0)
        -- length;
    }

    ITypedRegion partition= getPartition(d, e.getOffset() + length);
    int endOffset= partition.getOffset() + partition.getLength();
    if (endOffset == e.getOffset())
      return -1;

    int end= fRememberedPosition == null ? -1 : fRememberedPosition.getOffset() + fRememberedPosition.getLength();
    if (endOffset < end && end < d.getLength())
      partition= getPartition(d, end);

    IPresentationDamager damager= getDamager(partition.getType());
    if (damager == null)
      return -1;

    IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged);
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) {
View Full Code Here

  /*
   * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getPartition(int)
   * @since 3.0
   */
  public ITypedRegion getPartition(int offset, boolean preferOpenPartitions) {
    ITypedRegion region= getPartition(offset);
    if (preferOpenPartitions) {
      if (region.getOffset() == offset && !region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE)) {
        if (offset > 0) {
          region= getPartition(offset - 1);
          if (region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE))
            return region;
        }
        return new TypedRegion(offset, 0, IDocument.DEFAULT_CONTENT_TYPE);
      }
    }
View Full Code Here

     *
     * @param pos an offset within this document
     * @return true if the offset is within this document's partition
     */
    public boolean inPartition(int pos) {
      final ITypedRegion partition= getPartition(pos);
      return partition != null && partition.getType().equals(fPartition);
    }
View Full Code Here

     * @param pos an offset within the document
     * @param searchForward the direction of the search
     * @return the next position to query
     */
    public int getNextPosition(int pos, boolean searchForward) {
      final ITypedRegion partition= getPartition(pos);
      if (partition == null) return simpleIncrement(pos, searchForward);
      if (fPartition.equals(partition.getType()))
        return simpleIncrement(pos, searchForward);
      if (searchForward) {
        int end= partition.getOffset() + partition.getLength();
        if (pos < end)
          return end;
      } else {
        int offset= partition.getOffset();
        if (pos > offset)
          return offset - 1;
      }
      return simpleIncrement(pos, searchForward);
    }
View Full Code Here

TOP

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

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.