Changeset 6783 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-01-30T02:08:22+01:00 (10 years ago)
Author:
Don-vip
Message:

fix some Sonar issues

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

Legend:

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

    r6779 r6783  
    373373     */
    374374    public static String getErrorMessage(Throwable t) {
    375         if (t == null) {
    376                 return null;
    377         }
     375        if (t == null) {
     376            return null;
     377        }
    378378        StringBuilder sb = new StringBuilder(t.getClass().getName());
    379379        String msg = t.getMessage();
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r6623 r6783  
    173173    }
    174174
    175     protected Layer getActiveLayer() {
    176         try {
    177             return Main.map.mapView.getActiveLayer();
    178         } catch(NullPointerException e) {
    179             return null;
    180         }
    181     }
    182 
    183175    /**
    184176     * Replies the first selected layer in the layer list dialog. null, if no
     
    208200            }
    209201        } else if (mode.equals("layer")) {
    210             if (getActiveLayer() == null)
     202            if (Main.main.getActiveLayer() == null)
    211203                return null;
    212204            // try to zoom to the first selected layer
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r6699 r6783  
    285285
    286286    private static void addPresetValue(TaggingPreset p, KeyedItem ky) {
    287         if (ky.key != null && ky.getValues() != null) {
     287        Collection<String> values = ky.getValues();
     288        if (ky.key != null && values != null) {
    288289            try {
    289                 presetsValueData.putAll(ky.key, ky.getValues());
     290                presetsValueData.putAll(ky.key, values);
    290291            } catch (NullPointerException e) {
    291292                Main.error(p+": Unable to initialize "+ky);
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r6595 r6783  
    3131import javax.swing.UIManager;
    3232
    33 import org.openstreetmap.josm.Main;
    3433import org.openstreetmap.josm.gui.help.HelpBrowser;
    3534import org.openstreetmap.josm.gui.help.HelpUtil;
     
    431430        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    432431        Dimension x = new Dimension(screenSize.width*2/3, screenSize.height*2/3);
    433         try {
    434             if(parent != null) {
    435                 x = JOptionPane.getFrameForComponent(parent).getSize();
    436             }
    437         } catch(NullPointerException e) {
    438             Main.warn(e);
     432        if (parent != null) {
     433            x = JOptionPane.getFrameForComponent(parent).getSize();
    439434        }
    440435        return x;
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r6666 r6783  
    283283                                    }
    284284
    285 
    286285                                    // Popup Information
    287286                                    // display them if the middle mouse button is pressed and
     
    328327                                    oldMousePos = ms.mousePos;
    329328                                } catch (ConcurrentModificationException x) {
    330                                     Main.warn(x);
    331                                 } catch (NullPointerException x) {
    332329                                    Main.warn(x);
    333330                                } finally {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r6706 r6783  
    109109    private LayerListModel model;
    110110
    111     /** the selection model */
    112     private DefaultListSelectionModel selectionModel;
    113 
    114111    /** the list of layers (technically its a JTable, but appears like a list) */
    115112    private LayerList layerList;
     
    165162        // create the models
    166163        //
    167         selectionModel = new DefaultListSelectionModel();
     164        DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    168165        selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    169166        model = new LayerListModel(selectionModel);
  • trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java

    r6362 r6783  
    2727     * @return the base wiki URL
    2828     */
    29     static public String getWikiBaseUrl() {
     29    public static String getWikiBaseUrl() {
    3030        return Main.pref.get("help.baseurl", Main.JOSM_WEBSITE);
    3131    }
     
    3636     * @return the base wiki URL for help pages
    3737     */
    38     static public String getWikiBaseHelpUrl() {
     38    public static String getWikiBaseHelpUrl() {
    3939        return getWikiBaseUrl() + "/wiki";
    4040    }
     
    4747     * @see #buildAbsoluteHelpTopic
    4848     */
    49     static public String getHelpTopicUrl(String absoluteHelpTopic) {
     49    public static String getHelpTopicUrl(String absoluteHelpTopic) {
    5050        if(absoluteHelpTopic == null)
    5151            return null;
     
    6363     * @return the URL to the edit page
    6464     */
    65     static public String getHelpTopicEditUrl(String absoluteHelpTopic) {
     65    public static String getHelpTopicEditUrl(String absoluteHelpTopic) {
    6666        String topicUrl = getHelpTopicUrl(absoluteHelpTopic);
    6767        topicUrl = topicUrl.replaceAll("#[^#]*$", ""); // remove optional fragment
     
    7676     * @return the relative help topic in the URL, i.e. "/Action/New"
    7777     */
    78     static public String extractRelativeHelpTopic(String url) {
     78    public static String extractRelativeHelpTopic(String url) {
    7979        String topic = extractAbsoluteHelpTopic(url);
    8080        if (topic == null)
     
    9494     * @return the absolute help topic in the URL, i.e. "/De:Help/Action/New"
    9595     */
    96     static public String extractAbsoluteHelpTopic(String url) {
     96    public static String extractAbsoluteHelpTopic(String url) {
    9797        if (!url.startsWith(getWikiBaseHelpUrl())) return null;
    9898        url = url.substring(getWikiBaseHelpUrl().length());
     
    119119     * @since 5915
    120120     */
    121     static private String getHelpTopicPrefix(LocaleType type) {
     121    private static String getHelpTopicPrefix(LocaleType type) {
    122122        String ret = LanguageInfo.getWikiLanguagePrefix(type);
    123123        if(ret == null)
     
    138138     * @since 5915
    139139     */
    140     static public String buildAbsoluteHelpTopic(String topic, LocaleType type) {
     140    public static String buildAbsoluteHelpTopic(String topic, LocaleType type) {
    141141        String prefix = getHelpTopicPrefix(type);
    142142        if (prefix == null || topic == null || topic.trim().length() == 0 || topic.trim().equals("/"))
     
    151151     * @return the help topic. null, if no context specific help topic is found
    152152     */
    153     static public String getContextSpecificHelpTopic(Object context) {
     153    public static String getContextSpecificHelpTopic(Object context) {
    154154        if (context == null)
    155155            return null;
     
    183183     * @return instance of help action
    184184     */
    185     static private Action getHelpAction() {
    186         try {
     185    private static Action getHelpAction() {
     186        if (Main.main.menu != null) {
    187187            return Main.main.menu.help;
    188         } catch(NullPointerException e) {
    189             return new HelpAction();
    190         }
     188        }
     189        return new HelpAction();
    191190    }
    192191
     
    201200     * @param relativeHelpTopic the help topic. Set to the default help topic if null.
    202201     */
    203     static public void setHelpContext(JComponent component, String relativeHelpTopic) {
     202    public static void setHelpContext(JComponent component, String relativeHelpTopic) {
    204203        if (relativeHelpTopic == null) {
    205204            relativeHelpTopic = "/";
     
    224223     * @param helpTopic
    225224     */
    226     static public String ht(String helpTopic) {
     225    public static String ht(String helpTopic) {
    227226        // this is just a marker method
    228227        return helpTopic;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r6643 r6783  
    196196                    if (children != null) {
    197197                        progressMonitor.subTask(tr("Scanning directory {0}", f.getPath()));
    198                         try {
    199                             addRecursiveFiles(files, Arrays.asList(children));
    200                         } catch(NullPointerException npe) {
    201                             Main.error(npe);
    202                             rememberError(tr("Found null file in directory {0}\n", f.getPath()));
    203                         }
     198                        addRecursiveFiles(files, Arrays.asList(children));
    204199                    } else {
    205200                        rememberError(tr("Error while getting files from directory {0}\n", f.getPath()));
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java

    r6764 r6783  
    4545    /** the combo box with the available locales */
    4646    private JosmComboBox langCombo;
    47     /** the model for the combo box */
    48     private LanguageComboBoxModel model;
    4947
    5048    @Override
    5149    public void addGui(final PreferenceTabbedPane gui) {
    52         model = new LanguageComboBoxModel();
     50        LanguageComboBoxModel model = new LanguageComboBoxModel();
    5351        // Selecting the language BEFORE the JComboBox listens to model changes speed up initialization by ~35ms (see #7386)
    5452        // See http://stackoverflow.com/questions/3194958/fast-replacement-for-jcombobox-basiccomboboxui
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java

    r6267 r6783  
    4242    private final PresetHandler presetHandler;
    4343
    44     private AutoCompletionManager autocomplete;
    45 
    4644    /**
    4745     * builds the panel with the table for editing tags
     
    183181        CheckParameterUtil.ensureParameterNotNull(layer, "layer");
    184182
    185         autocomplete = layer.data.getAutoCompletionManager();
     183        AutoCompletionManager autocomplete = layer.data.getAutoCompletionManager();
    186184        AutoCompletionList acList = new AutoCompletionList();
    187185
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r6340 r6783  
    245245    }
    246246
    247     private Dimension minimumComponentSize(Node node) {
    248         Component child = childForNode(node);
    249         return (child != null) ? child.getMinimumSize() : new Dimension(0, 0);
    250 
    251     }
    252 
    253247    private Dimension preferredNodeSize(Node root) {
    254248        if (root instanceof Leaf)
Note: See TracChangeset for help on using the changeset viewer.