Changeset 2243 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
- Timestamp:
- 2009-10-04T12:07:16+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
r2239 r2243 110 110 } 111 111 }); 112 historyTable.addMouseListener(new ShowHistoryMouseAdapter()); 112 113 113 114 JScrollPane pane = new JScrollPane(historyTable); … … 138 139 model.refresh(); 139 140 } 140 141 /**142 * shows the {@see HistoryBrowserDialog} for a given {@see History}143 *144 * @param h the history. Must not be null.145 * @exception IllegalArgumentException thrown, if h is null146 */147 protected void showHistory(History h) throws IllegalArgumentException {148 if (h == null)149 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "h"));150 if (HistoryBrowserDialogManager.getInstance().existsDialog(h.getId())) {151 HistoryBrowserDialogManager.getInstance().show(h.getId());152 } else {153 HistoryBrowserDialog dialog = new HistoryBrowserDialog(h);154 HistoryBrowserDialogManager.getInstance().show(h.getId(), dialog);155 }156 }157 158 141 159 142 /** … … 233 216 } 234 217 return ret; 218 } 219 220 public OsmPrimitive getPrimitive(int row) { 221 return data.get(row); 235 222 } 236 223 } … … 286 273 } 287 274 275 class ShowHistoryMouseAdapter extends MouseAdapter { 276 @Override 277 public void mouseClicked(MouseEvent e) { 278 if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { 279 int row = historyTable.rowAtPoint(e.getPoint()); 280 new ShowHistoryAction().showHistory(Collections.singletonList(model.getPrimitive(row))); 281 } 282 } 283 } 284 288 285 /** 289 286 * The action for showing history information of the current history item. … … 307 304 } 308 305 309 public void actionPerformed(ActionEvent e) { 310 int [] rows = historyTable.getSelectedRows(); 311 if (rows == null || rows.length == 0) return; 312 313 final List<OsmPrimitive> selectedItems = model.getPrimitives(rows); 314 List<OsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(selectedItems); 306 /** 307 * shows the {@see HistoryBrowserDialog} for a given {@see History} 308 * 309 * @param h the history. Must not be null. 310 * @exception IllegalArgumentException thrown, if h is null 311 */ 312 protected void showHistory(History h) throws IllegalArgumentException { 313 if (h == null) 314 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "h")); 315 if (HistoryBrowserDialogManager.getInstance().existsDialog(h.getId())) { 316 HistoryBrowserDialogManager.getInstance().show(h.getId()); 317 } else { 318 HistoryBrowserDialog dialog = new HistoryBrowserDialog(h); 319 HistoryBrowserDialogManager.getInstance().show(h.getId(), dialog); 320 } 321 } 322 323 public void showHistory(final List<OsmPrimitive> primitives) { 324 List<OsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(primitives); 315 325 if (!toLoad.isEmpty()) { 316 326 HistoryLoadTask task = new HistoryLoadTask(); 317 task.add( selectedItems);327 task.add(primitives); 318 328 Main.worker.submit(task); 319 329 } … … 321 331 Runnable r = new Runnable() { 322 332 public void run() { 323 for (OsmPrimitive p : selectedItems) {333 for (OsmPrimitive p : primitives) { 324 334 History h = HistoryDataSet.getInstance().getHistory(p.getId()); 325 335 if (h == null) { … … 333 343 } 334 344 345 public void actionPerformed(ActionEvent e) { 346 int [] rows = historyTable.getSelectedRows(); 347 if (rows == null || rows.length == 0) return; 348 showHistory(model.getPrimitives(rows)); 349 } 350 335 351 protected void updateEnabledState() { 336 352 setEnabled(historyTable.getSelectedRowCount() > 0);
Note:
See TracChangeset
for help on using the changeset viewer.