Changeset 7860 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-12-20T20:32:54+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #10850 - clear imagery providers map preview when reloading default list

File:
1 edited

Legend:

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

    r7719 r7860  
    205205        /** The table of default providers **/
    206206        public final JTable defaultTable;
     207        /** The selection listener synchronizing map display with table of default providers **/
     208        private final DefListSelectionListener defaultTableListener;
    207209        /** The map displaying imagery bounds of selected default providers **/
    208210        public final JMapViewer defaultMap;
     
    331333            add(defaultMap, GBC.std().insets(5, 5, 0, 0).fill(GridBagConstraints.BOTH).weight(0.33, 0.6).insets(5, 0, 0, 0));
    332334
    333             defaultTable.getSelectionModel().addListSelectionListener(new DefListSelectionListener());
     335            defaultTableListener = new DefListSelectionListener();
     336            defaultTable.getSelectionModel().addListSelectionListener(defaultTableListener);
    334337
    335338            defaultToolbar = new JToolBar(JToolBar.VERTICAL);
     
    367370            activeToolbar.add(remove);
    368371            add(activeToolbar, GBC.eol().anchor(GBC.NORTH).insets(0, 0, 5, 5));
    369 
    370372        }
    371373
     
    381383            }
    382384
     385            private void clearMap() {
     386                defaultMap.removeAllMapRectangles();
     387                defaultMap.removeAllMapPolygons();
     388                mapRectangles.clear();
     389                mapPolygons.clear();
     390            }
     391
    383392            @Override
    384393            public void valueChanged(ListSelectionEvent e) {
    385                 // First index is set to -1 when the list is refreshed, so discard all map rectangles and polygons
     394                // First index can be set to -1 when the list is refreshed, so discard all map rectangles and polygons
    386395                if (e.getFirstIndex() == -1) {
    387                     defaultMap.removeAllMapRectangles();
    388                     defaultMap.removeAllMapPolygons();
    389                     mapRectangles.clear();
    390                     mapPolygons.clear();
     396                    clearMap();
     397                } else if (!e.getValueIsAdjusting()) {
    391398                    // Only process complete (final) selection events
    392                 } else if (!e.getValueIsAdjusting()) {
    393399                    for (int i = e.getFirstIndex(); i<=e.getLastIndex(); i++) {
    394400                        updateBoundsAndShapes(i);
     
    494500        private class RemoveEntryAction extends AbstractAction implements ListSelectionListener {
    495501
     502            /**
     503             * Constructs a new {@code RemoveEntryAction}.
     504             */
    496505            public RemoveEntryAction() {
    497506                putValue(NAME, tr("Remove"));
     
    520529
    521530        private class ActivateAction extends AbstractAction implements ListSelectionListener {
     531
     532            /**
     533             * Constructs a new {@code ActivateAction}.
     534             */
    522535            public ActivateAction() {
    523536                putValue(NAME, tr("Activate"));
     
    583596
    584597        private class ReloadAction extends AbstractAction {
     598
     599            /**
     600             * Constructs a new {@code ReloadAction}.
     601             */
    585602            public ReloadAction() {
    586603                putValue(SHORT_DESCRIPTION, tr("reload defaults"));
     
    592609                layerInfo.loadDefaults(true);
    593610                defaultModel.fireTableDataChanged();
     611                defaultTable.getSelectionModel().clearSelection();
     612                defaultTableListener.clearMap();
    594613                /* loading new file may change active layers */
    595614                activeModel.fireTableDataChanged();
     
    742761                scrollPane.setPreferredSize(new Dimension(400, 400));
    743762                box.add(scrollPane);
    744                 int option = JOptionPane.showConfirmDialog(Main.parent, box, tr("Please abort if you are not sure"), JOptionPane.YES_NO_OPTION,
    745                         JOptionPane.WARNING_MESSAGE);
     763                int option = JOptionPane.showConfirmDialog(Main.parent, box, tr("Please abort if you are not sure"),
     764                        JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
    746765                if (option == JOptionPane.YES_OPTION)
    747766                    return true;
     
    811830         * The table model for imagery offsets list
    812831         */
    813         class OffsetsBookmarksModel extends DefaultTableModel {
     832        private class OffsetsBookmarksModel extends DefaultTableModel {
     833
     834            /**
     835             * Constructs a new {@code OffsetsBookmarksModel}.
     836             */
    814837            public OffsetsBookmarksModel() {
    815838                setColumnIdentifiers(new String[] { tr("Projection"),  tr("Layer"), tr("Name"), tr("Easting"), tr("Northing"),});
Note: See TracChangeset for help on using the changeset viewer.