Ignore:
Timestamp:
2011-09-08T00:08:02+02:00 (13 years ago)
Author:
simon04
Message:

fix #6773 - shortcuts for History and Advanced info dialog

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  
    2222import javax.swing.JTable;
    2323import javax.swing.ListSelectionModel;
    24 import javax.swing.SwingUtilities;
    2524import javax.swing.event.ListSelectionEvent;
    2625import javax.swing.event.ListSelectionListener;
     
    3635import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3736import org.openstreetmap.josm.data.osm.PrimitiveId;
    38 import org.openstreetmap.josm.data.osm.history.History;
    3937import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
    4038import org.openstreetmap.josm.data.osm.history.HistoryDataSetListener;
     
    4442import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager;
    4543import org.openstreetmap.josm.gui.history.HistoryLoadTask;
    46 import org.openstreetmap.josm.tools.BugReportExceptionHandler;
    4744import org.openstreetmap.josm.tools.ImageProvider;
    4845import org.openstreetmap.josm.tools.Shortcut;
     
    290287            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
    291288                int row = historyTable.rowAtPoint(e.getPoint());
    292                 new ShowHistoryAction().showHistory(Collections.singletonList(model.getPrimitive(row)));
     289                HistoryBrowserDialogManager.getInstance().showHistory(Collections.singletonList(model.getPrimitive(row)));
    293290            }
    294291        }
     
    306303        }
    307304
    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 yet
    314                     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 cache
    317                     // yet
    318                     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 
    355305        public void actionPerformed(ActionEvent e) {
    356306            int [] rows = historyTable.getSelectedRows();
    357307            if (rows == null || rows.length == 0) return;
    358             showHistory(model.getPrimitives(rows));
     308            HistoryBrowserDialogManager.getInstance().showHistory(model.getPrimitives(rows));
    359309        }
    360310
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r4357 r4408  
    1717import java.util.Collections;
    1818import java.util.Comparator;
    19 import java.util.HashMap;
    2019import java.util.HashSet;
    2120import java.util.LinkedList;
     
    2625import javax.swing.AbstractListModel;
    2726import javax.swing.DefaultListSelectionModel;
    28 import javax.swing.JButton;
    2927import javax.swing.JList;
    3028import javax.swing.JMenuItem;
     
    8886    private EditRelationSelection actEditRelationSelection;
    8987    private DownloadSelectedIncompleteMembersAction actDownloadSelectedIncompleteMembers;
    90     private InspectAction actInspect;
    9188
    9289    /**
     
    147144        actDownloadSelectedIncompleteMembers = new DownloadSelectedIncompleteMembersAction();
    148145        lstPrimitives.getSelectionModel().addListSelectionListener(actDownloadSelectedIncompleteMembers);
    149 
    150         actInspect = new InspectAction();
    151         lstPrimitives.getSelectionModel().addListSelectionListener(actInspect);
    152146
    153147        lstPrimitives.addMouseListener(new SelectionPopupMenuLauncher());
     
    221215            addSeparator();
    222216            add(actDownloadSelectedIncompleteMembers);
    223             addSeparator();
    224             add(actInspect);
    225217        }
    226218    }
     
    851843    }
    852844
    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 
    876845    /** Quicker comparator, comparing just by type and ID's */
    877846    static private class OsmPrimitiveQuickComparator implements Comparator<OsmPrimitive> {
Note: See TracChangeset for help on using the changeset viewer.