Changeset 4408 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs
- Timestamp:
- 2011-09-08T00:08:02+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
r4363 r4408 22 22 import javax.swing.JTable; 23 23 import javax.swing.ListSelectionModel; 24 import javax.swing.SwingUtilities;25 24 import javax.swing.event.ListSelectionEvent; 26 25 import javax.swing.event.ListSelectionListener; … … 36 35 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 36 import org.openstreetmap.josm.data.osm.PrimitiveId; 38 import org.openstreetmap.josm.data.osm.history.History;39 37 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 40 38 import org.openstreetmap.josm.data.osm.history.HistoryDataSetListener; … … 44 42 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; 45 43 import org.openstreetmap.josm.gui.history.HistoryLoadTask; 46 import org.openstreetmap.josm.tools.BugReportExceptionHandler;47 44 import org.openstreetmap.josm.tools.ImageProvider; 48 45 import org.openstreetmap.josm.tools.Shortcut; … … 290 287 if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { 291 288 int row = historyTable.rowAtPoint(e.getPoint()); 292 new ShowHistoryAction().showHistory(Collections.singletonList(model.getPrimitive(row)));289 HistoryBrowserDialogManager.getInstance().showHistory(Collections.singletonList(model.getPrimitive(row))); 293 290 } 294 291 } … … 306 303 } 307 304 308 protected List<OsmPrimitive> filterPrimitivesWithUnloadedHistory(Collection<OsmPrimitive> primitives) {309 ArrayList<OsmPrimitive> ret = new ArrayList<OsmPrimitive>(primitives.size());310 HistoryDataSet hds = HistoryDataSet.getInstance();311 for (OsmPrimitive p: primitives) {312 if (hds.getHistory(p.getPrimitiveId()) == null) {313 // reload if the history is not in the cache yet314 ret.add(p);315 } else if (!p.isNew() && hds.getHistory(p.getPrimitiveId()).getByVersion(p.getUniqueId()) == null) {316 // reload if the history object of the selected object is not in the cache317 // yet318 ret.add(p);319 }320 }321 return ret;322 }323 324 public void showHistory(final List<OsmPrimitive> primitives) {325 List<OsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(primitives);326 if (!toLoad.isEmpty()) {327 HistoryLoadTask task = new HistoryLoadTask();328 task.add(primitives);329 Main.worker.submit(task);330 }331 332 Runnable r = new Runnable() {333 public void run() {334 try {335 for (OsmPrimitive p : primitives) {336 History h = HistoryDataSet.getInstance().getHistory(p.getPrimitiveId());337 if (h == null) {338 continue;339 }340 HistoryBrowserDialogManager.getInstance().show(h);341 }342 } catch (final Exception e) {343 SwingUtilities.invokeLater(new Runnable() {344 public void run() {345 BugReportExceptionHandler.handleException(e);346 }347 });348 }349 350 }351 };352 Main.worker.submit(r);353 }354 355 305 public void actionPerformed(ActionEvent e) { 356 306 int [] rows = historyTable.getSelectedRows(); 357 307 if (rows == null || rows.length == 0) return; 358 showHistory(model.getPrimitives(rows));308 HistoryBrowserDialogManager.getInstance().showHistory(model.getPrimitives(rows)); 359 309 } 360 310 -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r4357 r4408 17 17 import java.util.Collections; 18 18 import java.util.Comparator; 19 import java.util.HashMap;20 19 import java.util.HashSet; 21 20 import java.util.LinkedList; … … 26 25 import javax.swing.AbstractListModel; 27 26 import javax.swing.DefaultListSelectionModel; 28 import javax.swing.JButton;29 27 import javax.swing.JList; 30 28 import javax.swing.JMenuItem; … … 88 86 private EditRelationSelection actEditRelationSelection; 89 87 private DownloadSelectedIncompleteMembersAction actDownloadSelectedIncompleteMembers; 90 private InspectAction actInspect;91 88 92 89 /** … … 147 144 actDownloadSelectedIncompleteMembers = new DownloadSelectedIncompleteMembersAction(); 148 145 lstPrimitives.getSelectionModel().addListSelectionListener(actDownloadSelectedIncompleteMembers); 149 150 actInspect = new InspectAction();151 lstPrimitives.getSelectionModel().addListSelectionListener(actInspect);152 146 153 147 lstPrimitives.addMouseListener(new SelectionPopupMenuLauncher()); … … 221 215 addSeparator(); 222 216 add(actDownloadSelectedIncompleteMembers); 223 addSeparator();224 add(actInspect);225 217 } 226 218 } … … 851 843 } 852 844 853 class InspectAction extends AbstractAction implements ListSelectionListener {854 public InspectAction() {855 putValue(SHORT_DESCRIPTION, tr("Get detailed information on the internal state of the objects."));856 putValue(NAME, tr("Inspect"));857 updateEnabledState();858 }859 860 public void actionPerformed(ActionEvent e) {861 Collection<OsmPrimitive> sel = model.getSelected();862 if (sel.isEmpty()) return;863 InspectPrimitiveDialog inspectDialog = new InspectPrimitiveDialog(sel, Main.map.mapView.getEditLayer());864 inspectDialog.showDialog();865 }866 867 public void updateEnabledState() {868 setEnabled(!model.getSelected().isEmpty());869 }870 871 public void valueChanged(ListSelectionEvent e) {872 updateEnabledState();873 }874 }875 876 845 /** Quicker comparator, comparing just by type and ID's */ 877 846 static private class OsmPrimitiveQuickComparator implements Comparator<OsmPrimitive> {
Note:
See TracChangeset
for help on using the changeset viewer.