Changeset 8475 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2015-06-07T15:46:39+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r8443 r8475 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.notes.Note; 16 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 18 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 68 69 } 69 70 70 protected void launchInfoBrowsersForSelectedPrimitives() { 71 List<OsmPrimitive> primitivesToShow = new ArrayList<>(getCurrentDataSet().getAllSelected()); 71 protected void launchInfoBrowsersForSelectedPrimitivesAndNote() { 72 List<OsmPrimitive> primitivesToShow = new ArrayList<>(); 73 if (getCurrentDataSet() != null) { 74 primitivesToShow.addAll(getCurrentDataSet().getAllSelected()); 75 } 76 77 Note noteToShow = Main.isDisplayingMapView() ? Main.map.noteDialog.getSelectedNote() : null; 72 78 73 79 // filter out new primitives which are not yet uploaded to the server … … 80 86 } 81 87 82 if (primitivesToShow.isEmpty() ) {88 if (primitivesToShow.isEmpty() && noteToShow == null) { 83 89 JOptionPane.showMessageDialog( 84 90 Main.parent, … … 95 101 if (primitivesToShow.size() > max && !confirmLaunchMultiple(primitivesToShow.size())) 96 102 return; 97 for(int i = 0; i < max; i++) { 98 OpenBrowser.displayUrl(createInfoUrl(primitivesToShow.get(i))); 103 for (int i = 0; i < max; i++) { 104 launchInfoBrowser(primitivesToShow.get(i)); 105 } 106 107 if (noteToShow != null) { 108 launchInfoBrowser(noteToShow); 109 } 110 } 111 112 protected final void launchInfoBrowser(Object o) { 113 String url = createInfoUrl(o); 114 if (url != null) { 115 String result = OpenBrowser.displayUrl(url); 116 if (result != null) { 117 Main.warn(result); 118 } 99 119 } 100 120 } … … 102 122 @Override 103 123 public void actionPerformed(ActionEvent e) { 104 launchInfoBrowsersForSelectedPrimitives ();124 launchInfoBrowsersForSelectedPrimitivesAndNote(); 105 125 } 106 126 -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoWebAction.java
r8378 r8475 28 28 @Override 29 29 protected String createInfoUrl(Object infoObject) { 30 OsmPrimitive primitive = (OsmPrimitive) infoObject; 31 return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history"; 30 if (infoObject instanceof OsmPrimitive) { 31 OsmPrimitive primitive = (OsmPrimitive) infoObject; 32 return Main.getBaseBrowseUrl() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history"; 33 } else { 34 return null; 35 } 32 36 } 33 37 } -
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.