01: package thinlet.drafts;
02:
03: import thinlet.*;
04:
05: /**
06: *
07: */
08: public class EventLogger {
09:
10: public void buttonAction(String text) {
11: log("button action " + text);
12: }
13:
14: public void selectAction(String name, String text) {
15: log(name + " select " + text);
16: }
17:
18: public void doubleClick(String name, String text) {
19: log(name + " double click " + text);
20: }
21:
22: public void expand(String text) {
23: log("expand " + text);
24: }
25:
26: public void collapse(String text) {
27: log("collapse " + text);
28: }
29:
30: public void insert(String text, int start, int end) {
31: log("insert " + text + " " + start + " " + end);
32: }
33:
34: public void remove(String text, int start, int end) {
35: log("remove " + text + " " + start + " " + end);
36: }
37:
38: public void caret(String text, int start, int end) {
39: log("caret " + text + " " + start + " " + end);
40: }
41:
42: public void perform(String text) {
43: log("perform " + text);
44: }
45:
46: public void tabChanged(int selected) {
47: log("tab changed " + selected);
48: }
49:
50: public void menuAction(String text) {
51: log("menuitem selected " + text);
52: }
53:
54: private Thinlet thinlet;
55: private Object logarea;
56:
57: /**
58: * Cache thinlet and the log textarea
59: */
60: public void setLogArea(Thinlet thinlet, Object logarea) {
61: this .thinlet = thinlet;
62: this .logarea = logarea;
63: }
64:
65: /**
66: * Append the given text to the log textarea
67: */
68: private void log(String text) {
69: StringBuffer update = new StringBuffer(thinlet.getString(
70: logarea, "text"));
71: if (update.length() > 0) {
72: update.append('\n');
73: }
74: update.append(text);
75: thinlet.setString(logarea, "text", update.toString());
76: int length = update.length(); // to scroll down
77: thinlet.setInteger(logarea, "start", length);
78: thinlet.setInteger(logarea, "end", length);
79: }
80:
81: public void showLink(Thinlet thinlet) {
82: log("link pressed");
83: }
84: }
|