001    // License: GPL. For details, see LICENSE file.
002    package org.openstreetmap.josm.gui.preferences;
003    
004    import javax.swing.JPanel;
005    import javax.swing.JScrollPane;
006    
007    import org.openstreetmap.josm.tools.GBC;
008    
009    public abstract class DefaultTabPreferenceSetting extends DefaultPreferenceSetting implements TabPreferenceSetting {
010    
011        private final String iconName;
012        private final String description;
013        private final String title;
014        
015        public DefaultTabPreferenceSetting() {
016            this(null, null, null);
017        }
018    
019        public DefaultTabPreferenceSetting(String iconName, String title, String description) {
020            this(iconName, title, description, false);
021        }
022    
023        public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert) {
024            super(isExpert);
025            this.iconName = iconName;
026            this.description = description;
027            this.title = title;
028        }
029    
030        @Override
031        public String getIconName() {
032            return iconName;
033        }
034    
035        @Override
036        public String getTooltip() {
037            if (getDescription() != null) {
038                return "<html>"+getDescription()+"</html>";
039            } else {
040                return null;
041            }
042        }
043    
044        @Override
045        public String getDescription() {
046            return description;
047        }
048    
049        @Override
050        public String getTitle() {
051            return title;
052        }
053        
054        protected final void createPreferenceTabWithScrollPane(PreferenceTabbedPane gui, JPanel panel) {
055            GBC a = GBC.eol().insets(-5,0,0,0);
056            a.anchor = GBC.EAST;
057            
058            JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
059            scrollPane.setBorder(null);
060    
061            JPanel tab = gui.createPreferenceTab(this);
062            tab.add(scrollPane, GBC.eol().fill(GBC.BOTH));
063            tab.add(GBC.glue(0,10), a);
064        }
065    }