1 package net.suberic.pooka.gui.filter; 2 import javax.swing.*; 3 import java.awt.*; 4 5 8 public class FontFilterEditor extends FilterEditor { 9 JComboBox fontCombo; 10 String origFontString; 11 12 public static String FILTER_CLASS = "net.suberic.pooka.gui.filter.FontDisplayFilter"; 13 14 18 public void configureEditor(net.suberic.util.gui.propedit.PropertyEditorManager newManager, String propertyName) { 19 property = propertyName; 20 manager = newManager; 21 22 origFontString = manager.getProperty(propertyName + ".style", ""); 23 24 fontCombo = createFontCombo(); 25 26 if (origFontString.equals("")) 27 fontCombo.setSelectedIndex(0); 28 else 29 fontCombo.setSelectedItem(getFontLabel(origFontString)); 30 31 this.add(fontCombo); 32 33 } 34 35 38 public JComboBox createFontCombo() { 39 java.util.Vector labels = new java.util.Vector (); 40 labels.add(manager.getProperty("Font.PLAIN.label", "PLAIN")); 41 labels.add(manager.getProperty("Font.BOLD.label", "BOLD")); 42 labels.add(manager.getProperty("Font.ITALIC.label", "ITALIC")); 43 44 return new JComboBox(labels); 45 } 46 47 50 public String getFontLabel(String fontType) { 51 return manager.getProperty("Font." + fontType + ".label", ""); 52 } 53 54 57 public String getSelectedFontType() { 58 String selectedString = (String ) fontCombo.getSelectedItem(); 59 if (selectedString.equalsIgnoreCase(manager.getProperty("Font.PLAIN.label", "PLAIN"))) 60 return "PLAIN"; 61 else if (selectedString.equalsIgnoreCase(manager.getProperty("Font.BOLD.label", "BOLD"))) 62 return "BOLD"; 63 else if (selectedString.equalsIgnoreCase(manager.getProperty("Font.ITALIC.label", "ITALIC"))) 64 return "ITALIC"; 65 else 66 return ""; 67 } 68 69 72 public java.util.Properties getValue() { 73 java.util.Properties props = new java.util.Properties (); 74 props.setProperty(property + ".style", getSelectedFontType()); 75 props.setProperty(property + ".class", FILTER_CLASS); 76 return props; 77 } 78 79 82 public void setValue() { 83 String newValue = getSelectedFontType(); 84 if (newValue != origFontString) 85 manager.setProperty(property + ".style", newValue); 86 87 String oldClassName = manager.getProperty(property + ".class", ""); 88 if (!oldClassName.equals(FILTER_CLASS)) 89 manager.setProperty(property + ".class", FILTER_CLASS); 90 } 91 92 95 public String getFilterClassValue() { 96 return FILTER_CLASS; 97 } 98 99 } 100 101 102 103 104 105 106 107 108 109 | Popular Tags |