Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


  }
 
  private IRegion findStringArgument(final IDocument document, final int offset, final String argument)
  {
    try {
      final IRegion lineInfo = document.getLineInformationOfOffset(offset);
      final String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
      final int lineRelativeOffset = offset - lineInfo.getOffset();
      int start = line.lastIndexOf(argument, lineRelativeOffset);
      if (start == -1) {
        return null;
      }
      start = line.lastIndexOf('"', lineRelativeOffset) + 1;
View Full Code Here


          if ("java".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getJavaEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, '"' + wicketId + '"', true, true, false, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 1, wicketId.length());
              wEditor.setActiveEditor(wEditor.getJavaEditor());
            }
          }
          else if ("html".equals(extension))
          {
            final ITextEditor textEditor = (ITextEditor)wEditor.getHtmlEditor();
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            final IRegion region = frda.find(0, "wicket:id=\"" + wicketId, true, true, true, false);
            if (region != null)
            {
              textEditor.selectAndReveal(region.getOffset() + 11, wicketId.length());
              wEditor.setActiveEditor(wEditor.getHtmlEditor());
            }
          }
          else if ("properties".equals(extension) && propertiesEditor != null)
          {
            final ITextEditor textEditor = (ITextEditor)propertiesEditor;
            final IDocument document = ((textEditor).getDocumentProvider()).getDocument(textEditor.getEditorInput());
            final FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
            IRegion regionBegin = frda.find(0, wicketId, true, true, true, false);
            if (regionBegin != null)
            {
              regionBegin = frda.find(regionBegin.getOffset(), "=", true, true, false, false);
              if (regionBegin != null)
              {
                final IRegion lineRegion = document.getLineInformationOfOffset(regionBegin.getOffset());
                final int selectionLength = lineRegion.getOffset() + lineRegion.getLength() - regionBegin.getOffset();
                textEditor.selectAndReveal(regionBegin.getOffset() + 1, selectionLength);
                wEditor.setActiveEditor(propertiesEditor);
              }
            }
          }
View Full Code Here

       
        // TODO: initialize indentLevel
        // initialize available line width
        int lineWidth = getFormattingPreferences().getMaxLineWidth();
        try {
          IRegion lineInfo = document.getLineInformationOfOffset(startOffset);
          lineWidth = lineWidth - (startOffset - lineInfo.getOffset());
        }
        catch (BadLocationException e) {
          Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
        }
        parentConstraints.setAvailableLineWidth(lineWidth);
View Full Code Here

     * @exception BadLocationException
     *                if offset is invalid in the current document
     */
    protected int endOfLineOf(int offset) throws BadLocationException {

        IRegion info = fDocument.getLineInformationOfOffset(offset);
        if (offset <= info.getOffset() + info.getLength()) {
            return info.getOffset() + info.getLength();
        }

        int line = fDocument.getLineOfOffset(offset);
        try {
            info = fDocument.getLineInformation(line + 1);
            return info.getOffset() + info.getLength();
        } catch (BadLocationException x) {
            return fDocument.getLength();
        }
    }
View Full Code Here

    public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
            boolean documentPartitioningChanged) {
        if (!documentPartitioningChanged) {
            try {

                IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
                int start = Math.max(partition.getOffset(), info.getOffset());

                int end = event.getOffset()
                        + (event.getText() == null ? event.getLength() : event.getText().length());

                if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
                    // optimize the case of the same line
                    end = info.getOffset() + info.getLength();
                } else {
                    end = endOfLineOf(end);
                }

                end = Math.min(partition.getOffset() + partition.getLength(), end);
View Full Code Here

    return document.getLength();
  }
 
  public String getLine(int line) {
    try {
      IRegion region = document.getLineInformation(line);
      return document.get(region.getOffset(), region.getLength());
    } catch (BadLocationException e) {
      System.out.printf("*** Warning BadLocationException");
      e.printStackTrace();
      return "";
    }
View Full Code Here

               
                if (lastPosition > 0)
                {
                    try
                    {
                        IRegion lineInfo = document.getLineInformationOfOffset(lastPosition);
                       
                        if (textConsoleViewer.getBottomIndexEndOffset() < lineInfo.getOffset())
                        {
                            if (lineInfo.getLength() > 0)
                                textConsoleViewer.revealRange(lineInfo.getOffset(), 1);
                            else
                                textConsoleViewer.revealRange(lineInfo.getOffset(), 0);
                        }
                    }
                    catch (BadLocationException ble)
                    {
                        ble.printStackTrace();
View Full Code Here

  private void updateTestCasesFromCurrentLine(
      List<String> testCases, AbstractTextEditor textEditor, int startLine) {
    IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
    try {
      IRegion region = document.getLineInformation(startLine);
      String sourceCode = document.get(region.getOffset(), region.getLength());
      testCases.addAll(finder.getTestCases(sourceCode));
    } catch (BadLocationException e) {
      logger.log(Level.SEVERE, "", e);
    }
  }
View Full Code Here

     * @exception BadLocationException
     *                if offset is invalid in the current document
     */
    protected int endOfLineOf(int offset) throws BadLocationException {

        IRegion info = fDocument.getLineInformationOfOffset(offset);
        if (offset <= info.getOffset() + info.getLength())
            return info.getOffset() + info.getLength();

        int line = fDocument.getLineOfOffset(offset);
        try {
            info = fDocument.getLineInformation(line + 1);
            return info.getOffset() + info.getLength();
        } catch (BadLocationException x) {
            return fDocument.getLength();
        }
    }
View Full Code Here

    public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
            boolean documentPartitioningChanged) {
        if (!documentPartitioningChanged) {
            try {

                IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
                int start = Math.max(partition.getOffset(), info.getOffset());

                int end = event.getOffset()
                        + (event.getText() == null ? event.getLength() : event.getText().length());

                if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
                    // optimize the case of the same line
                    end = info.getOffset() + info.getLength();
                } else
                    end = endOfLineOf(end);

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

TOP

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

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.