Changeset 4286 in josm for trunk/src/org
- Timestamp:
- 2011-08-07T18:05:48+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchAction.java
r3720 r4286 26 26 return; 27 27 28 TaggingPresetSearchDialog dialog = new TaggingPresetSearchDialog(Main.parent);28 TaggingPresetSearchDialog dialog = TaggingPresetSearchDialog.getInstance(); 29 29 dialog.showDialog(); 30 30 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java
r4221 r4286 54 54 public class TaggingPresetSearchDialog extends ExtendedDialog { 55 55 56 private int CLASSIFICATION_NAME_MATCH = 300; 57 private int CLASSIFICATION_GROUP_MATCH = 200; 58 private int CLASSIFICATION_TAGS_MATCH = 100; 59 60 private final BooleanProperty SEARCH_IN_TAGS = new BooleanProperty("taggingpreset.dialog.search-in-tags", true); 61 private final BooleanProperty ONLY_APPLICABLE = new BooleanProperty("taggingpreset.dialog.only-applicable-to-selection", true); 56 private static final int CLASSIFICATION_IN_FAVORITES = 300; 57 private static final int CLASSIFICATION_NAME_MATCH = 300; 58 private static final int CLASSIFICATION_GROUP_MATCH = 200; 59 private static final int CLASSIFICATION_TAGS_MATCH = 100; 60 61 private static final BooleanProperty SEARCH_IN_TAGS = new BooleanProperty("taggingpreset.dialog.search-in-tags", true); 62 private static final BooleanProperty ONLY_APPLICABLE = new BooleanProperty("taggingpreset.dialog.only-applicable-to-selection", true); 62 63 63 64 private static class ResultListCellRenderer extends DefaultListCellRenderer { … … 101 102 public final TaggingPreset preset; 102 103 public int classification; 104 public int favoriteIndex; 103 105 private final Collection<String> groups = new HashSet<String>(); 104 106 private final Collection<String> names = new HashSet<String>(); … … 190 192 } 191 193 194 private static TaggingPresetSearchDialog instance; 195 public static TaggingPresetSearchDialog getInstance() { 196 if (instance == null) { 197 instance = new TaggingPresetSearchDialog(); 198 } 199 return instance; 200 } 192 201 193 202 private JTextField edSearchText; … … 199 208 private ResultListModel lsResultModel = new ResultListModel(); 200 209 201 p ublic TaggingPresetSearchDialog(Component parent) {202 super( parent, tr("Presets"), new String[] {tr("Select"), tr("Cancel")});210 private TaggingPresetSearchDialog() { 211 super(Main.parent, tr("Presets"), new String[] {tr("Select"), tr("Cancel")}); 203 212 getTypesInSelection(); 204 213 … … 213 222 build(); 214 223 filterPresets(""); 224 } 225 226 @Override 227 public ExtendedDialog showDialog() { 228 super.showDialog(); 229 edSearchText.setText(""); 230 lsResult.getSelectionModel().clearSelection(); 231 return this; 215 232 } 216 233 … … 336 353 */ 337 354 private void filterPresets(String text) { 338 //TODO Favorites355 //TODO Save favorites to file 339 356 text = text.toLowerCase(); 340 357 … … 398 415 399 416 if (presetClasification.classification > 0) { 417 presetClasification.classification += presetClasification.favoriteIndex; 400 418 result.add(presetClasification); 401 419 } … … 433 451 selectPreset = 0; 434 452 } 435 lsResultModel.getPresets().get(selectPreset).preset.actionPerformed(null); 453 TaggingPreset preset = lsResultModel.getPresets().get(selectPreset).preset; 454 for (PresetClasification pc: classifications) { 455 if (pc.preset == preset) { 456 pc.favoriteIndex = CLASSIFICATION_IN_FAVORITES; 457 } else if (pc.favoriteIndex > 0) { 458 pc.favoriteIndex--; 459 } 460 } 461 preset.actionPerformed(null); 436 462 } 437 463
Note:
See TracChangeset
for help on using the changeset viewer.