1 19 20 package org.netbeans.modules.xml.multiview; 21 22 import javax.swing.*; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 26 31 public abstract class ItemCheckBoxHelper implements ActionListener , Refreshable { 32 private JCheckBox checkBox; 33 private XmlMultiViewDataSynchronizer synchronizer; 34 35 41 public ItemCheckBoxHelper(XmlMultiViewDataSynchronizer synchronizer, JCheckBox checkBox) { 42 this.synchronizer = synchronizer; 43 this.checkBox = checkBox; 44 checkBox.addActionListener(this); 45 setValue(getItemValue()); 46 } 47 48 51 public final void actionPerformed(ActionEvent e) { 52 final boolean value = getValue(); 53 if (value != getItemValue()) { 54 setItemValue(value); 55 synchronizer.requestUpdateData(); 56 } 57 } 58 59 64 public void setValue(boolean itemValue) { 65 checkBox.setSelected(itemValue); 66 } 67 68 73 public JCheckBox getCheckBox() { 74 return checkBox; 75 } 76 77 82 public boolean getValue() { 83 return checkBox.isSelected(); 84 } 85 86 91 public abstract boolean getItemValue(); 92 93 98 public abstract void setItemValue(boolean value); 99 100 public void refresh() { 101 setValue(getItemValue()); 102 } 103 } 104 | Popular Tags |