Ignore:
Timestamp:
2015-06-07T15:46:39+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11219 - Open notes in browser with Ctrl-Shift-I: "Advanced info (web)"

File:
1 edited

Legend:

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

    r8378 r8475  
    66
    77import java.awt.event.KeyEvent;
     8import java.util.Collection;
    89
    910import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.notes.Note;
    1012import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1113import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    3133
    3234    @Override
    33     protected  String createInfoUrl(Object infoObject) {
    34         OsmPrimitive primitive = (OsmPrimitive)infoObject;
    35         return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId();
     35    protected String createInfoUrl(Object infoObject) {
     36        if (infoObject instanceof OsmPrimitive) {
     37            OsmPrimitive primitive = (OsmPrimitive)infoObject;
     38            return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId();
     39        } else if (infoObject instanceof Note) {
     40            Note note = (Note)infoObject;
     41            return Main.getBaseBrowseUrl() + "/note/" + note.getId();
     42        } else {
     43            return null;
     44        }
     45    }
     46
     47    @Override
     48    protected void updateEnabledState() {
     49        super.updateEnabledState();
     50        updateEnabledStateWithNotes();
     51    }
     52
     53    @Override
     54    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
     55        super.updateEnabledState(selection);
     56        updateEnabledStateWithNotes();
     57    }
     58
     59    private void updateEnabledStateWithNotes() {
     60        // 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            }
     65        }
     66    }
     67
     68    /**
     69     * Called when the note selection has changed.
     70     * TODO: make a proper listener mechanism to handle change of note selection
     71     * @since 8475
     72     */
     73    public final void noteSelectionChanged() {
     74        updateEnabledState();
    3675    }
    3776}
Note: See TracChangeset for help on using the changeset viewer.