コード例 #1
0
    public void insertString(FilterBypass fb, int offs, String str, AttributeSet a)
        throws BadLocationException {
      if ("\n".equals(str)) {
        str = addWhiteSpace(fb.getDocument(), offs);
        if (fb.getDocument().getText(offs - 2, 1).equals("{")) {
          str = str + "Meow";
        }
      }

      super.insertString(fb, offs, str, a);
    }
 public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a)
     throws BadLocationException {
   if (isValidTemperature(false, fb, offs, str, length)) {
     fb.replace(offs, length, str, a);
     doValueUpdate(fb);
   }
 } // replace
 public void insertString(FilterBypass fb, int offs, String str, AttributeSet a)
     throws BadLocationException {
   if (isValidTemperature(true, fb, offs, str, 0)) {
     fb.insertString(offs, str, a);
     doValueUpdate(fb);
   }
 } // insertString
コード例 #4
0
 @Override
 public void moveDot(FilterBypass fb, int dot, Position.Bias bias) {
   if (dot >= maxSize) {
     fb.setDot(0, bias);
     moveFocus();
     return;
   }
   super.moveDot(fb, dot, bias);
 }
コード例 #5
0
  @Override
  public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs)
      throws BadLocationException {
    Document doc = fb.getDocument();
    StringBuilder sb = new StringBuilder();
    sb.append(doc.getText(0, doc.getLength()));
    sb.replace(offset, offset + length, text);

    if (test(sb.toString())) super.replace(fb, offset, length, text, attrs);
    else Toolkit.getDefaultToolkit().beep();
  }
コード例 #6
0
  @Override
  public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
    Document doc = fb.getDocument();
    StringBuilder sb = new StringBuilder();
    sb.append(doc.getText(0, doc.getLength()));
    sb.delete(offset, offset + length);

    if (isInteger(sb.toString())) {
      super.remove(fb, offset, length);
    }
  }
コード例 #7
0
  @Override
  public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
      throws BadLocationException {
    Document doc = fb.getDocument();
    StringBuilder sb = new StringBuilder();
    sb.append(doc.getText(0, doc.getLength()));
    sb.insert(offset, string);

    if (test(sb.toString())) super.insertString(fb, offset, string, attr);
    else Toolkit.getDefaultToolkit().beep();
  }
 /**
  * This function inserts or replaces the user's input in a string buffer, to create the text
  * which would be on screen if we allowed it. We declare to throw bad location due to
  * doc.getText, but since the paramters are coming from the farmework, that should never
  * happen.... in theory. If insert is true we insert, if false we replace. Length parameter only
  * used when replacing.
  */
 private StringBuffer getTextPrototype(
     boolean insert, FilterBypass fb, int offs, String str, int length)
     throws BadLocationException {
   Document doc = fb.getDocument();
   String text = doc.getText(0, doc.getLength());
   StringBuffer sb = new StringBuffer(text);
   if (insert) {
     sb.insert(offs, str);
   } else {
     sb.replace(offs, offs + length, str);
   }
   return sb;
 } // end of getTextPrototype
コード例 #9
0
ファイル: IntegerFilter.java プロジェクト: jon914/polydes
  @Override
  public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
    Document doc = fb.getDocument();
    StringBuilder sb = new StringBuilder();
    sb.append(doc.getText(0, doc.getLength()));
    sb.delete(offset, offset + length);

    if (test(sb.toString())) {
      super.remove(fb, offset, length);
    } else {
      // warn the user and don't allow the insert
    }
  }
コード例 #10
0
ファイル: IntegerFilter.java プロジェクト: jon914/polydes
  @Override
  public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
      throws BadLocationException {
    Document doc = fb.getDocument();
    StringBuilder sb = new StringBuilder();
    sb.append(doc.getText(0, doc.getLength()));
    sb.insert(offset, string);

    if (test(sb.toString())) {
      super.insertString(fb, offset, string, attr);
    } else {
      // warn the user and don't allow the insert
    }
  }
コード例 #11
0
  @Override
  public void insertString(
      FilterBypass filterBypass, int offset, String text, AttributeSet attributeSet)
      throws BadLocationException {
    text = trimHexadecimal(text);
    Document document = filterBypass.getDocument();
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(document.getText(0, document.getLength()));
    stringBuilder.insert(offset, text);

    if (isValidInput(stringBuilder.toString(), 0)) {
      super.insertString(filterBypass, offset, text, attributeSet);
    } else {
      Toolkit.getDefaultToolkit().beep();
    }
  }
    /**
     * Updates the shared value instance if updateValue is true. Always forces the redraw of
     * everything.
     */
    protected void doValueUpdate(FilterBypass fb) throws BadLocationException {
      Document doc = fb.getDocument();
      String text = doc.getText(0, doc.getLength());
      if (text.isEmpty()) {
        text = "0";
      }

      if (updateValue == true) {
        try {
          Double value = new Double(text);
          double newValue = multiplier.getValueToBeSet(value.doubleValue());
          cValue.setValue(newValue);
        } catch (NumberFormatException e) {
          // do nothing, since we allow '-'
        }
      }
      topContainer.forceRedraw();
    }
コード例 #13
0
    public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a)
        throws BadLocationException {
      if ("\n".equals(str)) str = addWhiteSpace(fb.getDocument(), offs);

      super.replace(fb, offs, length, str, a);
    }
コード例 #14
0
 public void setDot(FilterBypass fb, int dot, Bias bias) {
   if (dot < initialPos) {
     dot = Math.min(initialPos, run.getDocument().getLength());
   }
   fb.setDot(dot, bias);
 }
コード例 #15
0
 public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
   fb.remove(offset, length);
 }
コード例 #16
0
 public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
     throws BadLocationException {
   fb.insertString(offset, string, attr);
 }