Changeset 17178 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-10-12T20:06:14+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r17162 r17178 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.BorderLayout; 6 7 import java.awt.Component; 7 8 import java.awt.Container; … … 218 219 private void buildPanel() { 219 220 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 220 add(buildHtmlPanel(preferenceSetting.getTitle(), Font.BOLD), 221 GBC.eol().insets(0, 5, 0, 10).anchor(GBC.NORTHWEST).fill(GBC.HORIZONTAL)); 222 add(buildHtmlPanel(preferenceSetting.getDescription(), Font.ITALIC), 223 GBC.eol().insets(5, 0, 5, 20).fill(GBC.HORIZONTAL)); 224 } 225 226 private static JLabel buildHtmlPanel(String text, int fontStyle) { 227 JLabel label = new JLabel("<html>" + text + "</html>"); 228 label.setFont(label.getFont().deriveFont(fontStyle)); 229 return label; 221 JPanel headerPanel = new JPanel(new BorderLayout()); 222 add(headerPanel, GBC.eop().fill(GBC.HORIZONTAL)); 223 224 JLabel label = new JLabel("<html>" + 225 "<b>" + preferenceSetting.getTitle() + "</b><br>" + 226 "<i>" + preferenceSetting.getDescription() + "</i></html>"); 227 label.setFont(label.getFont().deriveFont(Font.PLAIN)); 228 headerPanel.add(label, BorderLayout.CENTER); 229 230 ImageIcon icon = preferenceSetting.getIcon(ImageProvider.ImageSizes.SETTINGS_TAB); 231 headerPanel.add(new JLabel(icon), BorderLayout.EAST); 230 232 } 231 233 … … 499 501 int position = index; 500 502 for (PreferenceTab tab : tabs) { 501 if (tab.getTabPreferenceSetting().equals(tps) && tps.getIconName() != null) { 502 insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++); 503 } else if (tab.getTabPreferenceSetting().equals(tps)) { 504 insertTab(tps.getTitle(), null, tab.getComponent(), tps.getTooltip(), position++); 503 if (tab.getTabPreferenceSetting().equals(tps)) { 504 insertTab(tps.getTitle(), icon, tab.getComponent(), tps.getTooltip(), position++); 505 505 } 506 506 } … … 519 519 TabPreferenceSetting tps = (TabPreferenceSetting) setting; 520 520 if (expert || !tps.isExpert()) { 521 // Get icon 522 String iconName = tps.getIconName(); 523 ImageIcon icon = null; 524 525 if (iconName != null && !iconName.isEmpty()) { 526 icon = ImageProvider.get("preferences", iconName, ImageProvider.ImageSizes.SETTINGS_TAB); 527 } 521 ImageIcon icon = tps.getIcon(ImageProvider.ImageSizes.LARGEICON); 528 522 if (settingsInitialized.contains(tps)) { 529 523 // If it has been initialized, add corresponding tab(s) 530 524 addGUITabsForSetting(icon, tps); 531 } else if (tps.getIconName() != null){525 } else { 532 526 // If it has not been initialized, create an empty tab with only icon and tooltip 533 addTab(null, icon, new PreferencePanel(tps), tps.getTooltip()); 534 } else { 535 addTab(tps.getTitle(), null, new PreferencePanel(tps), tps.getTooltip()); 527 addTab(tps.getTitle(), icon, new PreferencePanel(tps), tps.getTooltip()); 536 528 } 537 529 } -
trunk/src/org/openstreetmap/josm/gui/preferences/TabPreferenceSetting.java
r16966 r17178 3 3 4 4 import java.awt.Component; 5 6 import javax.swing.ImageIcon; 7 8 import org.openstreetmap.josm.tools.ImageProvider; 5 9 6 10 /** … … 16 20 */ 17 21 String getIconName(); 22 23 /** 24 * Returns the icon for this preference setting 25 * @param size the icon size 26 * @return the icon or {@code null} 27 */ 28 default ImageIcon getIcon(ImageProvider.ImageSizes size) { 29 String iconName = getIconName(); 30 return iconName == null || iconName.isEmpty() ? null : ImageProvider.get("preferences", iconName, size); 31 } 18 32 19 33 /**
Note:
See TracChangeset
for help on using the changeset viewer.