Changeset 13660 in josm


Ignore:
Timestamp:
2018-04-23T01:12:25+02:00 (5 months ago)
Author:
Don-vip
Message:

fix #15883 - Zoom on element when double-clicking on elements of upload window (patch by bagage)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java

    r13564 r13660  
    77import java.awt.GridBagConstraints;
    88import java.awt.GridBagLayout;
     9import java.awt.event.MouseAdapter;
     10import java.awt.event.MouseEvent;
    911import java.util.ArrayList;
     12import java.util.Collections;
    1013import java.util.List;
    1114import java.util.Optional;
     
    1720import javax.swing.JScrollPane;
    1821
     22import org.openstreetmap.josm.actions.AutoScaleAction;
    1923import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2024import org.openstreetmap.josm.gui.PrimitiveRenderer;
     
    5357        setLayout(new GridBagLayout());
    5458        PrimitiveRenderer renderer = new PrimitiveRenderer();
     59        MouseAdapter mouseListener = new MouseAdapter() {
     60            @Override
     61            public void mouseClicked(MouseEvent evt) {
     62                if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
     63                    PrimitiveList list = (PrimitiveList) evt.getSource();
     64                    int index = list.locationToIndex(evt.getPoint());
     65                    AutoScaleAction.zoomTo(Collections.singleton(list.getModel().getElementAt(index)));
     66                }
     67            }
     68        };
    5569        // initialize the three lists for uploaded primitives, but don't add them to the dialog yet, see setUploadedPrimitives()
    5670        //
    5771        lstAdd = new PrimitiveList();
    5872        lstAdd.setCellRenderer(renderer);
     73        lstAdd.addMouseListener(mouseListener);
    5974        lstAdd.setVisibleRowCount(Math.min(lstAdd.getModel().getSize(), 10));
    6075        spAdd = new JScrollPane(lstAdd);
     
    6479        lstUpdate = new PrimitiveList();
    6580        lstUpdate.setCellRenderer(renderer);
     81        lstUpdate.addMouseListener(mouseListener);
    6682        lstUpdate.setVisibleRowCount(Math.min(lstUpdate.getModel().getSize(), 10));
    6783        spUpdate = new JScrollPane(lstUpdate);
     
    7187        lstDelete = new PrimitiveList();
    7288        lstDelete.setCellRenderer(renderer);
     89        lstDelete.addMouseListener(mouseListener);
    7390        lstDelete.setVisibleRowCount(Math.min(lstDelete.getModel().getSize(), 10));
    7491        spDelete = new JScrollPane(lstDelete);
Note: See TracChangeset for help on using the changeset viewer.