1 19 20 package org.netbeans.modules.search; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.util.HashMap ; 25 import org.netbeans.modules.search.types.FullTextType; 26 import org.openidex.search.SearchHistory; 27 import org.openidex.search.SearchType; 28 29 36 public final class FindDialogMemory implements PropertyChangeListener { 37 38 39 private static FindDialogMemory singleton; 40 41 45 private final HashMap searchTypesUsage = new HashMap (4); 46 47 50 private SearchType lastSearchType = null; 51 52 53 private FindDialogMemory() { } 54 55 56 58 public static FindDialogMemory getDefault() { 59 if (singleton == null) { 60 singleton = new FindDialogMemory(); 61 } 62 return singleton; 63 } 64 65 67 void initialize() { 68 SearchHistory.getDefault().addPropertyChangeListener(this); 69 } 70 71 73 void uninitialize() { 74 SearchHistory.getDefault().removePropertyChangeListener(this); 75 } 76 77 80 public void clearSearchTypesUsed() { 81 searchTypesUsage.clear(); 82 } 83 84 86 public void setSearchTypeUsed(String searchTypeClsName, 87 boolean used) { 88 searchTypesUsage.put(searchTypeClsName, Boolean.valueOf(used)); 89 } 90 91 93 public boolean wasSearchTypeUsed(String searchTypeClsName) { 94 return searchTypesUsage.get(searchTypeClsName) == Boolean.TRUE; 95 } 96 97 99 public void propertyChange(PropertyChangeEvent evt) { 100 if (SearchHistory.ADD_TO_HISTORY.equals(evt.getPropertyName())) { 101 searchTypesUsage.put(FullTextType.class.getName(), Boolean.TRUE); 102 } 103 } 104 105 107 public void setLastUsedSearchType(SearchType searchType){ 108 lastSearchType = searchType; 109 } 110 111 113 public SearchType getLastSearchType(){ 114 return lastSearchType; 115 } 116 117 } 118 | Popular Tags |