1 4 package org.oddjob.designer.elements; 5 6 import org.oddjob.designer.model.DesignDefinition; 7 import org.oddjob.designer.model.DesignElementAttribute; 8 import org.oddjob.designer.model.TextInput; 9 10 11 14 abstract public class MultiLineBaseDE extends DesignElementAttribute { 15 16 private String cache; 17 18 public boolean hasDetail() { 19 return true; 20 } 21 22 public DesignDefinition detail() { 23 return new TextInput("Text") { 24 public String getText() { 25 return cache; 26 } 27 public void setText(String text) { 28 attribute(text); 29 this.setChanged(); 30 this.notifyObservers(); 31 } 32 }; 33 } 34 35 public void attribute(String attr) { 36 cache = attr; 37 } 38 39 42 public String attribute() { 43 if (cache == null) { 44 return cache; 45 } 46 if (cache.indexOf('\n') == -1) { 47 return cache; 48 } 49 return null; 50 } 51 52 58 public void addText(String text) { 59 String sofar = ""; 60 if (cache != null) { 61 sofar = attribute(); 62 } 63 cache = sofar + text; 64 } 65 66 public String getValue() { 67 if (cache == null) { 68 return cache; 69 } 70 if (cache.indexOf('\n') == -1) { 71 return cache; 72 } 73 return null; 74 } 75 76 public String text() { 77 if (cache == null) { 78 return null; 79 } 80 if (cache.indexOf('\n') != -1) { 81 return cache; 82 } 83 return null; 84 } 85 86 public void setValue(String value) { 87 cache = value; 88 } 89 90 public void clear() { 91 cache = null; 92 super.clear(); 93 } 94 95 } 96 | Popular Tags |