Ignore:
Timestamp:
2016-12-08T00:54:43+01:00 (2 years ago)
Author:
Don-vip
Message:

findbugs - SIC_INNER_SHOULD_BE_STATIC_ANON

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

Legend:

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

    r10763 r11366  
    3737public final class HistoryBrowserDialogManager implements LayerChangeListener {
    3838
     39    static final class UnloadedHistoryPredicate implements Predicate<PrimitiveId> {
     40        private final HistoryDataSet hds = HistoryDataSet.getInstance();
     41
     42        @Override
     43        public boolean test(PrimitiveId p) {
     44            History h = hds.getHistory(p);
     45            if (h == null)
     46                // reload if the history is not in the cache yet
     47                return true;
     48            else
     49                // reload if the history object of the selected object is not in the cache yet
     50                return !p.isNew() && h.getByVersion(p.getUniqueId()) == null;
     51        }
     52    }
     53
    3954    private static final String WINDOW_GEOMETRY_PREF = HistoryBrowserDialogManager.class.getName() + ".geometry";
    4055
    4156    private static HistoryBrowserDialogManager instance;
     57
     58    private final Map<Long, HistoryBrowserDialog> dialogs;
     59
     60    private final Predicate<PrimitiveId> unloadedHistoryPredicate = new UnloadedHistoryPredicate();
     61
     62    private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew();
     63
     64    protected HistoryBrowserDialogManager() {
     65        dialogs = new HashMap<>();
     66        Main.getLayerManager().addLayerChangeListener(this);
     67    }
    4268
    4369    /**
     
    5076        }
    5177        return instance;
    52     }
    53 
    54     private final Map<Long, HistoryBrowserDialog> dialogs;
    55 
    56     protected HistoryBrowserDialogManager() {
    57         dialogs = new HashMap<>();
    58         Main.getLayerManager().addLayerChangeListener(this);
    5978    }
    6079
     
    211230        Main.worker.submit(r);
    212231    }
    213 
    214     private final Predicate<PrimitiveId> unloadedHistoryPredicate = new Predicate<PrimitiveId>() {
    215 
    216         private HistoryDataSet hds = HistoryDataSet.getInstance();
    217 
    218         @Override
    219         public boolean test(PrimitiveId p) {
    220             History h = hds.getHistory(p);
    221             if (h == null)
    222                 // reload if the history is not in the cache yet
    223                 return true;
    224             else
    225                 // reload if the history object of the selected object is not in the cache yet
    226                 return !p.isNew() && h.getByVersion(p.getUniqueId()) == null;
    227         }
    228     };
    229 
    230     private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew();
    231232}
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r10611 r11366  
    4444 *   <li>on the right, it displays the node list for the version at {@link PointInTimeType#CURRENT_POINT_IN_TIME}</li>
    4545 * </ul>
    46  *
     46 * @since 1709
    4747 */
    4848public class NodeListViewer extends JPanel {
     
    7474        final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    7575        final JTable table = new JTable(tableModel, columnModel);
    76         tableModel.addTableModelListener(newReversedChangeListener(table, columnModel));
     76        tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel));
    7777        table.setName("table.referencenodelisttable");
    7878        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     
    8787        final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    8888        final JTable table = new JTable(tableModel, columnModel);
    89         tableModel.addTableModelListener(newReversedChangeListener(table, columnModel));
     89        tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel));
    9090        table.setName("table.currentnodelisttable");
    9191        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     
    9494        table.addMouseListener(new DoubleClickAdapter(table));
    9595        return table;
    96     }
    97 
    98     protected TableModelListener newReversedChangeListener(final JTable table, final NodeListTableColumnModel columnModel) {
    99         return new TableModelListener() {
    100             private Boolean reversed;
    101             private final String nonReversedText = tr("Nodes") + (table.getFont().canDisplay('\u25bc') ? " \u25bc" : " (1-n)");
    102             private final String reversedText = tr("Nodes") + (table.getFont().canDisplay('\u25b2') ? " \u25b2" : " (n-1)");
    103 
    104             @Override
    105             public void tableChanged(TableModelEvent e) {
    106                 if (e.getSource() instanceof DiffTableModel) {
    107                     final DiffTableModel mod = (DiffTableModel) e.getSource();
    108                     if (reversed == null || reversed != mod.isReversed()) {
    109                         reversed = mod.isReversed();
    110                         columnModel.getColumn(0).setHeaderValue(reversed ? reversedText : nonReversedText);
    111                         table.getTableHeader().setToolTipText(
    112                                 reversed ? tr("The nodes of this way are in reverse order") : null);
    113                         table.getTableHeader().repaint();
    114                     }
    115                 }
    116             }
    117         };
    11896    }
    11997
     
    205183    }
    206184
     185    static final class ReversedChangeListener implements TableModelListener {
     186        private final NodeListTableColumnModel columnModel;
     187        private final JTable table;
     188        private Boolean reversed;
     189        private final String nonReversedText;
     190        private final String reversedText;
     191
     192        ReversedChangeListener(JTable table, NodeListTableColumnModel columnModel) {
     193            this.columnModel = columnModel;
     194            this.table = table;
     195            nonReversedText = tr("Nodes") + (table.getFont().canDisplay('\u25bc') ? " \u25bc" : " (1-n)");
     196            reversedText = tr("Nodes") + (table.getFont().canDisplay('\u25b2') ? " \u25b2" : " (n-1)");
     197        }
     198
     199        @Override
     200        public void tableChanged(TableModelEvent e) {
     201            if (e.getSource() instanceof DiffTableModel) {
     202                final DiffTableModel mod = (DiffTableModel) e.getSource();
     203                if (reversed == null || reversed != mod.isReversed()) {
     204                    reversed = mod.isReversed();
     205                    columnModel.getColumn(0).setHeaderValue(reversed ? reversedText : nonReversedText);
     206                    table.getTableHeader().setToolTipText(
     207                            reversed ? tr("The nodes of this way are in reverse order") : null);
     208                    table.getTableHeader().repaint();
     209                }
     210            }
     211        }
     212    }
     213
    207214    static class NodeListPopupMenu extends JPopupMenu {
    208215        private final ZoomToNodeAction zoomToNodeAction;
Note: See TracChangeset for help on using the changeset viewer.