Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.Region


            int replacedTextLength = event.getLength();
            int insertedTextLength = event.getText() != null ? event.getText().length() : 0;
            IDocument document = event.getDocument();
            // Region changeRegion = new Region(changeOffset,
            // replacedTextLength);
            Region changeRegion = new Region( changeOffset - BrowserCoreConstants.LINE_SEPARATOR.length(),
                replacedTextLength + ( 2 * BrowserCoreConstants.LINE_SEPARATOR.length() ) );

            // get containers to replace (from changeOffset till
            // changeOffset+replacedTextLength, check end of record)
            List<LdifContainer> oldContainerList = new ArrayList<LdifContainer>();
            LdifContainer[] containers = this.ldifModel.getContainers();
            for ( int i = 0; i < containers.length; i++ )
            {

                Region containerRegion = new Region( containers[i].getOffset(), containers[i].getLength() );

                boolean changeOffsetAtEOF = i == containers.length - 1
                    && changeOffset >= containerRegion.getOffset() + containerRegion.getLength();

                if ( TextUtilities.overlaps( containerRegion, changeRegion ) || changeOffsetAtEOF )
                {

                    // remember index
                    int index = i;

                    // add invalid containers and non-records before overlap
                    i--;
                    for ( ; i >= 0; i-- )
                    {
                        if ( !containers[i].isValid() || !( containers[i] instanceof LdifRecord ) )
                        {
                            oldContainerList.add( 0, containers[i] );
                        }
                        else
                        {
                            break;
                        }
                    }

                    // add all overlapping containers
                    i = index;
                    for ( ; i < containers.length; i++ )
                    {
                        containerRegion = new Region( containers[i].getOffset(), containers[i].getLength() );
                        if ( TextUtilities.overlaps( containerRegion, changeRegion ) || changeOffsetAtEOF )
                        {
                            oldContainerList.add( containers[i] );
                        }
                        else
View Full Code Here


        LdifContainer[] allContainers = ldifModel.getContainers();
        List containerList = new ArrayList();
        for ( int i = 0; i < allContainers.length; i++ )
        {
            LdifContainer container = allContainers[i];
            Region containerRegion = new Region( container.getOffset(), container.getLength() );
            if ( TextUtilities.overlaps( containerRegion, damage ) )
            {
                containerList.add( container );
            }
        }
View Full Code Here

                stack.push(new Character(chars[i]));
                continue;
            }
            if (chars[i] == rightChar) {
                if (stack.isEmpty()) {
                    return new Region(offset - 1, i + 2);
                } else {
                    stack.pop();
                }
            }
        }
View Full Code Here

                stack.push(new Character(chars[i]));
                continue;
            }
            if (chars[i] == leftChar) {
                if (stack.isEmpty()) {
                    return new Region(i, offset - i);
                } else {
                    stack.pop();
                }
            }
        }
View Full Code Here

            int replacedTextLength = event.getLength();
            int insertedTextLength = event.getText() != null ? event.getText().length() : 0;
            IDocument document = event.getDocument();
            // Region changeRegion = new Region(changeOffset,
            // replacedTextLength);
            Region changeRegion = new Region( changeOffset - BrowserCoreConstants.LINE_SEPARATOR.length(),
                replacedTextLength + ( 2 * BrowserCoreConstants.LINE_SEPARATOR.length() ) );

            // get containers to replace (from changeOffset till
            // changeOffset+replacedTextLength, check end of record)
            List<LdifContainer> oldContainerList = new ArrayList<LdifContainer>();
            LdifContainer[] containers = this.ldifModel.getContainers();
            for ( int i = 0; i < containers.length; i++ )
            {

                Region containerRegion = new Region( containers[i].getOffset(), containers[i].getLength() );

                boolean changeOffsetAtEOF = i == containers.length - 1
                    && changeOffset >= containerRegion.getOffset() + containerRegion.getLength();

                if ( TextUtilities.overlaps( containerRegion, changeRegion ) || changeOffsetAtEOF )
                {

                    // remember index
                    int index = i;

                    // add invalid containers and non-records before overlap
                    i--;
                    for ( ; i >= 0; i-- )
                    {
                        if ( !containers[i].isValid() || !( containers[i] instanceof LdifRecord ) )
                        {
                            oldContainerList.add( 0, containers[i] );
                        }
                        else
                        {
                            break;
                        }
                    }

                    // add all overlapping containers
                    i = index;
                    for ( ; i < containers.length; i++ )
                    {
                        containerRegion = new Region( containers[i].getOffset(), containers[i].getLength() );
                        if ( TextUtilities.overlaps( containerRegion, changeRegion ) || changeOffsetAtEOF )
                        {
                            oldContainerList.add( containers[i] );
                        }
                        else
View Full Code Here

                    end = info.getOffset() + info.getLength();
                } else
                    end = endOfLineOf(end);

                end = Math.min(partition.getOffset() + partition.getLength(), end);
                return new Region(start, end - start);

            } catch (BadLocationException x) {
                // FIXME hu ? needs some comment
                IvyPlugin.log(IStatus.WARNING, "Something bad happened", x);
            }
View Full Code Here

            parser.parse( sourceViewer.getDocument().get() );
            filter = parser.getModel().toString();
        }
        else if ( buttonId == FORMAT_BUTTON_ID )
        {
            IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
            configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
        }

        // call super implementation
        super.buttonPressed( buttonId );
View Full Code Here

        // set document
        IDocument document = new Document( filter );
        sourceViewer.setDocument( document );

        // preformat
        IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
        configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );

        // set focus to the source viewer
        sourceViewer.getTextWidget().setFocus();
View Full Code Here

    /**
     * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
     */
    public IRegion getHoverRegion( ITextViewer textViewer, int offset )
    {
        return new Region( offset, 1 );
    }
View Full Code Here

   * Method declared on ITextHover
   */
  public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
    Point selection= textViewer.getSelectedRange();
    if (selection.x <= offset && offset < selection.x + selection.y)
      return new Region(selection.x, selection.y);
    return new Region(offset, 0);
  }
View Full Code Here

TOP

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

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.