Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IDocument.replace()


            throw new InterruptedException();

          final String delimiter= document.getLineDelimiter(i);
          if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(fLineDelimiter)) {
            IRegion region= document.getLineInformation(i);
            document.replace(region.getOffset() + region.getLength(), delimiter.length(), fLineDelimiter);
          }

          monitor.worked(1);
        }
View Full Code Here


    final IDocument buffer = new Document(document.get());
    int index = offset - 1;
    while (index >= 0 && Character.isJavaIdentifierPart(buffer.getChar(index)))
      index--;
    final int length = offset - index - 1;
    buffer.replace(index + 1, length, " "); //$NON-NLS-1$
    return true;
  }

  public boolean isAutoInsertable() {
    return false;
View Full Code Here

   
    public void run() {
      ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      try {
        doc.replace(sel.getOffset(),sel.getLength(),HTMLUtil.escapeHTML(sel.getText()));
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
  }
View Full Code Here

      String text = sel.getText().trim();
      try {
        if(text.startsWith("<!--") && text.indexOf("-->") > 3){
          text = sel.getText().replaceFirst("<!--", "");
          text = text.replaceFirst("-->", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<!--" + sel.getText() + "-->");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
View Full Code Here

        if(text.startsWith("<!--") && text.indexOf("-->") > 3){
          text = sel.getText().replaceFirst("<!--", "");
          text = text.replaceFirst("-->", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<!--" + sel.getText() + "-->");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      String text = sel.getText().trim();
      try {
        if(text.startsWith("<%--") && text.endsWith("--%>")){
          text = sel.getText().replaceAll("<%--|--%>", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<%--" + sel.getText() + "--%>");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
View Full Code Here

      try {
        if(text.startsWith("<%--") && text.endsWith("--%>")){
          text = sel.getText().replaceAll("<%--|--%>", "");
          doc.replace(sel.getOffset(),sel.getLength(),text);
        } else {
          doc.replace(sel.getOffset(),sel.getLength(),"<%--" + sel.getText() + "--%>");
        }
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
View Full Code Here

   
    public void run() {
      ITextSelection sel = (ITextSelection)getSelectionProvider().getSelection();
      IDocument doc = getDocumentProvider().getDocument(getEditorInput());
      try {
        doc.replace(sel.getOffset(),sel.getLength(),HTMLUtil.escapeXML(sel.getText()));
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
  }
View Full Code Here

    try {
      int caret = content.length();
      if(content.indexOf("></")!=-1){
        caret = content.indexOf("></") + 1;
      }
      doc.replace(sel.getOffset(),sel.getLength(),content);
      editor.selectAndReveal(sel.getOffset() + caret, 0);
    } catch(Exception ex){
      HTMLPlugin.logException(ex);
    }
  }
View Full Code Here

        count1 = orgRange.getFrom()-1;
        count2 = revRange.getFrom()-1;
        // added
        if(delta instanceof AddDelta){
          while(count2 != revRange.getTo()){
            doc.replace(index,0,text2[count2] + "\n");
            index = index + text2[count2].length() + 1;
            count2++;
          }
        // removed
        } else if(delta instanceof DeleteDelta){
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.