Beispiel #1
0
 private void insertString(int pos, String str) {
   Document doc = getDocument();
   try {
     doc.insertString(pos, str, null);
   } catch (Exception e) {
     Debug.error(me + "insertString: Problem while trying to insert at pos\n%s", e.getMessage());
   }
 }
Beispiel #2
0
 private void checkCompletion(java.awt.event.KeyEvent ke) throws BadLocationException {
   Document doc = getDocument();
   Element root = doc.getDefaultRootElement();
   int pos = getCaretPosition();
   int lineIdx = root.getElementIndex(pos);
   Element line = root.getElement(lineIdx);
   int start = line.getStartOffset(), len = line.getEndOffset() - start;
   String strLine = doc.getText(start, len - 1);
   Debug.log(9, "[" + strLine + "]");
   if (strLine.endsWith("find") && ke.getKeyChar() == '(') {
     ke.consume();
     doc.insertString(pos, "(", null);
     ButtonCapture btnCapture = new ButtonCapture(this, line);
     insertComponent(btnCapture);
     doc.insertString(pos + 2, ")", null);
   }
 }
Beispiel #3
0
 // TODO not used
 public void appendString(String str) {
   Document doc = getDocument();
   try {
     int start = doc.getLength();
     doc.insertString(doc.getLength(), str, null);
     int end = doc.getLength();
     // end = parseLine(start, end, patHistoryBtnStr);
   } catch (Exception e) {
     Debug.error(me + "appendString: Problem while trying to append\n%s", e.getMessage());
   }
 }
Beispiel #4
0
 private void indent(int startLine, int endLine, int level) {
   Document doc = getDocument();
   String strIndent = "";
   if (level > 0) {
     for (int i = 0; i < level; i++) {
       strIndent += "  ";
     }
   } else {
     Debug.error("negative indentation not supported yet!!");
   }
   for (int i = startLine; i < endLine; i++) {
     try {
       int off = getLineStartOffset(i);
       if (level > 0) {
         doc.insertString(off, strIndent, null);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Beispiel #5
0
 private void expandTab() throws BadLocationException {
   int pos = getCaretPosition();
   Document doc = getDocument();
   doc.remove(pos - 1, 1);
   doc.insertString(pos - 1, _tabString, null);
 }