1 14 package org.compiere.grid.ed; 15 16 import java.awt.*; 17 import java.awt.event.*; 18 import javax.swing.*; 19 import java.beans.*; 20 21 import org.compiere.util.*; 22 import org.compiere.plaf.*; 23 import org.compiere.swing.*; 24 25 31 public class VCheckBox extends CCheckBox 32 implements VEditor, ActionListener 33 { 34 37 public VCheckBox() 38 { 39 this("", false, false, true, "", null, false); 40 } 42 52 public VCheckBox(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, 53 String title, String description, boolean tableEditor) 54 { 55 super(); 56 super.setName(columnName); 57 m_columnName = columnName; 58 setMandatory(mandatory); 59 if (isReadOnly || !isUpdateable) 61 setEditable(false); 62 else 63 setEditable(true); 64 65 if (!tableEditor) 67 { 68 setText(title); 69 if (description != null && description.length() > 0) 70 setToolTipText(description); 71 } 72 else 73 { 74 setHorizontalAlignment(JLabel.CENTER); 75 } 76 this.addActionListener(this); 78 } 80 83 public void dispose() 84 { 85 } 87 private String m_columnName; 88 89 93 public void setEditable (boolean value) 94 { 95 super.setReadWrite(value); 96 } 98 102 public boolean isEditable() 103 { 104 return super.isReadWrite(); 105 } 107 111 public void setValue(Object value) 112 { 113 boolean sel = false; 114 if (value != null && value.toString().equals("Y")) 115 sel = true; 116 setSelected(sel); 117 } 119 123 public void propertyChange (PropertyChangeEvent evt) 124 { 125 if (evt.getPropertyName().equals(org.compiere.model.MField.PROPERTY)) 126 setValue(evt.getNewValue()); 127 } 129 133 public Object getValue() 134 { 135 if (isSelected()) 136 return "Y"; 137 return "N"; 138 } 140 144 public String getDisplay() 145 { 146 if (isSelected()) 147 return "Y"; 148 return "N"; 149 } 151 154 public void setBackground() 155 { 156 } 158 162 public void actionPerformed(ActionEvent e) 163 { 164 try 166 { 167 fireVetoableChange(m_columnName, null, getValue()); 168 } 169 catch (PropertyVetoException pve) 170 { 171 } 172 } 174 178 public void setField (org.compiere.model.MField mField) 179 { 180 } 182 } | Popular Tags |