Changeset 8468 in josm


Ignore:
Timestamp:
2015-06-06T01:48:41+02:00 (9 years ago)
Author:
Don-vip
Message:

fix some minor sonar/code style issues:

  • Avoid Protected Field In Final Class
  • Class defines fields that are used only as locals
Location:
trunk/src/org/openstreetmap/josm
Files:
12 edited

Legend:

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

    r8443 r8468  
    3636
    3737    /** (preference key => return value) mappings valid for the current operation (no, those two maps cannot be combined) */
    38     protected static final Map<String, Integer> sessionChoices = new HashMap<>();
     38    private static final Map<String, Integer> sessionChoices = new HashMap<>();
    3939    /** (preference key =&gt; return value) mappings valid for the current session */
    40     protected static final Map<String, Integer> immediateChoices = new HashMap<>();
     40    private static final Map<String, Integer> immediateChoices = new HashMap<>();
    4141    /** a set indication that (preference key) is or may be stored for the currently active bulk operation */
    42     protected static final Set<String> immediateActive = new HashSet<>();
     42    private static final Set<String> immediateActive = new HashSet<>();
    4343
    4444    /**
     
    243243
    244244    /**
    245      * This is a message panel used in dialogs which can be enabled/disabled with a preference
    246      * setting.
     245     * This is a message panel used in dialogs which can be enabled/disabled with a preference setting.
    247246     * In addition to the normal message any {@link JOptionPane} would display it includes
    248247     * a checkbox for enabling/disabling this particular dialog.
     
    250249     */
    251250    static class MessagePanel extends JPanel {
    252         private final ButtonGroup group = new ButtonGroup();
    253251        private final JRadioButton cbShowPermanentDialog = new JRadioButton(NotShowAgain.PERMANENT.getLabel());
    254252        private final JRadioButton cbShowSessionDialog = new JRadioButton(NotShowAgain.SESSION.getLabel());
     
    258256        /**
    259257         * Constructs a new panel.
    260          * @param message the the message (null to add no message, Component instances are added directly, otherwise a JLabel with the string representation is added)
     258         * @param message the the message (null to add no message, Component instances are added directly,
     259         *                otherwise a JLabel with the string representation is added)
    261260         * @param displayImmediateOption whether to provide "Do not show again (this session)"
    262261         */
    263262        public MessagePanel(Object message, boolean displayImmediateOption) {
    264263            cbStandard.setSelected(true);
     264            ButtonGroup group = new ButtonGroup();
    265265            group.add(cbShowPermanentDialog);
    266266            group.add(cbShowSessionDialog);
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r8419 r8468  
    443443        public static final String TILE_BOUNDS_PROP = TileAddressInputPanel.class.getName() + ".tileBounds";
    444444
    445         private JosmTextField tfTileAddress;
    446445        private transient TileAddressValidator valTileAddress;
    447446
     
    467466            gc.weightx = 1.0;
    468467            gc.gridx = 1;
    469             pnl.add(tfTileAddress = new JosmTextField(), gc);
     468            JosmTextField tfTileAddress = new JosmTextField();
     469            pnl.add(tfTileAddress, gc);
    470470            valTileAddress = new TileAddressValidator(tfTileAddress);
    471471            SelectAllOnFocusGainedDecorator.decorate(tfTileAddress);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r8419 r8468  
    510510    private static final class StatisticsInfoTable extends JPanel {
    511511
    512         private JTable infoTable;
    513 
    514         protected void build(StatisticsTableModel model) {
    515             infoTable = new JTable(model, new StatisticsTableColumnModel());
     512        private StatisticsInfoTable(StatisticsTableModel model) {
     513            JTable infoTable = new JTable(model, new StatisticsTableColumnModel());
    516514            infoTable.setShowHorizontalLines(true);
    517515            infoTable.setShowVerticalLines(false);
     
    521519        }
    522520
    523         private StatisticsInfoTable(StatisticsTableModel model) {
    524             build(model);
    525         }
    526 
    527521        @Override
    528522        public Insets getInsets() {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r8444 r8468  
    767767        }
    768768
     769        /**
     770         * Constructs a new {@code SearchPopupMenu}.
     771         */
    769772        public SearchPopupMenu() {
    770773            for (SearchSetting ss: org.openstreetmap.josm.actions.search.SearchAction.getSearchHistory()) {
     
    780783     */
    781784    protected static class SelectionMenuItem extends JMenuItem implements ActionListener {
    782         private final transient DefaultNameFormatter df = DefaultNameFormatter.getInstance();
    783785        protected transient Collection<? extends OsmPrimitive> sel;
    784786
    785787        public SelectionMenuItem(Collection<? extends OsmPrimitive> sel) {
    786             super();
    787788            this.sel = sel;
    788789            int ways = 0;
     
    816817                this.sel=new ArrayList<>(); // empty selection
    817818            }
     819            DefaultNameFormatter df = DefaultNameFormatter.getInstance();
    818820            if (ways + nodes + relations == 1) {
    819821                text.append(": ");
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r8444 r8468  
    605605
    606606        public class DialogPopupMenu extends JPopupMenu {
    607             private final ButtonGroup buttonHidingGroup = new ButtonGroup();
    608             private final JMenu buttonHidingMenu = new JMenu(tr("Side buttons"));
    609 
     607
     608            /**
     609             * Constructs a new {@code DialogPopupMenu}.
     610             */
    610611            public DialogPopupMenu() {
    611612                alwaysShown.setSelected(buttonHiding == ButtonHidingType.ALWAYS_SHOWN);
    612613                dynamic.setSelected(buttonHiding == ButtonHidingType.DYNAMIC);
    613614                alwaysHidden.setSelected(buttonHiding == ButtonHidingType.ALWAYS_HIDDEN);
     615                ButtonGroup buttonHidingGroup = new ButtonGroup();
     616                JMenu buttonHidingMenu = new JMenu(tr("Side buttons"));
    614617                for (JRadioButtonMenuItem rb : new JRadioButtonMenuItem[]{alwaysShown, dynamic, alwaysHidden}) {
    615618                    buttonHidingGroup.add(rb);
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r8404 r8468  
    1414
    1515import javax.swing.DefaultListModel;
    16 import javax.swing.ImageIcon;
    1716import javax.swing.JLabel;
    1817import javax.swing.JList;
     
    195194    static class BookmarkCellRenderer extends JLabel implements ListCellRenderer<BookmarkList.Bookmark> {
    196195
    197         private ImageIcon icon;
    198 
     196        /**
     197         * Constructs a new {@code BookmarkCellRenderer}.
     198         */
    199199        public BookmarkCellRenderer() {
    200200            setOpaque(true);
    201             icon = ImageProvider.get("dialogs", "bookmark");
    202             setIcon(icon);
     201            setIcon(ImageProvider.get("dialogs", "bookmark"));
    203202        }
    204203
     
    217216            StringBuilder sb = new StringBuilder(128);
    218217            sb.append("<html>min[latitude,longitude]=<strong>[")
    219               .append(area.getMinLat()).append(',').append(area.getMinLon()).append("]</strong>")
    220               .append("<br>max[latitude,longitude]=<strong>[")
    221               .append(area.getMaxLat()).append(',').append(area.getMaxLon()).append("]</strong>")
    222               .append("</html>");
     218              .append(area.getMinLat()).append(',').append(area.getMinLon()).append("]</strong>"+
     219                      "<br>max[latitude,longitude]=<strong>[")
     220              .append(area.getMaxLat()).append(',').append(area.getMaxLon()).append("]</strong>"+
     221                      "</html>");
    223222            return sb.toString();
    224223        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java

    r8444 r8468  
    2222    public static final Cascade EMPTY_CASCADE = new Cascade();
    2323
    24     protected Map<String, Object> prop = new HashMap<>();
     24    private Map<String, Object> prop = new HashMap<>();
    2525
    2626    private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})");
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r8419 r8468  
    454454    }
    455455
    456     protected static final CopyOnWriteArrayList<MapPaintSylesUpdateListener> listeners
     456    private static final CopyOnWriteArrayList<MapPaintSylesUpdateListener> listeners
    457457            = new CopyOnWriteArrayList<>();
    458458
  • trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java

    r8442 r8468  
    318318
    319319    class CancelAction extends AbstractAction {
     320
     321        /**
     322         * Constructs a new {@code CancelAction}.
     323         */
    320324        public CancelAction() {
    321325            putValue(NAME, tr("Cancel"));
     
    336340
    337341    class AcceptAccessTokenAction extends AbstractAction implements PropertyChangeListener {
    338         private transient OAuthToken token;
    339 
     342
     343        /**
     344         * Constructs a new {@code AcceptAccessTokenAction}.
     345         */
    340346        public AcceptAccessTokenAction() {
    341347            putValue(NAME, tr("Accept Access Token"));
     
    359365            if (!evt.getPropertyName().equals(AbstractAuthorizationUI.ACCESS_TOKEN_PROP))
    360366                return;
    361             token = (OAuthToken)evt.getNewValue();
    362             updateEnabledState(token);
     367            updateEnabledState((OAuthToken)evt.getNewValue());
    363368        }
    364369    }
     
    366371    class WindowEventHandler extends WindowAdapter {
    367372        @Override
    368         public void windowClosing(WindowEvent arg0) {
     373        public void windowClosing(WindowEvent e) {
    369374            new CancelAction().cancel();
    370375        }
  • trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java

    r8442 r8468  
    113113     */
    114114    private class RetrieveRequestTokenPanel extends JPanel {
    115         private JCheckBox cbShowAdvancedParameters;
    116115
    117116        /**
     
    130129            gc.weightx = 0.0;
    131130            gc.insets = new Insets(0,0,0,3);
    132             pnl.add(cbShowAdvancedParameters = new JCheckBox(), gc);
     131            JCheckBox cbShowAdvancedParameters = new JCheckBox();
     132            pnl.add(cbShowAdvancedParameters, gc);
    133133            cbShowAdvancedParameters.setSelected(false);
    134134            cbShowAdvancedParameters.addItemListener(
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r8404 r8468  
    6767    }
    6868
     69    private List<PrefEntry> allData;
     70    private List<PrefEntry> displayData = new ArrayList<>();
     71    private JosmTextField txtFilter;
     72    private PreferencesTable table;
     73
    6974    private AdvancedPreference() {
    7075        super(/* ICON(preferences/) */ "advanced", tr("Advanced Preferences"), tr("Setting Preference entries directly. Use with caution!"));
     
    7580        return true;
    7681    }
    77 
    78     protected List<PrefEntry> allData;
    79     protected List<PrefEntry> displayData = new ArrayList<>();
    80     protected JosmTextField txtFilter;
    81     protected PreferencesTable table;
    8282
    8383    @Override
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r8461 r8468  
    3030
    3131    // properties need JOSM restart to apply, modified rarely enough
    32     protected static final int MAX_KEY_LENGTH = Main.pref.getInteger("tags.paste.max-key-length", 50);
    33     protected static final int MAX_KEY_COUNT = Main.pref.getInteger("tags.paste.max-key-count", 30);
    34     protected static final String KEY_PATTERN = Main.pref.get("tags.paste.tag-pattern", "[0-9a-zA-Z:_]*");
    35     protected static final int MAX_VALUE_LENGTH = 255;
     32    private static final int MAX_KEY_LENGTH = Main.pref.getInteger("tags.paste.max-key-length", 50);
     33    private static final int MAX_KEY_COUNT = Main.pref.getInteger("tags.paste.max-key-count", 30);
     34    private static final String KEY_PATTERN = Main.pref.get("tags.paste.tag-pattern", "[0-9a-zA-Z:_]*");
     35    private static final int MAX_VALUE_LENGTH = 255;
    3636
    3737    private TextTagParser() {
Note: See TracChangeset for help on using the changeset viewer.