Changeset 11348 in josm for trunk/src


Ignore:
Timestamp:
2016-11-30T01:38:40+01:00 (8 years ago)
Author:
Don-vip
Message:

findbugs - fix some SIC_INNER_SHOULD_BE_STATIC_ANON

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java

    r10446 r11348  
    6161            Shortcut.SHIFT
    6262        );
    63         Main.registerActionShortcut(new AbstractAction() {
    64             @Override
    65             public void actionPerformed(ActionEvent e) {
    66                 EditRelationAction.launchEditor(getLastRelation());
    67             }
    68         }, shortcut);
     63        Main.registerActionShortcut(new LaunchEditorAction(), shortcut);
    6964    }
    7065
     
    148143    }
    149144
     145    protected static class LaunchEditorAction extends AbstractAction {
     146        @Override
     147        public void actionPerformed(ActionEvent e) {
     148            EditRelationAction.launchEditor(getLastRelation());
     149        }
     150    }
     151
    150152    protected static class RecentRelationsPopupMenu extends JPopupMenu {
    151153        /**
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r10663 r11348  
    66import static org.openstreetmap.josm.tools.I18n.trn;
    77
    8 import java.util.ArrayList;
    98import java.util.Arrays;
    109import java.util.Collection;
     
    1514import java.util.Map;
    1615import java.util.Objects;
     16import java.util.stream.Collectors;
    1717
    1818import javax.swing.Icon;
     
    3333 */
    3434public class ChangePropertyCommand extends Command {
     35
     36    static final class OsmPseudoCommand implements PseudoCommand {
     37        private final OsmPrimitive osm;
     38
     39        OsmPseudoCommand(OsmPrimitive osm) {
     40            this.osm = osm;
     41        }
     42
     43        @Override
     44        public String getDescriptionText() {
     45            return osm.getDisplayName(DefaultNameFormatter.getInstance());
     46        }
     47
     48        @Override
     49        public Icon getDescriptionIcon() {
     50            return ImageProvider.get(osm.getDisplayType());
     51        }
     52
     53        @Override
     54        public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
     55            return Collections.singleton(osm);
     56        }
     57    }
     58
    3559    /**
    3660     * All primitives that are affected with this command.
     
    212236        if (objects.size() == 1)
    213237            return null;
    214         List<PseudoCommand> children = new ArrayList<>();
    215         for (final OsmPrimitive osm : objects) {
    216             children.add(new PseudoCommand() {
    217                 @Override public String getDescriptionText() {
    218                     return osm.getDisplayName(DefaultNameFormatter.getInstance());
    219                 }
    220 
    221                 @Override public Icon getDescriptionIcon() {
    222                     return ImageProvider.get(osm.getDisplayType());
    223                 }
    224 
    225                 @Override public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
    226                     return Collections.singleton(osm);
    227                 }
    228             });
    229         }
    230         return children;
     238        return objects.stream().map(OsmPseudoCommand::new).collect(Collectors.toList());
    231239    }
    232240
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r11203 r11348  
    4242/**
    4343 * Imagery menu, holding entries for imagery preferences, offset actions and dynamic imagery entries
    44  * depending on current maview coordinates.
     44 * depending on current mapview coordinates.
    4545 * @since 3737
    4646 */
    4747public class ImageryMenu extends JMenu implements LayerChangeListener {
    4848
    49     /**
    50      * Compare ImageryInfo objects alphabetically by name.
    51      *
    52      * ImageryInfo objects are normally sorted by country code first
    53      * (for the preferences). We don't want this in the imagery menu.
    54      */
    55     public static final Comparator<ImageryInfo> alphabeticImageryComparator =
    56             (ii1, ii2) -> ii1.getName().toLowerCase(Locale.ENGLISH).compareTo(ii2.getName().toLowerCase(Locale.ENGLISH));
    57 
    58     private final transient Action offsetAction = new JosmAction(
    59             tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false) {
    60         {
     49    static final class AdjustImageryOffsetAction extends JosmAction {
     50
     51        AdjustImageryOffsetAction() {
     52            super(tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false);
    6153            putValue("toolbar", "imagery-offset");
    6254            Main.toolbar.register(this);
     
    9486            popup.show(source, source.getWidth()/2, source.getHeight()/2);
    9587        }
    96     };
     88    }
     89
     90    /**
     91     * Compare ImageryInfo objects alphabetically by name.
     92     *
     93     * ImageryInfo objects are normally sorted by country code first
     94     * (for the preferences). We don't want this in the imagery menu.
     95     */
     96    public static final Comparator<ImageryInfo> alphabeticImageryComparator =
     97            (ii1, ii2) -> ii1.getName().toLowerCase(Locale.ENGLISH).compareTo(ii2.getName().toLowerCase(Locale.ENGLISH));
     98
     99    private final transient Action offsetAction = new AdjustImageryOffsetAction();
    97100
    98101    private final JMenuItem singleOffset = new JMenuItem(offsetAction);
     
    227230    }
    228231
     232    /**
     233     * Refresh offset menu item.
     234     */
    229235    public void refreshOffsetMenu() {
    230236        offsetMenuItem = getNewOffsetMenu();
  • trunk/src/org/openstreetmap/josm/gui/MainFrame.java

    r11093 r11348  
    8989        l.add(ImageProvider.get("logo").getImage());
    9090        setIconImages(l);
    91         addWindowListener(new WindowAdapter() {
    92             @Override
    93             public void windowClosing(final WindowEvent evt) {
    94                 Main.exitJosm(true, 0, null);
    95             }
    96         });
     91        addWindowListener(new ExitWindowAdapter());
    9792        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    9893
     
    159154        if (layer == Main.getLayerManager().getEditLayer()) {
    160155            refreshTitle();
     156        }
     157    }
     158
     159    static final class ExitWindowAdapter extends WindowAdapter {
     160        @Override
     161        public void windowClosing(final WindowEvent evt) {
     162            Main.exitJosm(true, 0, null);
    161163        }
    162164    }
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r11173 r11348  
    213213        splitPane.setDividerSize(5);
    214214        splitPane.setBorder(null);
    215         splitPane.setUI(new BasicSplitPaneUI() {
    216             @Override
    217             public BasicSplitPaneDivider createDefaultDivider() {
    218                 return new BasicSplitPaneDivider(this) {
    219                     @Override
    220                     public void setBorder(Border b) {
    221                         // Do nothing
    222                     }
    223                 };
    224             }
    225         });
     215        splitPane.setUI(new NoBorderSplitPaneUI());
    226216
    227217        // JSplitPane supports F6 and F8 shortcuts by default, but we need them for Audio actions
     
    533523    }
    534524
     525    static final class NoBorderSplitPaneUI extends BasicSplitPaneUI {
     526        @Override
     527        public BasicSplitPaneDivider createDefaultDivider() {
     528            return new BasicSplitPaneDivider(this) {
     529                @Override
     530                public void setBorder(Border b) {
     531                    // Do nothing
     532                }
     533            };
     534        }
     535    }
     536
    535537    private final class SideToolbarPopupMenu extends JPopupMenu {
    536538        private static final int staticMenuEntryCount = 2;
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r11085 r11348  
    134134    private final transient Collector collector;
    135135
     136    static final class ShowMonitorDialogMouseAdapter extends MouseAdapter {
     137        @Override
     138        public void mouseClicked(MouseEvent e) {
     139            PleaseWaitProgressMonitor monitor = Main.currentProgressMonitor;
     140            if (monitor != null) {
     141                monitor.showForegroundDialog();
     142            }
     143        }
     144    }
     145
     146    static final class JumpToOnLeftClickMouseAdapter extends MouseAdapter {
     147        @Override
     148        public void mouseClicked(MouseEvent e) {
     149            if (e.getButton() != MouseEvent.BUTTON3) {
     150                Main.main.menu.jumpToAct.showJumpToDialog();
     151            }
     152        }
     153    }
     154
    136155    public class BackgroundProgressMonitor implements ProgressMonitorDialog {
    137156
     
    829848
    830849        // also show Jump To dialog on mouse click (except context menu)
    831         MouseListener jumpToOnLeftClick = new MouseAdapter() {
    832             @Override
    833             public void mouseClicked(MouseEvent e) {
    834                 if (e.getButton() != MouseEvent.BUTTON3) {
    835                     Main.main.menu.jumpToAct.showJumpToDialog();
    836                 }
    837             }
    838         };
     850        MouseListener jumpToOnLeftClick = new JumpToOnLeftClickMouseAdapter();
    839851
    840852        // Listen for mouse movements and set the position text field
     
    918930        gbc.ipadx = 100;
    919931        add(progressBar, gbc);
    920         progressBar.addMouseListener(new MouseAdapter() {
    921             @Override
    922             public void mouseClicked(MouseEvent e) {
    923                 PleaseWaitProgressMonitor monitor = Main.currentProgressMonitor;
    924                 if (monitor != null) {
    925                     monitor.showForegroundDialog();
    926                 }
    927             }
    928         });
     932        progressBar.addMouseListener(new ShowMonitorDialogMouseAdapter());
    929933
    930934        Main.pref.addPreferenceChangeListener(this);
  • trunk/src/org/openstreetmap/josm/gui/NotificationManager.java

    r10893 r11348  
    183183    private static class NotificationPanel extends JPanel {
    184184
     185        static final class ShowNoteHelpAction extends AbstractAction {
     186            private final Notification note;
     187
     188            private ShowNoteHelpAction(Notification note) {
     189                this.note = note;
     190            }
     191
     192            @Override
     193            public void actionPerformed(ActionEvent e) {
     194                SwingUtilities.invokeLater(() -> HelpBrowser.setUrlForHelpTopic(note.getHelpTopic()));
     195            }
     196        }
     197
    185198        private JPanel innerPanel;
    186199
     
    214227                btnHelp.setToolTipText(tr("Show help information"));
    215228                HelpUtil.setHelpContext(btnHelp, note.getHelpTopic());
    216                 btnHelp.addActionListener(new AbstractAction() {
    217                     @Override
    218                     public void actionPerformed(ActionEvent e) {
    219                         SwingUtilities.invokeLater(() -> HelpBrowser.setUrlForHelpTopic(note.getHelpTopic()));
    220                     }
    221                 });
     229                btnHelp.addActionListener(new ShowNoteHelpAction(note));
    222230                btnHelp.setOpaque(false);
    223231                tbHelp = new JToolBar();
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java

    r10611 r11348  
    1818public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel {
    1919
    20     private final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
    21 
    22     private final transient OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
     20    static final class MemberRenderer extends OsmPrimitivRenderer {
    2321        @Override
    2422        public Component getTableCellRendererComponent(JTable table,
     
    2725                    table, isSelected, row);
    2826        }
    29     };
     27    }
     28
     29    private final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
     30
     31    private final transient OsmPrimitivRenderer primitiveRenderer = new MemberRenderer();
    3032
    3133    private final transient TableCellRenderer tableRenderer = (table, value, isSelected, hasFocus, row, column)
    3234            -> setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
    3335            table, isSelected, row);
     36
     37    /**
     38     * Constructs a new {@code RelationMemberConflictResolverColumnModel}.
     39     */
     40    public RelationMemberConflictResolverColumnModel() {
     41        createColumns();
     42    }
    3443
    3544    private static Component setColors(Component comp, JTable table, boolean isSelected, int row) {
     
    110119        addColumn(col);
    111120    }
    112 
    113     /**
    114      * Constructs a new {@code RelationMemberConflictResolverColumnModel}.
    115      */
    116     public RelationMemberConflictResolverColumnModel() {
    117         createColumns();
    118     }
    119121}
Note: See TracChangeset for help on using the changeset viewer.