/** * Tests for <code>PlainView</code> repaints more lines than necessary. * * <p>If a character (not a new line) is inserted into document, document structure will not * change, or in other words the number of text lines will stay the same. In this case only the * modified line needs to be repainted but <code>PlainView</code> repaints all following lines as * well. */ public void testInsertUpdateExtraRepaint() throws BadLocationException { doc.insertString(0, "1:0123\n2:\n3:abcdefg", null); view.updateMetrics(); doc.insertString(0, "^", null); view.insertUpdate(event, shape, null); lineRange.check(0, 0, shape, container); }
@Override public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f) { super.insertUpdate(e, a, f); JavaDocument d = (JavaDocument) e.getDocument(); if (d.isNeedsRedraw()) { getContainer().repaint(); d.setNeedsRedraw(false); } }
/** * Gives notification that something was inserted into the document in a location that this view * is responsible for. * * @param changes the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children * @see View#insertUpdate */ public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) { super.insertUpdate(changes, adjustAllocation(a), f); updateVisibilityModel(); }
/** * Tests for <code>PlainView.insertUpdate</code> throws NPE. * * <p>If a change occured outside the widest line and document structure was not changed, <code> * insertUpdate</code> throws NPE when processing the notification. */ public void testInsertUpdateNPE() throws BadLocationException { doc.insertString(0, "1:0123\n2:\n3:abcdefg", null); view.updateMetrics(); doc.insertString(0, "^", null); view.insertUpdate(event, shape, null); }