public void remove(DocumentFilter.FilterBypass fb, int offs, int length) throws BadLocationException { String str = ""; if (isValidPostiveNumber(false, fb, offs, str, length)) { fb.remove(offs, length); doValueUpdate(fb); } } // End of remove
/** {@inheritDoc} */ public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { String text = fb.getDocument().getText(offset, length); int index = text.indexOf(":"); if (index == -1) { fb.remove(offset, length); } else { // index value is relative to offset if (index > 0) { fb.remove(offset, index); } if (index < length - 1) { fb.remove(offset + index + 1, length - index - 1); } } updateCaretPosition(fb); }
private void trimPosition( DocumentFilter.FilterBypass fb, String newText, int offset, int previousLength) throws BadLocationException { String allText = fb.getDocument().getText(0, fb.getDocument().getLength()); int index = allText.indexOf(':'); if (index != -1 && newText.length() == 1) { int minuteLength = allText.length() - index - 1; int hourLength = index; if (minuteLength > 2 || hourLength > 2) { if (offset < previousLength) { fb.remove(offset + 1, 1); } else { fb.remove(previousLength, 1); } } } updateCaretPosition(fb); }
public void remove(DocumentFilter.FilterBypass fb, int offs, int length) throws BadLocationException { // Insertion is just replacement of a 0 lenght string. // Delete is a kind of insertion. // It's just replacement of non-zero lenght string with a 0 lenght string. // So we will insert a 0 length text. String str = ""; // And we pass in false for insertion which means replacement. if (isValidTemperature(false, fb, offs, str, length)) { fb.remove(offs, length); doValueUpdate(fb); } } // End of remove