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