Package org.eclipse.jface.text

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


            count2++;
          }
        // removed
        } else if(delta instanceof DeleteDelta){
          while(count1 != orgRange.getTo()){
            doc.replace(index,text1[count1].length()+1,"");
            count1++;
          }
        // replaced
        } else if(delta instanceof ChangeDelta){
          while(count1 != orgRange.getTo()){
View Full Code Here


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

          while(count1 != orgRange.getTo()){
            doc.replace(index,text1[count1].length()+1,"");
            count1++;
          }
          while(count2 != revRange.getTo()){
            doc.replace(index,0,text2[count2] + "\n");
            index = index + text2[count2].length() + 1;
            count2++;
          }
        }
        count1 = orgRange.getTo();
View Full Code Here

    RGB color = dialog.open();
    if(color!=null){
      IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
      ITextSelection sel = (ITextSelection)editor.getSelectionProvider().getSelection();
      try {
        doc.replace(sel.getOffset(), 0, HTMLUtil.toHex(color));
      } catch(Exception ex){
        HTMLPlugin.logException(ex);
      }
    }
  }
View Full Code Here

        if(text.startsWith("//")){
          text = text.replaceAll("(^|\r\n|\r|\n)//","$1");
        } else {
          text = text.replaceAll("(^|\r\n|\r|\n)(.+?)","$1//$2");
        }
        doc.replace(sel.getOffset(),sel.getLength(),text);
      } catch (BadLocationException e) {
        HTMLPlugin.logException(e);
      }
    }
  } 
View Full Code Here

                int lineStart = docSelection.getStartLine();
                int lineEnd = docSelection.getEndLine();
                boolean shouldComment = shouldComment(lineStart, lineEnd, doc);
                for (int i = lineStart; i <= lineEnd; i++) {
                    if (shouldComment)
                        doc.replace(doc.getLineOffset(i), 0, "#");
                    else
                        doc.replace(doc.getLineOffset(i), 1, "");
                }
            } catch (BadLocationException ble) {
                logger.logError("Error while trying to comment/uncomment code", ble);
View Full Code Here

                boolean shouldComment = shouldComment(lineStart, lineEnd, doc);
                for (int i = lineStart; i <= lineEnd; i++) {
                    if (shouldComment)
                        doc.replace(doc.getLineOffset(i), 0, "#");
                    else
                        doc.replace(doc.getLineOffset(i), 1, "");
                }
            } catch (BadLocationException ble) {
                logger.logError("Error while trying to comment/uncomment code", ble);
            }
        }
View Full Code Here

            }

            for (ITextOperation textOp : textOps) {
                try {
                    if (textOp instanceof DeleteOperation)
                        doc.replace(textOp.getPosition(),
                            textOp.getTextLength(), "");
                    if (textOp instanceof InsertOperation)
                        doc.replace(textOp.getPosition(), 0, textOp.getText());
                } catch (BadLocationException e) {
                    log.error("Invalid location for " + textOp);
View Full Code Here

                try {
                    if (textOp instanceof DeleteOperation)
                        doc.replace(textOp.getPosition(),
                            textOp.getTextLength(), "");
                    if (textOp instanceof InsertOperation)
                        doc.replace(textOp.getPosition(), 0, textOp.getText());
                } catch (BadLocationException e) {
                    log.error("Invalid location for " + textOp);
                }
            }
        } finally {
View Full Code Here

                }
            }

            // Try to replace
            try {
                doc.replace(offset, replacedText.length(), text);
            } catch (BadLocationException e) {
                log.error(String.format(
                    "Could not apply TextEdit at %d-%d of document "
                        + "with length %d.\nWas supposed to replace"
                        + " '%s' with '%s'.", offset,
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.