Changeset 8475 in josm for trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java
- Timestamp:
- 2015-06-07T15:46:39+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java
r8378 r8475 6 6 7 7 import java.awt.event.KeyEvent; 8 import java.util.Collection; 8 9 9 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.notes.Note; 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 31 33 32 34 @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(); 36 75 } 37 76 }
Note:
See TracChangeset
for help on using the changeset viewer.