- Timestamp:
- 2009-09-29T07:11:39+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r2166 r2212 61 61 } 62 62 SearchSetting se = showSearchDialog(s); 63 if(se != null) searchWithHistory(se); 63 if(se != null) { 64 searchWithHistory(se); 65 } 64 66 } 65 67 … … 126 128 Main.parent, 127 129 initialValues instanceof Filter ? tr("Filter") : tr("Search"), 128 new String[] {129 initialValues instanceof Filter ? tr("Submit filter") : tr("Start Search"),130 tr("Cancel")}130 new String[] { 131 initialValues instanceof Filter ? tr("Submit filter") : tr("Start Search"), 132 tr("Cancel")} 131 133 ); 132 134 dialog.setButtonIcons(new String[] {"dialogs/search.png", "cancel.png"}); … … 140 142 SearchMode mode = replace.isSelected() ? SearchAction.SearchMode.replace 141 143 : (add.isSelected() ? SearchAction.SearchMode.add 142 : (remove.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection));144 : (remove.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection)); 143 145 initialValues.text = input.getText(); 144 146 initialValues.mode = mode; … … 171 173 172 174 public interface Function{ 173 public Boolean isSomething(OsmPrimitive o);175 public Boolean isSomething(OsmPrimitive o); 174 176 } 175 177 … … 179 181 String searchText = s.text; 180 182 if(s instanceof Filter){ 181 searchText = "(" + s.text + ")" + (((Filter)s).applyForChildren ? ("| child (" + s.text + ")"): "");182 searchText = (((Filter)s).inverted ? "-" : "") + "(" + searchText + ")";183 searchText = "(" + s.text + ")" + (((Filter)s).applyForChildren ? ("| child (" + s.text + ")"): ""); 184 searchText = (((Filter)s).inverted ? "-" : "") + "(" + searchText + ")"; 183 185 } 184 186 /*System.out.println(searchText);*/ … … 215 217 return foundMatches; 216 218 } 217 219 218 220 public static void search(String search, SearchMode mode, boolean caseSensitive, boolean regexSearch) { 219 search(new SearchSetting(search, mode, caseSensitive, regexSearch));221 search(new SearchSetting(search, mode, caseSensitive, regexSearch)); 220 222 } 221 223 … … 233 235 // } 234 236 // } 235 236 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected();237 int foundMatches = getSelection(s, sel, new Function(){238 public Boolean isSomething(OsmPrimitive o){239 return o.isSelected();240 }241 });242 Main.main.getCurrentDataSet().setSelected(sel);243 if (foundMatches == 0) {244 String msg = null;245 if (s.mode == SearchMode.replace) {246 msg = tr("No match found for ''{0}''", s.text);247 } else if (s.mode == SearchMode.add) {248 msg = tr("Nothing added to selection by searching for ''{0}''", s.text);249 } else if (s.mode == SearchMode.remove) {250 msg = tr("Nothing removed from selection by searching for ''{0}''", s.text);251 } else if (s.mode == SearchMode.in_selection) {252 msg = tr("Nothing find in selection by searching for ''{0}''", s.text);253 }254 Main.map.statusLine.setHelpText(msg);255 JOptionPane.showMessageDialog(256 Main.parent,257 msg,258 tr("Warning"),259 JOptionPane.WARNING_MESSAGE260 );261 } else {262 Main.map.statusLine.setHelpText(tr("Found {0} matches", foundMatches));263 }237 238 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 239 int foundMatches = getSelection(s, sel, new Function(){ 240 public Boolean isSomething(OsmPrimitive o){ 241 return o.isSelected(); 242 } 243 }); 244 Main.main.getCurrentDataSet().setSelected(sel); 245 if (foundMatches == 0) { 246 String msg = null; 247 if (s.mode == SearchMode.replace) { 248 msg = tr("No match found for ''{0}''", s.text); 249 } else if (s.mode == SearchMode.add) { 250 msg = tr("Nothing added to selection by searching for ''{0}''", s.text); 251 } else if (s.mode == SearchMode.remove) { 252 msg = tr("Nothing removed from selection by searching for ''{0}''", s.text); 253 } else if (s.mode == SearchMode.in_selection) { 254 msg = tr("Nothing found in selection by searching for ''{0}''", s.text); 255 } 256 Main.map.statusLine.setHelpText(msg); 257 JOptionPane.showMessageDialog( 258 Main.parent, 259 msg, 260 tr("Warning"), 261 JOptionPane.WARNING_MESSAGE 262 ); 263 } else { 264 Main.map.statusLine.setHelpText(tr("Found {0} matches", foundMatches)); 265 } 264 266 } 265 267
Note:
See TracChangeset
for help on using the changeset viewer.