Changeset 17229 in josm
- Timestamp:
- 2020-10-18T12:03:26+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java
r17160 r17229 149 149 } 150 150 151 /** 152 * Determines whether this tab may be hidden (since it does not contain any relevant content) 153 * @return whether this tab may be hidden 154 */ 155 protected boolean canBeHidden() { 156 return false; 157 } 158 151 159 @Override 152 160 public String getHelpContext() { -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r17228 r17229 20 20 import java.util.NoSuchElementException; 21 21 import java.util.Objects; 22 import java.util.OptionalInt; 22 23 import java.util.Set; 23 24 import java.util.function.Predicate; … … 318 319 } 319 320 320 private void selectTabBy(Predicate<TabPreferenceSetting> predicate) {321 IntStream.range(0, getTabCount())321 private OptionalInt indexOfTab(Predicate<TabPreferenceSetting> predicate) { 322 return IntStream.range(0, getTabCount()) 322 323 .filter(i -> getComponentAt(i) instanceof PreferenceTab 323 324 && predicate.test(((PreferenceTab) getComponentAt(i)).getTabPreferenceSetting())) 324 .findFirst() 325 .ifPresent(this::setSelectedIndex); 325 .findFirst(); 326 } 327 328 private void selectTabBy(Predicate<TabPreferenceSetting> predicate) { 329 indexOfTab(predicate).ifPresent(this::setSelectedIndex); 326 330 } 327 331 … … 537 541 Logging.warn("Ignoring preferences "+setting); 538 542 } 543 } 544 // Hide empty TabPreferenceSetting (only present for plugins) 545 for (DefaultTabPreferenceSetting tps : Utils.filteredCollection(settings, DefaultTabPreferenceSetting.class)) { 546 if (!tps.canBeHidden() || Utils.filteredCollection(settings, SubPreferenceSetting.class).stream() 547 .anyMatch(s -> s.getTabPreferenceSetting(this) == tps)) { 548 continue; 549 } 550 indexOfTab(tps::equals).ifPresent(index -> { 551 remove(index); 552 Logging.debug("{0}: hiding empty {1}", getClass().getSimpleName(), tps); 553 }); 539 554 } 540 555 if (sel != null) { -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DisplayPreference.java
r17227 r17229 48 48 return HelpUtil.ht("/Preferences/Display"); 49 49 } 50 51 @Override 52 protected boolean canBeHidden() { 53 return true; 54 } 50 55 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java
r17227 r17229 47 47 return HelpUtil.ht("/Preferences/Map"); 48 48 } 49 50 @Override 51 protected boolean canBeHidden() { 52 return true; 53 } 49 54 }
Note:
See TracChangeset
for help on using the changeset viewer.