Changeset 9136 in josm


Ignore:
Timestamp:
2015-12-17T00:12:03+01:00 (5 years ago)
Author:
Don-vip
Message:

sonar fixes + javadoc

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

Legend:

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

    r8510 r9136  
    2323import org.openstreetmap.josm.tools.Shortcut;
    2424
     25/**
     26 * Abstract base class for info actions, opening an URL describing a particular object.
     27 * @since 1697
     28 */
    2529public abstract class AbstractInfoAction extends JosmAction {
    2630
     31    /**
     32     * Constructs a new {@code AbstractInfoAction}.
     33     * @param installAdapters false, if you don't want to install layer changed and selection changed adapters
     34     */
    2735    public AbstractInfoAction(boolean installAdapters) {
    2836        super(installAdapters);
    2937    }
    3038
     39    /**
     40     * Constructs a new {@code AbstractInfoAction}.
     41     * @param name the action's text as displayed on the menu (if it is added to a menu)
     42     * @param iconName the filename of the icon to use
     43     * @param tooltip  a longer description of the action that will be displayed in the tooltip. Please note
     44     *           that html is not supported for menu actions on some platforms.
     45     * @param shortcut a ready-created shortcut object or null if you don't want a shortcut. But you always
     46     *            do want a shortcut, remember you can always register it with group=none, so you
     47     *            won't be assigned a shortcut unless the user configures one. If you pass null here,
     48     *            the user CANNOT configure a shortcut for your action.
     49     * @param register register this action for the toolbar preferences?
     50     * @param toolbarId identifier for the toolbar preferences. The iconName is used, if this parameter is null
     51     * @param installAdapters false, if you don't want to install layer changed and selection changed adapters
     52     */
    3153    public AbstractInfoAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register,
    3254            String toolbarId, boolean installAdapters) {
     
    3456    }
    3557
     58    /**
     59     * Asks user confirmation before launching a large number of browser windows.
     60     * @param numBrowsers the number of browser windows to open
     61     * @return {@code true} if the user confirms, {@code false} otherwise
     62     */
    3663    public static boolean confirmLaunchMultiple(int numBrowsers) {
    3764        String msg  = /* for correct i18n of plural forms - see #9110 */ trn(
  • trunk/src/org/openstreetmap/josm/actions/HistoryInfoWebAction.java

    r8846 r9136  
    1212import org.openstreetmap.josm.tools.Shortcut;
    1313
     14/**
     15 * Display history information about OSM ways, nodes, or relations in web browser.
     16 * @since 4408
     17 */
    1418public class HistoryInfoWebAction extends AbstractInfoAction {
    1519
  • trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java

    r8846 r9136  
    5959    private void updateEnabledStateWithNotes() {
    6060        // Allows enabling if a note is selected, even if no OSM object is selected
    61         if (!isEnabled() && Main.isDisplayingMapView()) {
    62             if (Main.map.noteDialog.getSelectedNote() != null) {
    63                 setEnabled(true);
    64             }
     61        if (!isEnabled() && Main.isDisplayingMapView() && Main.map.noteDialog.getSelectedNote() != null) {
     62            setEnabled(true);
    6563        }
    6664    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r9078 r9136  
    131131    }
    132132
     133    /**
     134     * Refreshes user list from given collection of OSM primitives.
     135     * @param fromPrimitives OSM primitives to fetch users from
     136     */
    133137    public void refresh(Collection<? extends OsmPrimitive> fromPrimitives) {
    134138        model.populate(fromPrimitives);
     
    152156            refresh(((OsmDataLayer) layer).data.getAllSelected());
    153157        }
    154 
    155158    }
    156159
     
    169172        public void select() {
    170173            int[] indexes = userTable.getSelectedRows();
    171             if (indexes == null || indexes.length == 0) return;
     174            if (indexes == null || indexes.length == 0)
     175                return;
    172176            model.selectPrimitivesOwnedBy(userTable.getSelectedRows());
    173177        }
     
    188192    }
    189193
    190     /*
    191      * Action for launching the info page of a user
     194    /**
     195     * Action for launching the info page of a user.
    192196     */
    193197    class ShowUserInfoAction extends AbstractInfoAction implements ListSelectionListener {
     
    204208        public void actionPerformed(ActionEvent e) {
    205209            int[] rows = userTable.getSelectedRows();
    206             if (rows == null || rows.length == 0) return;
     210            if (rows == null || rows.length == 0)
     211                return;
    207212            List<User> users = model.getSelectedUsers(rows);
    208             if (users.isEmpty()) return;
     213            if (users.isEmpty())
     214                return;
    209215            if (users.size() > 10) {
    210216                Main.warn(tr("Only launching info browsers for the first {0} of {1} selected users", 10, users.size()));
     
    257263     */
    258264    private static class UserInfo implements Comparable<UserInfo> {
    259         public User user;
    260         public int count;
    261         public double percent;
     265        public final User user;
     266        public final int count;
     267        public final double percent;
    262268
    263269        UserInfo(User user, int count, double percent) {
     
    269275        @Override
    270276        public int compareTo(UserInfo o) {
    271             if (count < o.count) return 1;
    272             if (count > o.count) return -1;
    273             if (user == null || user.getName() == null) return 1;
    274             if (o.user == null || o.user.getName() == null) return -1;
     277            if (count < o.count)
     278                return 1;
     279            if (count > o.count)
     280                return -1;
     281            if (user == null || user.getName() == null)
     282                return 1;
     283            if (o.user == null || o.user.getName() == null)
     284                return -1;
    275285            return user.getName().compareTo(o.user.getName());
    276286        }
     
    297307        protected Map<User, Integer> computeStatistics(Collection<? extends OsmPrimitive> primitives) {
    298308            Map<User, Integer> ret = new HashMap<>();
    299             if (primitives == null || primitives.isEmpty()) return ret;
     309            if (primitives == null || primitives.isEmpty())
     310                return ret;
    300311            for (OsmPrimitive primitive: primitives) {
    301312                if (ret.containsKey(primitive.getUser())) {
     
    327338        @Override
    328339        public int getRowCount() {
    329             if (data == null) return 0;
     340            if (data == null)
     341                return 0;
    330342            return data.size();
    331343        }
     
    338350            case 1: /* count */ return info.count;
    339351            case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent);
    340             }
    341             return null;
     352            default: return null;
     353            }
    342354        }
    343355
     
    364376        public List<User> getSelectedUsers(int[] rows) {
    365377            List<User> ret = new LinkedList<>();
    366             if (rows == null || rows.length == 0) return ret;
     378            if (rows == null || rows.length == 0)
     379                return ret;
    367380            for (int row: rows) {
    368381                if (data.get(row).user == null) {
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r9078 r9136  
    4747    private VersionTablePopupMenu popupMenu;
    4848    private final transient HistoryBrowserModel model;
     49
     50    /**
     51     * Constructs a new {@code VersionTable}.
     52     * @param model model used by the history browser
     53     */
     54    public VersionTable(HistoryBrowserModel model) {
     55        super(model.getVersionTableModel(), new VersionTableColumnModel());
     56        model.addObserver(this);
     57        build();
     58        this.model = model;
     59    }
    4960
    5061    protected void build() {
     
    93104    }
    94105
    95     /**
    96      * Constructs a new {@code VersionTable}.
    97      * @param model model used by the history browser
    98      */
    99     public VersionTable(HistoryBrowserModel model) {
    100         super(model.getVersionTableModel(), new VersionTableColumnModel());
    101         model.addObserver(this);
    102         build();
    103         this.model = model;
    104     }
    105 
    106106    // some kind of hack to prevent the table from scrolling to the
    107107    // right when clicking on the cells
     
    140140        @Override
    141141        protected int checkTableSelection(JTable table, Point p) {
    142             HistoryBrowserModel.VersionTableModel model = getVersionTableModel();
     142            HistoryBrowserModel.VersionTableModel tableModel = getVersionTableModel();
    143143            int row = rowAtPoint(p);
    144             if (row > -1 && !model.isLatest(row)) {
    145                 popupMenu.prepare(model.getPrimitive(row));
     144            if (row > -1 && !tableModel.isLatest(row)) {
     145                popupMenu.prepare(tableModel.getPrimitive(row));
    146146            }
    147147            return row;
     
    252252    }
    253253
     254    /**
     255     * Renderer for history radio buttons in columns A and B.
     256     */
    254257    public static class RadioButtonRenderer extends JRadioButton implements TableCellRenderer {
    255258
     
    263266    }
    264267
     268    /**
     269     * Editor for history radio buttons in columns A and B.
     270     */
    265271    public static class RadioButtonEditor extends DefaultCellEditor implements ItemListener {
    266272
     
    278284        @Override
    279285        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    280             if (value == null) return null;
     286            if (value == null)
     287                return null;
    281288            boolean val = (Boolean) value;
    282289            btn.setSelected(val);
     
    297304    }
    298305
     306    /**
     307     * Renderer for history version labels, allowing to define horizontal alignment.
     308     */
    299309    public static class AlignedRenderer extends JLabel implements TableCellRenderer {
    300310
Note: See TracChangeset for help on using the changeset viewer.