01: package desktop;
02:
03: import org.wings.SComponent;
04: import org.wings.SURLIcon;
05: import org.wings.event.SDocumentEvent;
06: import org.wings.event.SDocumentListener;
07:
08: import java.beans.PropertyChangeEvent;
09: import java.beans.PropertyChangeListener;
10:
11: public class EditorItem extends AbstractDesktopItem {
12:
13: protected EditorPanel editorPane;
14:
15: public EditorItem() {
16: super ();
17:
18: pref.put(TOOL, "EditorTool");
19: addPropertyChangeListener(new PropertyChangeListener() {
20: public void propertyChange(PropertyChangeEvent e) {
21: if (e.getPropertyName().equals(TEXT))
22: ((EditorPanel) getComponent()).setText((String) e
23: .getNewValue());
24:
25: }
26: });
27:
28: putValue(NAME, "Editor ["
29: + ((EditorPanel) getComponent()).getEditorNr() + "]");
30: putValue(ICON, new SURLIcon("../icons/penguin.png"));
31: }
32:
33: public EditorItem(String name) {
34: super (name);
35: addPropertyChangeListener(new PropertyChangeListener() {
36: public void propertyChange(PropertyChangeEvent e) {
37: if (e.getPropertyName().equals(TEXT))
38: ((EditorPanel) getComponent()).setText((String) e
39: .getNewValue());
40:
41: }
42: });
43: }
44:
45: public SComponent getComponent() {
46: if (editorPane == null) {
47: editorPane = new EditorPanel();
48:
49: editorPane.getTextArea().addDocumentListener(
50: new SDocumentListener() {
51:
52: public void changedUpdate(SDocumentEvent e) {
53: putValue(TEXT, editorPane.getText());
54:
55: }
56:
57: public void insertUpdate(SDocumentEvent e) {
58: putValue(TEXT, editorPane.getText());
59:
60: }
61:
62: public void removeUpdate(SDocumentEvent e) {
63: putValue(TEXT, editorPane.getText());
64:
65: }
66:
67: });
68:
69: }
70:
71: return editorPane;
72: }
73:
74: public void activated() {
75: }
76:
77: public void fixContent() {
78: System.out.println(editorPane.getText());
79: putValue(TEXT, editorPane.getText());
80: }
81: }
|