1 19 package org.netbeans.modules.j2ee.ddloaders.multiview; 20 21 import javax.swing.text.PlainDocument ; 22 import javax.swing.text.BadLocationException ; 23 import javax.swing.text.AttributeSet ; 24 25 28 public abstract class NonEditableDocument extends PlainDocument { 29 30 String text = null; 31 32 protected abstract String retrieveText(); 33 34 protected NonEditableDocument() { 35 init(); 36 } 37 38 public void init() { 39 String s = retrieveText(); 40 if (s == null) { 41 s = ""; 42 } 43 if (!s.equals(text)) { 44 text = s; 45 try { 46 super.remove(0, super.getLength()); 47 super.insertString(0, s, null); 48 } catch (BadLocationException e) { 49 50 } 51 } 52 } 53 54 public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { 55 56 } 57 58 public void remove(int offs, int len) throws BadLocationException { 59 60 } 61 } 62 | Popular Tags |