1 package org.catacomb.druid.gui.edit;
2
3 import org.catacomb.druid.event.LabelActor;
4 import org.catacomb.druid.swing.DInt;
5 import org.catacomb.interlish.content.IntegerValue;
6 import org.catacomb.interlish.structure.*;
7 import org.catacomb.report.E;
8
9
10 import java.awt.Color;
11
12 public class DruInt extends DruGCPanel
13 implements LabelActor, Ablable, IntegerValueEditor, ValueWatcher {
14 static final long serialVersionUID = 1001;
15
16 DInt dInt;
17
18 public LabelActor labelActor;
19
20 IntegerValue integerValue;
21
22
23 public DruInt(int val, int min, int max, String scale) {
24 super();
25
26 dInt = new DInt(val, min, max, scale);
27
28 addSingleDComponent(dInt);
29 dInt.setLabelActor(this);
30 }
31
32
33
34 public void setProperties(int val, int min, int max,
35 String scale, boolean strictLims) {
36 dInt.setProperties(val, min, max, scale, strictLims);
37 }
38
39
40
41 public void valueChangedBy(Value pv, Object src) {
42 if (src == this) {
43 valueChange(integerValue.getInteger());
44
45 } else {
46 if (integerValue == pv) {
47 if (integerValue == null) {
48 dInt.setValue(0);
49 dInt.setEnabled(false);
50 } else {
51 dInt.setValue(integerValue.getInteger());
52 }
53 } else {
54 E.error("value changed by called with mismatched value");
55 }
56 }
57 }
58
59
60 public void setIntegerValue(IntegerValue dv) {
61 if (integerValue != null) {
62 integerValue.removeValueWatcher(this);
63 }
64 integerValue = dv;
65 if (integerValue == null) {
66 dInt.setEnabled(false);
67 } else {
68 dInt.setValue(integerValue.getInteger());
69 integerValue.addValueWatcher(this);
70 }
71 }
72
73
74
75
76 public void setLabel(String s) {
77 dInt.setLabel(s);
78 }
79
80 public void setEditable(boolean b) {
81 dInt.setEditable(b);
82 dInt.setEnabled(b);
83 }
84
85
86 public void setBg(Color c) {
87 dInt.setBg(c);
88 super.setBg(c);
89 }
90
91
92 public void able(boolean b) {
93 dInt.setEnabled(b);
94 }
95
96
97
98 public void labelAction(String s, boolean b) {
99 int i = dInt.getValue();
100
101 if (integerValue != null) {
102 integerValue.reportableSetInteger(i, this);
103 }
104
105 }
106
107
108 }