Changeset 6738 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-01-19T18:47:49+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r6597 r6738 114 114 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 115 115 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction; 116 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchPrimitiveDialog; 116 117 import org.openstreetmap.josm.tools.ImageProvider; 117 118 import org.openstreetmap.josm.tools.Shortcut; … … 375 376 376 377 public final TaggingPresetSearchAction presetSearchAction = new TaggingPresetSearchAction(); 378 public final TaggingPresetSearchPrimitiveDialog.Action presetSearchPrimitiveAction = new TaggingPresetSearchPrimitiveDialog.Action(); 377 379 public final DialogsToggleAction dialogsToggleAction = new DialogsToggleAction(); 378 380 public FullscreenToggleAction fullscreenToggleAction = null; … … 640 642 editMenu.addSeparator(); 641 643 add(editMenu, search); 644 add(editMenu, presetSearchPrimitiveAction); 642 645 editMenu.addSeparator(); 643 646 add(editMenu, preferences); … … 700 703 701 704 add(presetsMenu, presetSearchAction); 705 add(presetsMenu, presetSearchPrimitiveAction); 702 706 add(presetsMenu, PreferencesAction.forPreferenceSubTab(tr("Preset preferences"), 703 707 tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class)); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r6572 r6738 66 66 * @since 294 67 67 */ 68 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener {68 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener, Predicate<OsmPrimitive> { 69 69 70 70 public static final int DIALOG_ANSWER_APPLY = 1; … … 463 463 } 464 464 465 @Override 466 public boolean evaluate(OsmPrimitive p) { 467 return matches(EnumSet.of(TaggingPresetType.forPrimitive(p)), p.getKeys(), false); 468 } 469 465 470 public boolean matches(Collection<TaggingPresetType> t, Map<String, String> tags, boolean onlyShowable) { 466 471 if (onlyShowable && !isShowable()) -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java
r6362 r6738 34 34 private TaggingPresetSearchDialog() { 35 35 super(Main.parent, tr("Presets"), new String[] {tr("Select"), tr("Cancel")}); 36 selector = new TaggingPresetSelector( );36 selector = new TaggingPresetSelector(true, true); 37 37 setContent(selector); 38 38 DataSet.addSelectionListener(selector); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSelector.java
r6425 r6738 201 201 * Constructs a new {@code TaggingPresetSelector}. 202 202 */ 203 public TaggingPresetSelector( ) {203 public TaggingPresetSelector(boolean displayOnlyApplicable, boolean displaySearchInTags) { 204 204 super(new BorderLayout()); 205 205 if (TaggingPresetPreference.taggingPresets!=null) { … … 260 260 pnChecks.setLayout(new BoxLayout(pnChecks, BoxLayout.Y_AXIS)); 261 261 262 ckOnlyApplicable = new JCheckBox(); 263 ckOnlyApplicable.setText(tr("Show only applicable to selection")); 264 pnChecks.add(ckOnlyApplicable); 265 ckOnlyApplicable.addItemListener(new ItemListener() { 266 @Override 267 public void itemStateChanged(ItemEvent e) { 268 filterPresets(); 269 } 270 }); 271 272 ckSearchInTags = new JCheckBox(); 273 ckSearchInTags.setText(tr("Search in tags")); 274 ckSearchInTags.setSelected(SEARCH_IN_TAGS.get()); 275 ckSearchInTags.addItemListener(new ItemListener() { 276 @Override 277 public void itemStateChanged(ItemEvent e) { 278 filterPresets(); 279 } 280 }); 281 pnChecks.add(ckSearchInTags); 262 if (displayOnlyApplicable) { 263 ckOnlyApplicable = new JCheckBox(); 264 ckOnlyApplicable.setText(tr("Show only applicable to selection")); 265 pnChecks.add(ckOnlyApplicable); 266 ckOnlyApplicable.addItemListener(new ItemListener() { 267 @Override 268 public void itemStateChanged(ItemEvent e) { 269 filterPresets(); 270 } 271 }); 272 } 273 274 if (displaySearchInTags) { 275 ckSearchInTags = new JCheckBox(); 276 ckSearchInTags.setText(tr("Search in tags")); 277 ckSearchInTags.setSelected(SEARCH_IN_TAGS.get()); 278 ckSearchInTags.addItemListener(new ItemListener() { 279 @Override 280 public void itemStateChanged(ItemEvent e) { 281 filterPresets(); 282 } 283 }); 284 pnChecks.add(ckSearchInTags); 285 } 282 286 283 287 add(pnChecks, BorderLayout.SOUTH); … … 317 321 } 318 322 319 boolean onlyApplicable = ckOnlyApplicable .isSelected();320 boolean inTags = ckSearchInTags .isSelected();323 boolean onlyApplicable = ckOnlyApplicable != null && ckOnlyApplicable.isSelected(); 324 boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected(); 321 325 322 326 List<PresetClassification> result = new ArrayList<PresetClassification>(); … … 402 406 403 407 public void init() { 404 ckOnlyApplicable.setEnabled(!getTypesInSelection().isEmpty()); 405 ckOnlyApplicable.setSelected(!getTypesInSelection().isEmpty() && ONLY_APPLICABLE.get()); 408 if (ckOnlyApplicable != null) { 409 ckOnlyApplicable.setEnabled(!getTypesInSelection().isEmpty()); 410 ckOnlyApplicable.setSelected(!getTypesInSelection().isEmpty() && ONLY_APPLICABLE.get()); 411 } 406 412 edSearchText.setText(""); 407 413 filterPresets(); … … 423 429 */ 424 430 public void savePreferences() { 425 SEARCH_IN_TAGS.put(ckSearchInTags.isSelected()); 426 if (ckOnlyApplicable.isEnabled()) { 431 if (ckSearchInTags != null) { 432 SEARCH_IN_TAGS.put(ckSearchInTags.isSelected()); 433 } 434 if (ckOnlyApplicable != null && ckOnlyApplicable.isEnabled()) { 427 435 ONLY_APPLICABLE.put(ckOnlyApplicable.isSelected()); 428 436 }
Note:
See TracChangeset
for help on using the changeset viewer.