1 package discRack.presentation.delements; 2 3 import discRack.presentation.dpanels.*; 4 5 import javax.swing.JPanel ; 6 import javax.swing.JComponent ; 7 8 import java.io.*; 9 import java.util.*; 10 11 17 public class DSimpleElement { 18 19 protected String name; 20 protected Object value; 21 22 protected boolean isRequired=false; 23 protected boolean isReadOnly=false; 24 25 private boolean isDCheckPanel=false; 26 private boolean isPassword=false; 27 28 public DSimpleElement (String name) { 29 this (name,false); 30 } 31 32 public DSimpleElement (String name,boolean isDCheckPanel) { 33 this(name,isDCheckPanel,false); 34 } 35 36 public DSimpleElement (String name,boolean isDCheckPanel,boolean isPassword) { 37 this.name=name; 38 this.isDCheckPanel=isDCheckPanel; 39 this.isPassword=isPassword; 40 value=new String (); 41 } 42 43 public void setReadOnly (boolean ro) { 44 isReadOnly=ro; 45 } 46 47 public boolean isReadOnly () { 48 return isReadOnly; 49 } 50 51 public void setRequired (boolean r) { 52 isRequired=r; 53 } 54 55 public boolean isRequired () { 56 return isRequired; 57 } 58 59 public boolean isEmpty () { 60 return !(value!=null && value.toString().trim().length()>0); 61 } 62 63 public boolean isValid () { 64 return true; 65 } 66 67 public boolean setDODSElements (DPanel p) { 68 return true; 69 } 70 71 public DPanel getPanel () { 72 if (!isDCheckPanel) { 73 return new DTextPanel(this,isPassword); 74 } else { 75 return new DCheckPanel(this); 76 } 77 } 78 79 public void setValue(Object v) { 80 if (v!=null) { 81 value=v; 82 } else { 83 value=""; 84 } 85 } 86 87 public Object toValue() { 88 return value; 89 } 90 91 public String toName () { 92 return name; 93 } 94 95 public String toString () { 96 if (value!=null) { 97 return value.toString().trim(); 98 } 99 else { 100 return name; 101 } 102 } 103 104 } 105 | Popular Tags |