Changeset 6666 in josm for trunk/src


Ignore:
Timestamp:
2014-01-10T19:24:34+01:00 (11 years ago)
Author:
Don-vip
Message:

see #9508 - refactor validator preferences + handling of JScrollPane policies ("vertical as needed" / "horizontal as needed" are default policies)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r6643 r6666  
    366366            Dimension scrn = Toolkit.getDefaultToolkit().getScreenSize();
    367367
    368             // Create a JScrollPane around the content, in case there's not
    369             // enough space
    370             JScrollPane sp = new JScrollPane(content);
    371             sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     368            // Create a JScrollPane around the content, in case there's not enough space
     369            JScrollPane sp = GuiHelper.embedInVerticalScrollPane(content);
    372370            sp.setBorder(BorderFactory.createRaisedBevelBorder());
    373371            // Implement max-size content-independent
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java

    r6565 r6666  
    1515import java.beans.PropertyChangeListener;
    1616import java.util.Collection;
    17 import java.util.List;
    1817import java.util.Observable;
    1918import java.util.Observer;
     
    8786    protected JScrollPane embeddInScrollPane(JTable table) {
    8887        JScrollPane pane = new JScrollPane(table);
    89         pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    90         pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    9188        if (adjustmentSynchronizer == null) {
    9289            adjustmentSynchronizer = new AdjustmentSynchronizer();
     
    480477
    481478        public CopyBeforeCurrentLeftAction() {
    482             super("copybeforecurrentleft", tr("> before"), 
     479            super("copybeforecurrentleft", tr("> before"),
    483480                    tr("Copy my selected elements before the first selected element in the list of merged elements."));
    484481        }
     
    510507
    511508        public CopyAfterCurrentLeftAction() {
    512             super("copyaftercurrentleft", tr("> after"), 
     509            super("copyaftercurrentleft", tr("> after"),
    513510                    tr("Copy my selected elements after the first selected element in the list of merged elements."));
    514511        }
     
    570567
    571568        public CopyBeforeCurrentRightAction() {
    572             super("copybeforecurrentright", tr("< before"), 
     569            super("copybeforecurrentright", tr("< before"),
    573570                    tr("Copy their selected elements before the first selected element in the list of merged elements."));
    574571        }
     
    596593
    597594        public CopyAfterCurrentRightAction() {
    598             super("copyaftercurrentright", tr("< after"), 
     595            super("copyaftercurrentright", tr("< after"),
    599596                    tr("Copy their selected element after the first selected element in the list of merged elements"));
    600597        }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    r6316 r6666  
    5252    protected JScrollPane embeddInScrollPane(JTable table) {
    5353        JScrollPane pane = new JScrollPane(table);
    54         pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    55         pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    56 
    5754        adjustmentSynchronizer.synchronizeAdjustment(pane.getVerticalScrollBar());
    5855        return pane;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/AdvancedChangesetQueryPanel.java

    r6340 r6666  
    3131import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    3232import org.openstreetmap.josm.gui.help.HelpUtil;
     33import org.openstreetmap.josm.gui.util.GuiHelper;
    3334import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator;
    3435import org.openstreetmap.josm.gui.widgets.BoundingBoxSelectionPanel;
    3536import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     37import org.openstreetmap.josm.gui.widgets.JosmTextField;
    3638import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    3739import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    3840import org.openstreetmap.josm.io.ChangesetQuery;
    3941import org.openstreetmap.josm.tools.CheckParameterUtil;
    40 import org.openstreetmap.josm.gui.widgets.JosmTextField;
    4142
    4243
     
    152153    protected void build() {
    153154        setLayout(new BorderLayout());
    154         JScrollPane spQueryPanel = new JScrollPane(buildQueryPanel());
     155        JScrollPane spQueryPanel = GuiHelper.embedInVerticalScrollPane(buildQueryPanel());
    155156        add(spQueryPanel, BorderLayout.CENTER);
    156         spQueryPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    157         spQueryPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    158 
    159     }
    160 
     157    }
     158
     159    /**
     160     * Constructs a new {@code AdvancedChangesetQueryPanel}.
     161     */
    161162    public AdvancedChangesetQueryPanel() {
    162163        build();
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java

    r6267 r6666  
    1111import javax.swing.JSplitPane;
    1212import javax.swing.JTabbedPane;
    13 import javax.swing.JTable;
    1413
    1514import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3332
    3433    /**
    35      * embedds table in a {@link JScrollPane}
    36      *
    37      * @param table the table
    38      * @return the {@link JScrollPane} with the embedded table
    39      */
    40     protected JScrollPane embeddInScrollPane(JTable table) {
    41         JScrollPane pane = new JScrollPane(table);
    42         pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    43         pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    44         return pane;
    45     }
    46 
    47     /**
    4834     * creates the table which shows the list of versions
    4935     *
     
    5541
    5642        VersionTable versionTable = new VersionTable(model);
    57         pnl.add(embeddInScrollPane(versionTable), BorderLayout.CENTER);
     43        pnl.add(new JScrollPane(versionTable), BorderLayout.CENTER);
    5844        return pnl;
    5945    }
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryViewerPanel.java

    r6207 r6666  
    3131    private JScrollPane embedInScrollPane(JTable table) {
    3232        JScrollPane pane = new JScrollPane(table);
    33         pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    34         pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    3533        adjustmentSynchronizer.participateInSynchronizedScrolling(pane.getVerticalScrollBar());
    3634        return pane;
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r6336 r6666  
    5555    protected JScrollPane embeddInScrollPane(JTable table) {
    5656        JScrollPane pane = new JScrollPane(table);
    57         pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    58         pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    5957        adjustmentSynchronizer.participateInSynchronizedScrolling(pane.getVerticalScrollBar());
    6058        return pane;
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r6310 r6666  
    220220                trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>");
    221221
    222         final JScrollPane sp = new JScrollPane(new HtmlPanel(info.toString()), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
     222        final JScrollPane sp = new JScrollPane(new HtmlPanel(info.toString()));
    223223        sp.setPreferredSize(new Dimension(sp.getPreferredSize().width, 350));
    224224        SwingUtilities.invokeLater(new Runnable() {
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/CustomizeDrawingAction.java

    r6070 r6666  
    2525import org.openstreetmap.josm.gui.layer.Layer.MultiLayerAction;
    2626import org.openstreetmap.josm.gui.preferences.display.GPXSettingsPanel;
     27import org.openstreetmap.josm.gui.util.GuiHelper;
    2728import org.openstreetmap.josm.tools.ImageProvider;
    2829
     
    8081        }
    8182        GPXSettingsPanel panel = new GPXSettingsPanel(layers.get(0).getName(), hasLocal, hasNonlocal);
    82         JScrollPane scrollpane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     83        JScrollPane scrollpane = GuiHelper.embedInVerticalScrollPane(panel);
    8384        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    8485        int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
  • trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java

    r6643 r6666  
    167167
    168168        JTabbedPane tpProperties = new JTabbedPane();
    169         tpProperties.add(VerticallyScrollablePanel.embed(buildUserNamePasswordPanel()));
    170         tpProperties.add(VerticallyScrollablePanel.embed(buildGrantsPanel()));
    171         tpProperties.add(VerticallyScrollablePanel.embed(getAdvancedPropertiesPanel()));
     169        tpProperties.add(buildUserNamePasswordPanel().getVerticalScrollPane());
     170        tpProperties.add(buildGrantsPanel().getVerticalScrollPane());
     171        tpProperties.add(getAdvancedPropertiesPanel().getVerticalScrollPane());
    172172        tpProperties.setTitleAt(0, tr("Basic"));
    173173        tpProperties.setTitleAt(1, tr("Granted rights"));
  • trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java

    r6267 r6666  
    4444import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
    4545import org.openstreetmap.josm.gui.help.HelpUtil;
     46import org.openstreetmap.josm.gui.util.GuiHelper;
    4647import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    4748import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    170171        pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl);
    171172
    172         spAuthorisationProcedureUI = new JScrollPane(new JPanel());
    173         spAuthorisationProcedureUI.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    174         spAuthorisationProcedureUI.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     173        spAuthorisationProcedureUI = GuiHelper.embedInVerticalScrollPane(new JPanel());
    175174        spAuthorisationProcedureUI.getVerticalScrollBar().addComponentListener(
    176175                new ComponentListener() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java

    r5632 r6666  
    1010import javax.swing.JTabbedPane;
    1111
     12import org.openstreetmap.josm.Main;
    1213import org.openstreetmap.josm.tools.GBC;
    1314
     
    2021    private final Map<SubPreferenceSetting, Component> subSettingMap;
    2122   
     23    /**
     24     * Constructs a new {@code DefaultTabPreferenceSetting}.
     25     */
    2226    public DefaultTabPreferenceSetting() {
    2327        this(null, null, null);
     
    7882        a.anchor = GBC.EAST;
    7983       
    80         JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
     84        JScrollPane scrollPane = new JScrollPane(panel);
    8185        scrollPane.setBorder(null);
    8286
     
    96100                } catch (IllegalArgumentException e) {
    97101                    // Ignore exception and return false below
     102                    Main.debug(Main.getErrorMessage(e));
    98103                }
    99104            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r6643 r6666  
    5353import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference;
    5454import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
     55import org.openstreetmap.josm.gui.preferences.validator.ValidatorTestsPreference;
    5556import org.openstreetmap.josm.plugins.PluginDownloadTask;
    5657import org.openstreetmap.josm.plugins.PluginHandler;
     
    283284    public final ServerAccessPreference getServerPreference() {
    284285        return getSetting(ServerAccessPreference.class);
     286    }
     287
     288    /**
     289     * Returns the {@code ValidatorPreference} object.
     290     * @return the {@code ValidatorPreference} object.
     291     * @since 6665
     292     */
     293    public final ValidatorPreference getValidatorPreference() {
     294        return getSetting(ValidatorPreference.class);
    285295    }
    286296
     
    503513        settingsFactory.add(new ShortcutPreference.Factory());
    504514        settingsFactory.add(new ValidatorPreference.Factory());
     515        settingsFactory.add(new ValidatorTestsPreference.Factory());
    505516        settingsFactory.add(new RemoteControlPreference.Factory());
    506517        settingsFactory.add(new ImageryPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java

    r6529 r6666  
    2222import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    2323import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
     24import org.openstreetmap.josm.gui.util.GuiHelper;
    2425import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    2526import org.openstreetmap.josm.gui.widgets.JosmTextField;
     
    109110
    110111        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    111         JScrollPane sp = new JScrollPane(panel);
    112         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    113         sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     112        JScrollPane sp = GuiHelper.embedInVerticalScrollPane(panel);
    114113
    115114        gui.getMapPreference().addSubTab(this, tr("File backup"), sp, tr("Configure whether to create backup files"));
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r6623 r6666  
    161161        model  = new PluginPreferencesModel();
    162162        pnlPluginPreferences = new PluginListPanel(model);
    163         spPluginPreferences = new JScrollPane(pnlPluginPreferences);
    164         spPluginPreferences.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    165         spPluginPreferences.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     163        spPluginPreferences = GuiHelper.embedInVerticalScrollPane(pnlPluginPreferences);
    166164        spPluginPreferences.getVerticalScrollBar().addComponentListener(
    167165                new ComponentAdapter(){
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java

    r6623 r6666  
    3737        gui.getServerPreference().addApiUrlChangeListener(pnlAuthPreferences);
    3838        gui.getServerPreference().addSubTab(this, tr("Authentication"),
    39                 ServerAccessPreference.wrapVerticallyScrollablePanel(pnlAuthPreferences),
     39                pnlAuthPreferences.getVerticalScrollPane(),
    4040                tr("Configure your identity and how to authenticate at the OSM server"));
    4141    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java

    r6623 r6666  
    4141        pnlProxyPreferences = new ProxyPreferencesPanel();
    4242        gui.getServerPreference().addSubTab(this, tr("Proxy settings"),
    43                 ServerAccessPreference.wrapVerticallyScrollablePanel(pnlProxyPreferences),
     43                pnlProxyPreferences.getVerticalScrollPane(),
    4444                tr("Configure whether to use a proxy server"));
    4545    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java

    r6623 r6666  
    1111
    1212import javax.swing.JPanel;
    13 import javax.swing.JScrollPane;
    1413import javax.swing.JTabbedPane;
    1514
     
    1918import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2019import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    21 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    2220
    2321/**
     
    4240    /** indicates whether to use the default OSM URL or not */
    4341    private OsmApiUrlInputPanel pnlApiUrlPreferences;
    44 
    45     /**
    46      * Embeds a vertically scrollable panel in a {@link JScrollPane}
    47      * @param panel the panel
    48      * @return the scroll pane
    49      */
    50     public static JScrollPane wrapVerticallyScrollablePanel(VerticallyScrollablePanel panel) {
    51         JScrollPane sp = new JScrollPane(panel);
    52         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    53         sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    54         return sp;
    55     }
    5642
    5743    /**
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java

    r6636 r6666  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.GridBagLayout;
    7 import java.awt.event.ActionEvent;
    8 import java.awt.event.ActionListener;
    9 import java.util.Collection;
    10 import java.util.LinkedList;
     6import javax.swing.JTabbedPane;
    117
    12 import javax.swing.BorderFactory;
    13 import javax.swing.JCheckBox;
    14 import javax.swing.JLabel;
    15 import javax.swing.JPanel;
    16 
    17 import org.openstreetmap.josm.Main;
    188import org.openstreetmap.josm.data.preferences.BooleanProperty;
    19 import org.openstreetmap.josm.data.validation.OsmValidator;
    20 import org.openstreetmap.josm.data.validation.Test;
    219import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2210import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     
    2614
    2715/**
    28  * Preference settings for the validator
     16 * Preference settings for the validator.
    2917 *
    3018 * @author frsantos
     
    4432    private ValidatorPreference() {
    4533        super("validator", tr("Data validator"),
    46                 tr("An OSM data validator that checks for common errors made by users and editor programs."));
     34                tr("An OSM data validator that checks for common errors made by users and editor programs."),
     35                false, new JTabbedPane());
    4736    }
    4837
     
    7463    public static final String PREF_FILTER_BY_SELECTION = PREFIX + ".selectionFilter";
    7564
    76     private JCheckBox prefUseIgnore;
    77     private JCheckBox prefUseLayer;
    78     private JCheckBox prefOtherUpload;
    79     private JCheckBox prefOther;
    80 
    81     /** The list of all tests */
    82     private Collection<Test> allTests;
    83 
    8465    @Override
    85     public void addGui(PreferenceTabbedPane gui)
    86     {
    87         JPanel testPanel = new JPanel(new GridBagLayout());
    88         testPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    89 
    90         prefUseIgnore = new JCheckBox(tr("Use ignore list."), Main.pref.getBoolean(PREF_USE_IGNORE, true));
    91         prefUseIgnore.setToolTipText(tr("Use the ignore list to suppress warnings."));
    92         testPanel.add(prefUseIgnore, GBC.eol());
    93 
    94         prefUseLayer = new JCheckBox(tr("Use error layer."), Main.pref.getBoolean(PREF_LAYER, true));
    95         prefUseLayer.setToolTipText(tr("Use the error layer to display problematic elements."));
    96         testPanel.add(prefUseLayer, GBC.eol());
    97 
    98         prefOther = new JCheckBox(tr("Show informational level."), PREF_OTHER.get());
    99         prefOther.setToolTipText(tr("Show the informational tests."));
    100         testPanel.add(prefOther, GBC.eol());
    101 
    102         prefOtherUpload = new JCheckBox(tr("Show informational level on upload."), Main.pref.getBoolean(PREF_OTHER_UPLOAD, false));
    103         prefOtherUpload.setToolTipText(tr("Show the informational tests in the upload check windows."));
    104         testPanel.add(prefOtherUpload, GBC.eol());
    105 
    106         ActionListener otherUploadEnabled = new ActionListener() {
    107             @Override
    108             public void actionPerformed(ActionEvent e) {
    109                 prefOtherUpload.setEnabled(prefOther.isSelected());
    110             }
    111         };
    112         prefOther.addActionListener(otherUploadEnabled);
    113         otherUploadEnabled.actionPerformed(null);
    114 
    115         GBC a = GBC.eol().insets(-5,0,0,0);
    116         a.anchor = GBC.EAST;
    117         testPanel.add( new JLabel(tr("On demand")), GBC.std() );
    118         testPanel.add( new JLabel(tr("On upload")), a );
    119 
    120         allTests = OsmValidator.getTests();
    121         for (Test test: allTests) {
    122             test.addGui(testPanel);
    123         }
    124 
    125         createPreferenceTabWithScrollPane(gui, testPanel);
     66    public void addGui(PreferenceTabbedPane gui) {
     67        gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
    12668    }
    12769
    12870    @Override
    12971    public boolean ok() {
    130         Collection<String> tests = new LinkedList<String>();
    131         Collection<String> testsBeforeUpload = new LinkedList<String>();
    132 
    133         for (Test test : allTests) {
    134             test.ok();
    135             String name = test.getClass().getSimpleName();
    136             if(!test.enabled)
    137                 tests.add(name);
    138             if(!test.testBeforeUpload)
    139                 testsBeforeUpload.add(name);
    140         }
    141         OsmValidator.initializeTests(allTests);
    142 
    143         Main.pref.putCollection(PREF_SKIP_TESTS, tests);
    144         Main.pref.putCollection(PREF_SKIP_TESTS_BEFORE_UPLOAD, testsBeforeUpload);
    145         Main.pref.put(PREF_USE_IGNORE, prefUseIgnore.isSelected());
    146         PREF_OTHER.put(prefOther.isSelected());
    147         Main.pref.put(PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
    148         Main.pref.put(PREF_LAYER, prefUseLayer.isSelected());
    14972        return false;
    15073    }
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r6643 r6666  
    2727import javax.swing.ImageIcon;
    2828import javax.swing.JOptionPane;
     29import javax.swing.JScrollPane;
    2930import javax.swing.SwingUtilities;
    3031import javax.swing.Timer;
     
    247248        }
    248249    }
     250
     251    /**
     252     * Embeds the given component into a new vertical-only scrollable {@code JScrollPane}.
     253     * @param panel The component to embed
     254     * @return the vertical scrollable {@code JScrollPane}
     255     * @since 6666
     256     */
     257    public static JScrollPane embedInVerticalScrollPane(Component panel) {
     258        return new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     259    }
    249260}
  • trunk/src/org/openstreetmap/josm/gui/widgets/VerticallyScrollablePanel.java

    r6084 r6666  
    1010import javax.swing.Scrollable;
    1111
     12import org.openstreetmap.josm.gui.util.GuiHelper;
     13
    1214public class VerticallyScrollablePanel extends JPanel implements Scrollable {
    1315
    14     static public JScrollPane embed(VerticallyScrollablePanel panel) {
    15         JScrollPane sp = new JScrollPane(panel);
    16         sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    17         sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    18         return sp;
    19     }
    20 
     16    /**
     17     * Constructs a new {@code VerticallyScrollablePanel}.
     18     */
    2119    public VerticallyScrollablePanel() {
    2220        super();
     
    3331    public VerticallyScrollablePanel(LayoutManager layout) {
    3432        super(layout);
     33    }
     34
     35    /**
     36     * Returns a vertical scrollable {@code JScrollPane} containing this panel.
     37     * @return the vertical scrollable {@code JScrollPane}
     38     * @since 6666
     39     */
     40    public final JScrollPane getVerticalScrollPane() {
     41        return GuiHelper.embedInVerticalScrollPane(this);
    3542    }
    3643
Note: See TracChangeset for help on using the changeset viewer.