- Timestamp:
- 2015-06-07T15:46:39+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 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 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r8392 r8475 216 216 } 217 217 updateButtonStates(); 218 // TODO make a proper listener mechanism to handle change of note selection 219 Main.main.menu.infoweb.noteSelectionChanged(); 220 } 221 222 /** 223 * Returns the currently selected note, if any. 224 * @return currently selected note, or null 225 * @since 8475 226 */ 227 public Note getSelectedNote() { 228 return noteData != null ? noteData.getSelectedNote() : null; 218 229 } 219 230 … … 254 265 private transient List<Note> data; 255 266 267 /** 268 * Constructs a new {@code NoteTableModel}. 269 */ 256 270 public NoteTableModel() { 257 271 data = new ArrayList<>(); … … 286 300 class AddCommentAction extends AbstractAction { 287 301 302 /** 303 * Constructs a new {@code AddCommentAction}. 304 */ 288 305 public AddCommentAction() { 289 306 putValue(SHORT_DESCRIPTION,tr("Add comment")); … … 315 332 class CloseAction extends AbstractAction { 316 333 334 /** 335 * Constructs a new {@code CloseAction}. 336 */ 317 337 public CloseAction() { 318 putValue(SHORT_DESCRIPTION, tr("Close note"));338 putValue(SHORT_DESCRIPTION, tr("Close note")); 319 339 putValue(NAME, tr("Close")); 320 340 putValue(SMALL_ICON, ICON_CLOSED); … … 337 357 class NewAction extends AbstractAction { 338 358 359 /** 360 * Constructs a new {@code NewAction}. 361 */ 339 362 public NewAction() { 340 putValue(SHORT_DESCRIPTION, tr("Create a new note"));363 putValue(SHORT_DESCRIPTION, tr("Create a new note")); 341 364 putValue(NAME, tr("Create")); 342 365 putValue(SMALL_ICON, ICON_NEW); … … 354 377 class ReopenAction extends AbstractAction { 355 378 379 /** 380 * Constructs a new {@code ReopenAction}. 381 */ 356 382 public ReopenAction() { 357 putValue(SHORT_DESCRIPTION, tr("Reopen note"));383 putValue(SHORT_DESCRIPTION, tr("Reopen note")); 358 384 putValue(NAME, tr("Reopen")); 359 385 putValue(SMALL_ICON, ICON_OPEN); … … 377 403 class SortAction extends AbstractAction { 378 404 405 /** 406 * Constructs a new {@code SortAction}. 407 */ 379 408 public SortAction() { 380 409 putValue(SHORT_DESCRIPTION, tr("Sort notes")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r8444 r8475 220 220 @Override 221 221 protected String createInfoUrl(Object infoObject) { 222 User user = (User)infoObject; 223 return Main.getBaseUserUrl() + "/" + Utils.encodeUrl(user.getName()).replaceAll("\\+", "%20"); 222 if (infoObject instanceof User) { 223 User user = (User)infoObject; 224 return Main.getBaseUserUrl() + "/" + Utils.encodeUrl(user.getName()).replaceAll("\\+", "%20"); 225 } else { 226 return null; 227 } 224 228 } 225 229 -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r8419 r8475 162 162 @Override 163 163 protected String createInfoUrl(Object infoObject) { 164 HistoryOsmPrimitive primitive = (HistoryOsmPrimitive) infoObject; 165 return Main.getBaseBrowseUrl() + "/changeset/" + primitive.getChangesetId(); 164 if (infoObject instanceof HistoryOsmPrimitive) { 165 HistoryOsmPrimitive prim = (HistoryOsmPrimitive) infoObject; 166 return Main.getBaseBrowseUrl() + "/changeset/" + prim.getChangesetId(); 167 } else { 168 return null; 169 } 166 170 } 167 171 … … 195 199 @Override 196 200 protected String createInfoUrl(Object infoObject) { 197 HistoryOsmPrimitive hp = (HistoryOsmPrimitive) infoObject; 198 return hp.getUser() == null ? null : Main.getBaseUserUrl() + "/" + hp.getUser().getName(); 201 if (infoObject instanceof HistoryOsmPrimitive) { 202 HistoryOsmPrimitive hp = (HistoryOsmPrimitive) infoObject; 203 return hp.getUser() == null ? null : Main.getBaseUserUrl() + "/" + hp.getUser().getName(); 204 } else { 205 return null; 206 } 199 207 } 200 208
Note:
See TracChangeset
for help on using the changeset viewer.