Ticket #6974: customSearchActionPermanent.patch
| File customSearchActionPermanent.patch, 2.8 KB (added by , 15 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/search/SearchAction.java
2 2 package org.openstreetmap.josm.actions.search; 3 3 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 7 import static org.openstreetmap.josm.tools.I18n.trc; 7 8 … … 35 36 import org.openstreetmap.josm.data.osm.Filter; 36 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 38 import org.openstreetmap.josm.gui.ExtendedDialog; 39 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 38 40 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 39 41 import org.openstreetmap.josm.tools.GBC; 40 42 import org.openstreetmap.josm.tools.Property; … … 185 187 JCheckBox allElements = new JCheckBox(tr("all objects"), initialValues.allElements); 186 188 allElements.setToolTipText(tr("Also include incomplete and deleted objects in search.")); 187 189 final JCheckBox regexSearch = new JCheckBox(tr("regular expression"), initialValues.regexSearch); 190 final JCheckBox addOnToolbar = new JCheckBox(tr("Add toolbar button"), false); 188 191 189 192 JPanel top = new JPanel(new GridBagLayout()); 190 193 top.add(label, GBC.std().insets(0, 0, 5, 0)); … … 199 202 { 200 203 left.add(allElements, GBC.eol()); 201 204 left.add(regexSearch, GBC.eol()); 205 left.add(addOnToolbar, GBC.eol()); 202 206 } 203 207 204 208 JPanel right = new JPanel(); … … 292 296 initialValues.caseSensitive = caseSensitive.isSelected(); 293 297 initialValues.allElements = allElements.isSelected(); 294 298 initialValues.regexSearch = regexSearch.isSelected(); 299 300 if (addOnToolbar.isSelected()) { 301 ToolbarPreferences.ActionDefinition aDef = 302 new ToolbarPreferences.ActionDefinition(Main.main.menu.search); 303 aDef.getParameters().put("searchExpression", initialValues); 304 // parametrized action definition is now composed 305 ActionParser actionParser = new ToolbarPreferences.ActionParser(null); 306 String res = actionParser.saveAction(aDef); 307 308 Collection<String> t = new LinkedList<String>(Main.pref.getCollection("toolbar")); 309 if (t!=null) { 310 // add custom search button to toolbar preferences 311 if (!t.contains(res)) t.add(res); 312 Main.pref.putCollection("toolbar", t); 313 Main.toolbar.refreshToolbarControl(); 314 } 315 } 295 316 return initialValues; 296 317 } 297 318
