1 package net.suberic.pooka.gui.search; 2 import net.suberic.util.VariableBundle; 3 import net.suberic.util.gui.propedit.*; 4 import javax.swing.*; 5 import java.util.*; 6 7 10 public class SearchEditorPane extends LabelValuePropertyEditor { 11 12 Properties originalProperties; 13 14 SearchEntryPanel searchEntryPanel; 15 16 23 public void configureEditor(String propertyName, String template, String propertyBaseName, PropertyEditorManager newManager) { 24 configureBasic(propertyName, template, propertyBaseName, newManager); 25 26 searchEntryPanel = new SearchEntryPanel(net.suberic.pooka.Pooka.getSearchManager(), property, manager.getFactory().getSourceBundle()); 27 originalProperties = searchEntryPanel.generateSearchTermProperties(property); 28 29 labelComponent = new JLabel(manager.getProperty("title.search.where", "Where")); 31 valueComponent = searchEntryPanel; 32 33 updateEditorEnabled(); 34 } 35 36 39 public void setValue() throws PropertyValueVetoException { 40 Properties newValues = searchEntryPanel.generateSearchTermProperties(property); 44 Enumeration newKeys = newValues.keys(); 45 46 Set originalKeys = originalProperties.keySet(); 47 48 while (newKeys.hasMoreElements()) { 49 Object currentKey = newKeys.nextElement(); 50 if (originalKeys.contains(currentKey)) { 51 originalKeys.remove(currentKey); 52 String originalValue = originalProperties.getProperty((String ) currentKey); 53 String newValue = newValues.getProperty((String ) currentKey); 54 if (originalValue == null || ! originalValue.equals(newValue)) 55 manager.setProperty((String ) currentKey, newValue); 56 } else { 57 manager.setProperty((String ) currentKey, newValues.getProperty((String ) currentKey)); 58 } 59 } 60 61 Iterator iter = originalKeys.iterator(); 62 while (iter.hasNext()) { 63 manager.removeProperty((String ) iter.next()); 64 } 65 } 66 67 public void validateProperty() throws PropertyValueVetoException { 68 69 } 70 71 74 public Properties getValue() { 75 return searchEntryPanel.generateSearchTermProperties(property); 76 } 77 78 81 public void resetDefaultValue() { 82 searchEntryPanel.setSearchTerm(property, manager.getFactory().getSourceBundle()); 83 } 84 85 88 protected void updateEditorEnabled() { 89 searchEntryPanel.setEnabled(isEditorEnabled()); 90 } 91 } 92 | Popular Tags |