1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences;
|
---|
3 |
|
---|
4 | import javax.swing.JPanel;
|
---|
5 | import javax.swing.JScrollPane;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.tools.GBC;
|
---|
8 |
|
---|
9 | public abstract class DefaultTabPreferenceSetting extends DefaultPreferenceSetting implements TabPreferenceSetting {
|
---|
10 |
|
---|
11 | private final String iconName;
|
---|
12 | private final String description;
|
---|
13 | private final String title;
|
---|
14 |
|
---|
15 | public DefaultTabPreferenceSetting() {
|
---|
16 | this(null, null, null);
|
---|
17 | }
|
---|
18 |
|
---|
19 | public DefaultTabPreferenceSetting(String iconName, String title, String description) {
|
---|
20 | this(iconName, title, description, false);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert) {
|
---|
24 | super(isExpert);
|
---|
25 | this.iconName = iconName;
|
---|
26 | this.description = description;
|
---|
27 | this.title = title;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public String getIconName() {
|
---|
32 | return iconName;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public String getTooltip() {
|
---|
37 | if (getDescription() != null) {
|
---|
38 | return "<html>"+getDescription()+"</html>";
|
---|
39 | } else {
|
---|
40 | return null;
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public String getDescription() {
|
---|
46 | return description;
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public String getTitle() {
|
---|
51 | return title;
|
---|
52 | }
|
---|
53 |
|
---|
54 | protected final void createPreferenceTabWithScrollPane(PreferenceTabbedPane gui, JPanel panel) {
|
---|
55 | GBC a = GBC.eol().insets(-5,0,0,0);
|
---|
56 | a.anchor = GBC.EAST;
|
---|
57 |
|
---|
58 | JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
---|
59 | scrollPane.setBorder(null);
|
---|
60 |
|
---|
61 | JPanel tab = gui.createPreferenceTab(this);
|
---|
62 | tab.add(scrollPane, GBC.eol().fill(GBC.BOTH));
|
---|
63 | tab.add(GBC.glue(0,10), a);
|
---|
64 | }
|
---|
65 | }
|
---|