Ignore:
Timestamp:
2016-05-16T14:59:34+02:00 (8 years ago)
Author:
Don-vip
Message:

findbugs: SC_START_IN_CTOR + UW_UNCOND_WAIT + UM_UNNECESSARY_MATH + UPM_UNCALLED_PRIVATE_METHOD + DM_STRING_TOSTRING + DM_BOXED_PRIMITIVE_FOR_COMPARE + SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
7 edited

Legend:

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

    r10173 r10228  
    824824    }
    825825
    826     private int getMaximumAvailableWidth() {
    827         int maxWidth = getSize().width;
    828         for (int i = 0; i < getMenuCount(); i++) {
    829             JMenu menu = getMenu(i);
    830             if (menu != null) {
    831                 maxWidth -= menu.getPreferredSize().width;
    832             }
    833         }
    834         return maxWidth;
    835     }
    836 
    837826    /**
    838827     * Search main menu for items with {@code textToFind} in title.
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r10212 r10228  
    9393 * @author imi
    9494 */
    95 public class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener {
     95public final class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener {
    9696
    9797    private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(Main.pref.get("statusbar.decimal-format", "0.0"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r10212 r10228  
    719719            @Override
    720720            public int compare(Relation o1, Relation o2) {
    721                 int comp = Boolean.valueOf(o1.isDisabledAndHidden()).compareTo(o2.isDisabledAndHidden());
     721                int comp = Boolean.compare(o1.isDisabledAndHidden(), o2.isDisabledAndHidden());
    722722                return comp != 0 ? comp : DefaultNameFormatter.getInstance().getRelationComparator().compare(o1, o2);
    723723            }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java

    r10074 r10228  
    6060        protected void realRun() throws SAXException, IOException, OsmTransferException {
    6161            precacheTask = layer.downloadAreaToCache(progressMonitor, points, 0, 0);
    62             while (!precacheTask.isFinished() && !progressMonitor.isCanceled()) {
    63                 synchronized (this) {
    64                     try {
     62            synchronized (this) {
     63                try {
     64                    while (!precacheTask.isFinished() && !progressMonitor.isCanceled()) {
    6565                        wait(200);
    66                     } catch (InterruptedException ex) {
    67                         Main.warn("InterruptedException in "+getClass().getSimpleName()+" while precaching WMS");
    6866                    }
     67                } catch (InterruptedException ex) {
     68                    Main.warn("InterruptedException in "+getClass().getSimpleName()+" while precaching WMS");
    6969                }
    7070            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java

    r10137 r10228  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.tools.I18n.trn;
    65
    7 import java.awt.Component;
    86import java.awt.GridBagConstraints;
    97import java.awt.GridBagLayout;
    108import java.awt.Insets;
    119import java.awt.Rectangle;
    12 import java.awt.event.ActionEvent;
    13 import java.awt.event.ActionListener;
    1410import java.awt.event.MouseAdapter;
    1511import java.awt.event.MouseEvent;
    16 import java.util.HashSet;
    1712import java.util.List;
    18 import java.util.Set;
    1913
    20 import javax.swing.JCheckBox;
    2114import javax.swing.JLabel;
    22 import javax.swing.JOptionPane;
    2315import javax.swing.SwingConstants;
    2416import javax.swing.SwingUtilities;
     
    2921import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    3022import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    31 import org.openstreetmap.josm.plugins.PluginHandler;
    3223import org.openstreetmap.josm.plugins.PluginInformation;
    3324import org.openstreetmap.josm.tools.OpenBrowser;
    34 import org.openstreetmap.josm.tools.Utils;
    3525
    3626/**
     
    5646    }
    5747
    58     protected String formatPluginRemoteVersion(PluginInformation pi) {
     48    protected static String formatPluginRemoteVersion(PluginInformation pi) {
    5949        StringBuilder sb = new StringBuilder();
    6050        if (pi.version == null || pi.version.trim().isEmpty()) {
     
    6959    }
    7060
    71     protected String formatPluginLocalVersion(PluginInformation pi) {
     61    protected static String formatPluginLocalVersion(PluginInformation pi) {
    7262        if (pi == null)
    7363            return tr("unknown");
     
    7767    }
    7868
    79     protected String formatCheckboxTooltipText(PluginInformation pi) {
     69    protected static String formatCheckboxTooltipText(PluginInformation pi) {
    8070        if (pi == null)
    8171            return "";
     
    10898
    10999    /**
    110      * A plugin checkbox.
    111      */
    112     private class JPluginCheckBox extends JCheckBox {
    113         protected final transient PluginInformation pi;
    114 
    115         JPluginCheckBox(final PluginInformation pi, boolean selected) {
    116             this.pi = pi;
    117             setSelected(selected);
    118             setToolTipText(formatCheckboxTooltipText(pi));
    119             addActionListener(new PluginCbActionListener(this));
    120         }
    121     }
    122 
    123     /**
    124      * Listener called when the user selects/unselects a plugin checkbox.
    125      */
    126     private class PluginCbActionListener implements ActionListener {
    127         private final JPluginCheckBox cb;
    128 
    129         PluginCbActionListener(JPluginCheckBox cb) {
    130             this.cb = cb;
    131         }
    132 
    133         protected void selectRequiredPlugins(PluginInformation info) {
    134             if (info != null && info.requires != null) {
    135                 for (String s : info.getRequiredPlugins()) {
    136                     if (!model.isSelectedPlugin(s)) {
    137                         model.setPluginSelected(s, true);
    138                         selectRequiredPlugins(model.getPluginInformation(s));
    139                     }
    140                 }
    141             }
    142         }
    143 
    144         @Override
    145         public void actionPerformed(ActionEvent e) {
    146             // Select/unselect corresponding plugin in the model
    147             model.setPluginSelected(cb.pi.getName(), cb.isSelected());
    148             // Does the newly selected plugin require other plugins ?
    149             if (cb.isSelected() && cb.pi.requires != null) {
    150                 // Select required plugins
    151                 selectRequiredPlugins(cb.pi);
    152                 // Alert user if plugin requirements are not met
    153                 PluginHandler.checkRequiredPluginsPreconditions(PluginListPanel.this, model.getAvailablePlugins(), cb.pi, false);
    154             } else if (!cb.isSelected()) {
    155                 // If the plugin has been unselected, was it required by other plugins still selected ?
    156                 Set<String> otherPlugins = new HashSet<>();
    157                 for (PluginInformation pi : model.getAvailablePlugins()) {
    158                     if (!pi.equals(cb.pi) && pi.requires != null && model.isSelectedPlugin(pi.getName())) {
    159                         for (String s : pi.getRequiredPlugins()) {
    160                             if (s.equals(cb.pi.getName())) {
    161                                 otherPlugins.add(pi.getName());
    162                                 break;
    163                             }
    164                         }
    165                     }
    166                 }
    167                 if (!otherPlugins.isEmpty()) {
    168                     alertPluginStillRequired(PluginListPanel.this, cb.pi.getName(), otherPlugins);
    169                 }
    170             }
    171         }
    172     }
    173 
    174     /**
    175      * Alerts the user if an unselected plugin is still required by another plugins
    176      *
    177      * @param parent The parent Component used to display error popup
    178      * @param plugin the plugin
    179      * @param otherPlugins the other plugins
    180      */
    181     private static void alertPluginStillRequired(Component parent, String plugin, Set<String> otherPlugins) {
    182         StringBuilder sb = new StringBuilder("<html>")
    183           .append(trn("Plugin {0} is still required by this plugin:",
    184                 "Plugin {0} is still required by these {1} plugins:",
    185                 otherPlugins.size(),
    186                 plugin,
    187                 otherPlugins.size()))
    188           .append(Utils.joinAsHtmlUnorderedList(otherPlugins))
    189           .append("</html>");
    190         JOptionPane.showMessageDialog(
    191                 parent,
    192                 sb.toString(),
    193                 tr("Warning"),
    194                 JOptionPane.WARNING_MESSAGE
    195         );
    196     }
    197 
    198     /**
    199100     * Refreshes the list.
    200101     */
     
    221122            String localversion = formatPluginLocalVersion(model.getPluginInformation(pi.getName()));
    222123
    223             final JPluginCheckBox cbPlugin = new JPluginCheckBox(pi, selected);
     124            final PluginCheckBox cbPlugin = new PluginCheckBox(pi, selected, this, model);
    224125            String pluginText = tr("{0}: Version {1} (local: {2})", pi.getName(), remoteversion, localversion);
    225126            if (pi.requires != null && !pi.requires.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java

    r10137 r10228  
    117117            return ui;
    118118
    119         int sel = Boolean.valueOf(selected).compareTo(other.selected);
     119        int sel = Boolean.compare(selected, other.selected);
    120120        if (sel != 0)
    121121            return sel;
    122122
    123         int ds = Boolean.valueOf(inDataSet).compareTo(other.inDataSet);
     123        int ds = Boolean.compare(inDataSet, other.inDataSet);
    124124        if (ds != 0)
    125125            return ds;
    126126
    127         int std = Boolean.valueOf(inStandard).compareTo(other.inStandard);
     127        int std = Boolean.compare(inStandard, other.inStandard);
    128128        if (std != 0)
    129129            return std;
  • trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java

    r8929 r10228  
    6767            case "n":
    6868            case "north":
    69                 return Math.toRadians(0);
     69                return 0; // 0 degree => 0 radian
    7070            case "ne":
    7171            case "northeast":
     
    7979            case "s":
    8080            case "south":
    81                 return Math.toRadians(180);
     81                return Math.PI; // 180 degree
    8282            case "sw":
    8383            case "southwest":
Note: See TracChangeset for help on using the changeset viewer.