Changeset 11416 in josm for trunk/src


Ignore:
Timestamp:
2016-12-23T15:19:47+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #14151 - see #14042 - fix NPE properly (regression from r11306) + add robustness

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r11306 r11416  
    202202        if (primitive != null) {
    203203            Changeset cs = primitive.getChangeset();
    204             if (cs != null) {
    205                 update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion());
    206             }
     204            update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion());
    207205        }
    208206    }
     
    219217    /**
    220218     * Updates the content of this panel based on the changeset information given by {@code cs}.
    221      * @param cs the changeset information - must not be null
     219     * @param cs the changeset information
    222220     * @param isLatest whether this relates to a not yet commited changeset
    223221     * @param timestamp the timestamp
     
    227225        lblInfo.setText(getInfoText(timestamp, version, isLatest));
    228226
    229         if (!isLatest) {
     227        if (!isLatest && cs != null) {
    230228            User user = cs.getUser();
    231229            String url = Main.getBaseBrowseUrl() + "/changeset/" + cs.getId();
     
    299297        @Override
    300298        public void actionPerformed(ActionEvent e) {
    301             ChangesetDialog.LaunchChangesetManager.displayChangesets(Collections.singleton(id));
     299            if (id != null) {
     300                ChangesetDialog.LaunchChangesetManager.displayChangesets(Collections.singleton(id));
     301            }
    302302            if (componentToSelect != null) {
    303303                ChangesetCacheManager.getInstance().setSelectedComponentInDetailPanel(componentToSelect);
  • trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java

    r10604 r11416  
    7474
    7575    protected final void refresh() {
    76         if (url != null) {
     76        if (url != null && !url.isEmpty()) {
    7777            setText("<html><a href=\""+url+"\">"+description+"</a></html>");
    7878            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     
    8686
    8787    /**
    88      * Sets the URL to be visited if the user clicks on this URL label. If null, the
    89      * label turns into a normal label without hyperlink.
     88     * Sets the URL to be visited if the user clicks on this URL label.
     89     * If null or empty, the label turns into a normal label without hyperlink.
    9090     *
    9191     * @param url the url. Can be null.
     
    109109    @Override
    110110    public void mouseClicked(MouseEvent e) {
    111         if (SwingUtilities.isLeftMouseButton(e)) {
    112             OpenBrowser.displayUrl(url);
    113         } else if (SwingUtilities.isRightMouseButton(e)) {
    114             ClipboardUtils.copyString(url);
     111        if (url != null && !url.isEmpty()) {
     112            if (SwingUtilities.isLeftMouseButton(e)) {
     113                OpenBrowser.displayUrl(url);
     114            } else if (SwingUtilities.isRightMouseButton(e)) {
     115                ClipboardUtils.copyString(url);
     116            }
    115117        }
    116118    }
Note: See TracChangeset for help on using the changeset viewer.