01: package jtaDiscRack.presentation.delements;
02:
03: import jtaDiscRack.presentation.dpanels.*;
04:
05: /**
06: * Represents a simple element which have a panel for it's editing.
07: *
08: * @author Sasa Bojanic
09: * @version 1.0
10: */
11: public class DSimpleElement {
12:
13: protected String name;
14: protected Object value;
15:
16: protected boolean isRequired = false;
17: protected boolean isReadOnly = false;
18:
19: private boolean isDCheckPanel = false;
20: private boolean isPassword = false;
21:
22: public DSimpleElement(String name) {
23: this (name, false);
24: }
25:
26: public DSimpleElement(String name, boolean isDCheckPanel) {
27: this (name, isDCheckPanel, false);
28: }
29:
30: public DSimpleElement(String name, boolean isDCheckPanel,
31: boolean isPassword) {
32: this .name = name;
33: this .isDCheckPanel = isDCheckPanel;
34: this .isPassword = isPassword;
35: value = new String();
36: }
37:
38: public void setReadOnly(boolean ro) {
39: isReadOnly = ro;
40: }
41:
42: public boolean isReadOnly() {
43: return isReadOnly;
44: }
45:
46: public void setRequired(boolean r) {
47: isRequired = r;
48: }
49:
50: public boolean isRequired() {
51: return isRequired;
52: }
53:
54: public boolean isEmpty() {
55: return !(value != null && value.toString().trim().length() > 0);
56: }
57:
58: public boolean isValid() {
59: return true;
60: }
61:
62: public boolean setDODSElements(DPanel p) {
63: return true;
64: }
65:
66: public DPanel getPanel() {
67: if (!isDCheckPanel) {
68: return new DTextPanel(this , isPassword);
69: } else {
70: return new DCheckPanel(this );
71: }
72: }
73:
74: public void setValue(Object v) {
75: if (v != null) {
76: value = v;
77: } else {
78: value = "";
79: }
80: }
81:
82: public Object toValue() {
83: return value;
84: }
85:
86: public String toName() {
87: return name;
88: }
89:
90: public String toString() {
91: if (value != null) {
92: return value.toString().trim();
93: } else {
94: return name;
95: }
96: }
97:
98: }
|