1 package net.suberic.pooka.gui.filter; 2 import net.suberic.pooka.Pooka; 3 import javax.swing.*; 4 import java.util.Vector ; 5 import java.util.Properties ; 6 7 10 public class FlagFilterEditor extends FilterEditor { 11 JComboBox flagBox; 12 JComboBox trueFalseBox; 13 14 public static String FILTER_CLASS = "net.suberic.pooka.filter.FlagFilterAction"; 15 16 20 public void configureEditor(net.suberic.util.gui.propedit.PropertyEditorManager newManager, String propertyName) { 21 property = propertyName; 22 manager = newManager; 23 24 Vector flagNames = Pooka.getSearchManager().getFlagLabels(); 25 flagBox = new JComboBox(flagNames); 26 27 this.add(flagBox); 28 29 Vector trueFalse = new Vector (); 30 trueFalse.add(Pooka.getProperty("label.true", "True")); 31 trueFalse.add(Pooka.getProperty("label.false", "False")); 32 33 trueFalseBox = new JComboBox(trueFalse); 34 35 this.add(trueFalseBox); 36 } 37 38 41 public java.util.Properties getValue() { 42 Properties props = new Properties (); 43 String oldFlag = manager.getProperty(property + ".flag", ""); 44 if (! oldFlag.equals((String ) flagBox.getSelectedItem())) 45 props.setProperty(property + ".flag", (String ) flagBox.getSelectedItem()); 46 47 String oldValue = manager.getProperty(property + ".value", ""); 48 if (! oldFlag.equals((String ) trueFalseBox.getSelectedItem())) 49 props.setProperty(property + ".value", (String ) trueFalseBox.getSelectedItem()); 50 51 String oldClassName = manager.getProperty(property + ".class", ""); 52 if (!oldClassName.equals(FILTER_CLASS)) 53 props.setProperty(property + ".class", FILTER_CLASS); 54 55 return props; 56 } 57 58 61 public void setValue() { 62 String oldFlag = manager.getProperty(property + ".flag", ""); 63 if (! oldFlag.equals((String ) flagBox.getSelectedItem())) 64 manager.setProperty(property + ".flag", (String ) flagBox.getSelectedItem()); 65 66 String oldValue = manager.getProperty(property + ".value", ""); 67 if (! oldFlag.equals((String ) trueFalseBox.getSelectedItem())) 68 manager.setProperty(property + ".value", (String ) trueFalseBox.getSelectedItem()); 69 70 String oldClassName = manager.getProperty(property + ".class", ""); 71 if (!oldClassName.equals(FILTER_CLASS)) 72 manager.setProperty(property + ".class", FILTER_CLASS); 73 } 74 75 78 public String getFilterClassValue() { 79 return FILTER_CLASS; 80 } 81 82 83 } 84 | Popular Tags |