Changeset 5120 in josm for trunk


Ignore:
Timestamp:
2012-03-25T21:09:26+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #7541 - clean plugin list initialization + keep scrollbar position when refreshing the list

Location:
trunk/src/org/openstreetmap/josm/gui/preferences
Files:
2 edited

Legend:

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

    r5117 r5120  
    66
    77import java.awt.BorderLayout;
    8 import java.awt.Component;
    98import java.awt.GridBagConstraints;
    109import java.awt.GridBagLayout;
     
    3433import javax.swing.SwingUtilities;
    3534import javax.swing.UIManager;
    36 import javax.swing.event.ChangeEvent;
    37 import javax.swing.event.ChangeListener;
    3835import javax.swing.event.DocumentEvent;
    3936import javax.swing.event.DocumentListener;
     
    185182        PreferencePanel plugins = gui.createPreferenceTab(this);
    186183        plugins.add(buildContentPanel(), gc);
    187         //pnlPluginPreferences.refreshView(); // fix #7541, refreshView() will be called when the first tab will be selected
    188         gui.addChangeListener(new PluginPreferenceActivationListener(plugins));
     184        readLocalPluginInformation();
     185        pluginPreferencesActivated = true;
    189186    }
    190187
     
    410407
    411408    /**
    412      * Listens to the activation of the plugin preferences tab. On activation it
    413      * reloads plugin information from the local file system.
    414      *
    415      */
    416     class PluginPreferenceActivationListener implements ChangeListener {
    417         private Component pane;
    418         public PluginPreferenceActivationListener(Component preferencesPane) {
    419             pane = preferencesPane;
    420         }
    421 
    422         public void stateChanged(ChangeEvent e) {
    423             JTabbedPane tp = (JTabbedPane)e.getSource();
    424             if (tp.getSelectedComponent() == pane && !pluginPreferencesActivated) {
    425                 readLocalPluginInformation();
    426                 pluginPreferencesActivated = true;
    427             }
    428         }
    429     }
    430 
    431     /**
    432409     * Applies the current filter condition in the filter text field to the
    433410     * model
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java

    r4191 r5120  
    77import java.awt.GridBagLayout;
    88import java.awt.Insets;
     9import java.awt.Rectangle;
    910import java.awt.event.ActionEvent;
    1011import java.awt.event.ActionListener;
     
    1415import javax.swing.JLabel;
    1516import javax.swing.SwingConstants;
     17import javax.swing.SwingUtilities;
    1618import javax.swing.event.HyperlinkEvent;
     19import javax.swing.event.HyperlinkEvent.EventType;
    1720import javax.swing.event.HyperlinkListener;
    18 import javax.swing.event.HyperlinkEvent.EventType;
    1921
    2022import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     
    2729
    2830    public PluginListPanel() {
    29         model = new PluginPreferencesModel();
    30         setLayout(new GridBagLayout());
     31        this(new PluginPreferencesModel());
    3132    }
    3233
     
    8384
    8485    public void refreshView() {
     86        final Rectangle visibleRect = getVisibleRect();
    8587        List<PluginInformation> displayedPlugins = model.getDisplayedPlugins();
    8688        removeAll();
     
    145147        revalidate();
    146148        repaint();
     149        if (visibleRect != null && visibleRect.width > 0 && visibleRect.height > 0) {
     150            SwingUtilities.invokeLater(new Runnable() {
     151                @Override
     152                public void run() {
     153                    scrollRectToVisible(visibleRect);
     154                }
     155            });
     156        }
    147157    }
    148158}
Note: See TracChangeset for help on using the changeset viewer.