View Javadoc

1   
2   package org.catacomb.druid.gui.edit;
3   
4   import org.catacomb.druid.event.TextActor;
5   import org.catacomb.druid.swing.DTextArea;
6   import org.catacomb.interlish.content.StringValue;
7   import org.catacomb.interlish.structure.*;
8   import org.catacomb.report.E;
9   
10  
11  import java.awt.Color;
12  
13  
14  public class DruTextArea extends DruGCPanel
15      implements TextActor, Ablable, TextArea, ValueWatcher {
16      static final long serialVersionUID = 1001;
17  
18      DTextArea dTextArea;
19  
20  
21      StringValue stringValue;
22  
23  
24      public DruTextArea(String mn, int width, int height) {
25          super();
26  
27          setActionMethod(mn);
28  
29          dTextArea = new DTextArea(width, height, DTextArea.SCROLLABLE);
30  
31          setSingle();
32          addDComponent(dTextArea);
33  
34          dTextArea.setLineBorder(0xc0c0c0);
35  
36          dTextArea.setTextActor(this);
37      }
38  
39  
40  
41  
42      public void valueChangedBy(Value pv, Object src) {
43          if (src == this) {
44  
45          } else {
46              if (stringValue == pv) {
47                  if (stringValue == null) {
48                      dTextArea.setText("");
49                      dTextArea.setEnabled(false);
50                  } else {
51                      dTextArea.setText(stringValue.getString());
52  
53                      if (src.equals("HIGHLIGHT")) {  // ADHOC
54                          dTextArea.highlightLine(stringValue.getHighlight());
55                      } else {
56                          dTextArea.clearHighlight();
57                      }
58  
59                  }
60              } else {
61                  E.error("value changed by called with mismatched value");
62              }
63          }
64      }
65  
66  
67  
68  
69  
70      public void setStringValue(StringValue sv) {
71          if (stringValue != null) {
72              stringValue.removeValueWatcher(this);
73          }
74          stringValue = sv;
75          if (stringValue == null) {
76              dTextArea.setEnabled(false);
77          } else {
78              dTextArea.setText(stringValue.getString());
79              stringValue.addValueWatcher(this);
80          }
81      }
82  
83  
84  
85  
86  
87      public void textChanged(String s) {
88          stringValue.reportableSetString(dTextArea.getText(), this);
89  
90          // valueChange(dTextArea.getText()); // ever called?
91      }
92  
93  
94      public void textEntered(String s) {
95  
96      }
97  
98      public void textEdited(String s) {
99  
100     }
101 
102 
103 
104     public void setBg(Color c) {
105         dTextArea.setBg(c);
106         super.setBg(c);
107     }
108 
109 
110     public void able(boolean b) {
111         dTextArea.setEnabled(b);
112     }
113 
114     public void setEditable(boolean b) {
115         dTextArea.setEditable(b);
116         dTextArea.setEnabled(b);
117     }
118 
119     public void setAntialiased() {
120         dTextArea.setAntialiased();
121     }
122 
123     public void setPadding(int padding) {
124         dTextArea.setPadding(padding);
125 
126     }
127 
128     public void setFontSize(int fs) {
129         dTextArea.setFontSize(fs);
130     }
131 
132 
133 
134 
135     public void focusGained() {
136         // TODO Auto-generated method stub
137 
138     }
139 
140 
141 
142 
143     public void focusLost() {
144         // TODO Auto-generated method stub
145 
146     }
147 
148 }