1 19 20 package org.netbeans.lib.lexer.test; 21 22 import javax.swing.text.AttributeSet ; 23 import javax.swing.text.BadLocationException ; 24 import javax.swing.text.PlainDocument ; 25 import org.netbeans.lib.editor.util.swing.DocumentUtilities; 26 27 public class ModificationTextDocument extends PlainDocument { 28 29 protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr) { 30 super.insertUpdate(chng, attr); 31 DocumentUtilities.addEventPropertyStorage(chng); 32 try { 33 DocumentUtilities.putEventProperty(chng, String .class, 34 getText(chng.getOffset(), chng.getLength())); 35 } catch (BadLocationException e) { 36 e.printStackTrace(); 37 throw new IllegalStateException (e.toString()); 38 } 39 } 40 41 protected void removeUpdate(DefaultDocumentEvent chng) { 42 super.removeUpdate(chng); 43 DocumentUtilities.addEventPropertyStorage(chng); 44 try { 45 DocumentUtilities.putEventProperty(chng, String .class, 46 getText(chng.getOffset(), chng.getLength())); 47 } catch (BadLocationException e) { 48 e.printStackTrace(); 49 throw new IllegalStateException (e.toString()); 50 } 51 } 52 53 } | Popular Tags |