1 package thinlet.drafts; 2 3 import thinlet.*; 4 5 8 public class EventLogger { 9 10 public void buttonAction(String text) { log("button action " + text); } 11 public void selectAction(String name, String text) { log(name + " select " + text); } 12 public void doubleClick(String name, String text) { log(name + " double click " + text); } 13 public void expand(String text) { log("expand " + text); } 14 public void collapse(String text) { log("collapse " + text); } 15 public void insert(String text, int start, int end) { log("insert " + text + " " + start + " " + end); } 16 public void remove(String text, int start, int end) { log("remove " + text + " " + start + " " + end); } 17 public void caret(String text, int start, int end) { log("caret " + text + " " + start + " " + end); } 18 public void perform(String text) { log("perform " + text); } 19 public void tabChanged(int selected) { log("tab changed " + selected); } 20 public void menuAction(String text) { log("menuitem selected " + text); } 21 22 private Thinlet thinlet; 23 private Object logarea; 24 25 28 public void setLogArea(Thinlet thinlet, Object logarea) { 29 this.thinlet = thinlet; 30 this.logarea = logarea; 31 } 32 33 36 private void log(String text) { 37 StringBuffer update = new StringBuffer (thinlet.getString(logarea, "text")); 38 if (update.length() > 0) { update.append('\n'); } 39 update.append(text); 40 thinlet.setString(logarea, "text", update.toString()); 41 int length = update.length(); thinlet.setInteger(logarea, "start", length); 43 thinlet.setInteger(logarea, "end", length); 44 } 45 46 public void showLink(Thinlet thinlet) { 47 log("link pressed"); 48 } 49 } | Popular Tags |