1 package net.suberic.pooka.gui.filter; 2 3 import javax.swing.*; 4 import java.util.Properties ; 5 6 9 public class BounceFilterEditor extends FilterEditor { 10 JTextField addressField; 11 JCheckBox deleteField; 12 13 public static String FILTER_CLASS = "net.suberic.pooka.filter.BounceFilterAction"; 14 15 19 public void configureEditor(net.suberic.util.gui.propedit.PropertyEditorManager newManager, String propertyName) { 20 property = propertyName; 21 manager = newManager; 22 23 String originalAddressString = manager.getProperty(propertyName + ".targetAddresses", ""); 24 25 addressField = new JTextField(originalAddressString); 26 27 boolean originalDeleteValue = manager.getProperty(propertyName + ".removeBounced", "false").equalsIgnoreCase("true"); 28 29 deleteField = new JCheckBox(); 30 deleteField.setSelected(originalDeleteValue); 31 32 SpringLayout layout = new SpringLayout(); 33 this.setLayout(layout); 34 35 this.add(addressField); 36 this.add(deleteField); 37 38 layout.putConstraint(SpringLayout.NORTH, addressField, 0, SpringLayout.NORTH, this); 39 layout.putConstraint(SpringLayout.WEST, addressField, 0, SpringLayout.WEST, this); 40 layout.putConstraint(SpringLayout.SOUTH, this, 0, SpringLayout.SOUTH, addressField); 41 layout.putConstraint(SpringLayout.WEST, deleteField, 5, SpringLayout.EAST, addressField); 42 layout.putConstraint(SpringLayout.EAST, this, 5, SpringLayout.EAST, deleteField); 43 44 this.setPreferredSize(new java.awt.Dimension (150, addressField.getMinimumSize().height)); 45 this.setMaximumSize(new java.awt.Dimension (Integer.MAX_VALUE, addressField.getMinimumSize().height)); 46 } 47 48 51 public java.util.Properties getValue() { 52 Properties props = new Properties (); 53 54 String oldClassName = manager.getProperty(property + ".class", ""); 55 if (!oldClassName.equals(FILTER_CLASS)) 56 props.setProperty(property + ".class", FILTER_CLASS); 57 58 String originalAddressString = manager.getProperty(property + ".targetAddresses", ""); 59 if (addressField.getText() != originalAddressString) { 60 props.setProperty(property + ".targetAddresses", addressField.getText()); 61 } 62 63 boolean originalDeleteValue = manager.getProperty(property + ".removeBounced", "false").equalsIgnoreCase("true"); 64 if (originalDeleteValue != deleteField.isSelected()) { 65 if (deleteField.isSelected()) 66 props.setProperty(property + ".removeBounced", "true"); 67 else 68 props.setProperty(property + ".removeBounced", "false"); 69 } 70 71 return props; 72 } 73 74 77 public void setValue() { 78 79 String oldClassName = manager.getProperty(property + ".class", ""); 80 if (!oldClassName.equals(FILTER_CLASS)) 81 manager.setProperty(property + ".class", FILTER_CLASS); 82 83 String originalAddressString = manager.getProperty(property + ".targetAddresses", ""); 84 if (addressField.getText() != originalAddressString) { 85 manager.setProperty(property + ".targetAddresses", addressField.getText()); 86 } 87 88 boolean originalDeleteValue = manager.getProperty(property + ".removeBounced", "false").equalsIgnoreCase("true"); 89 if (originalDeleteValue != deleteField.isSelected()) { 90 if (deleteField.isSelected()) 91 manager.setProperty(property + ".removeBounced", "true"); 92 else 93 manager.setProperty(property + ".removeBounced", "false"); 94 } 95 96 } 97 98 101 public String getFilterClassValue() { 102 return FILTER_CLASS; 103 } 104 105 } 106 | Popular Tags |