source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/TabPreferenceSetting.java@ 17323

Last change on this file since 17323 was 17231, checked in by simon04, 4 years ago

see #7548 - Re-organize the preference dialog (add various icons)

Source of the language icon: https://github.com/FortAwesome/Font-Awesome/blob/5.15.1/svgs/solid/language.svg (CC BY 4.0)

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences;
3
4import java.awt.Component;
5
6import javax.swing.ImageIcon;
7
8import org.openstreetmap.josm.tools.ImageProvider;
9
10/**
11 * Preference settings, that display a top level tab.
12 *
13 * This preference setting's addGui method is called after the user clicked the tab.
14 */
15public interface TabPreferenceSetting extends PreferenceSetting {
16
17 /**
18 * Called during preferences dialog initialization to display the preferences tab with the returned icon.
19 * @return The icon name in the preferences folder.
20 */
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()
31 ? null
32 : iconName.contains("/")
33 ? ImageProvider.get(iconName, size)
34 : ImageProvider.get("preferences", iconName, size);
35 }
36
37 /**
38 * Called during preferences tab initialization to display its title.
39 * @return The title of this preferences tab.
40 */
41 String getTitle();
42
43 /**
44 * Called during preferences dialog initialization to display the preferences tab with the returned tooltip.
45 * @return The tooltip of this preferences tab.
46 */
47 String getTooltip();
48
49 /**
50 * Called during preferences tab initialization to display a description in one sentence for this tab.
51 * Will be displayed in italic under the title.
52 * @return The description of this preferences tab.
53 */
54 String getDescription();
55
56 /**
57 * Adds a new sub preference settings tab with the given title and component.
58 * @param sub The new sub preference settings.
59 * @param title The tab title.
60 * @param component The tab component.
61 * @since 5631
62 */
63 void addSubTab(SubPreferenceSetting sub, String title, Component component);
64
65 /**
66 * Adds a new sub preference settings tab with the given title, component and tooltip.
67 * @param sub The new sub preference settings.
68 * @param title The tab title.
69 * @param component The tab component.
70 * @param tip The tab tooltip.
71 * @since 5631
72 */
73 void addSubTab(SubPreferenceSetting sub, String title, Component component, String tip);
74
75 /**
76 * Registers a sub preference settings to an existing tab component.
77 * @param sub The new sub preference settings.
78 * @param component The component for which a tab already exists.
79 * @since 5631
80 */
81 void registerSubTab(SubPreferenceSetting sub, Component component);
82
83 /**
84 * Returns the tab component related to the specified sub preference settings
85 * @param sub The requested sub preference settings.
86 * @return The component related to the specified sub preference settings, or null.
87 * @since 5631
88 */
89 Component getSubTab(SubPreferenceSetting sub);
90
91 /**
92 * Returns the currently selected sub preference setting
93 * @return the currently selected sub preference setting
94 */
95 Class<? extends SubPreferenceSetting> getSelectedSubTab();
96
97 /**
98 * Selects the specified sub preference settings, if applicable. Not all Tab preference settings need to implement this.
99 * @param subPref The sub preference settings to be selected.
100 * @return true if the specified preference settings have been selected, false otherwise.
101 * @since 5631
102 */
103 boolean selectSubTab(SubPreferenceSetting subPref);
104
105 /**
106 * Returns the help context for this preferences settings tab.
107 * @return the help context for this preferences settings tab
108 * @since 13431
109 */
110 String getHelpContext();
111}
Note: See TracBrowser for help on using the repository browser.