Changeset 13171 in josm


Ignore:
Timestamp:
2017-11-27T20:19:15+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15598 - relation editor: handle double click in child and referring browsers the same way (patch by cmuelle8, modified)

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r13130 r13171  
    1010import java.awt.FlowLayout;
    1111import java.awt.event.ActionEvent;
     12import java.awt.event.MouseAdapter;
     13import java.awt.event.MouseEvent;
    1214import java.io.IOException;
    1315import java.net.HttpURLConnection;
     
    6668    private transient OsmDataLayer layer;
    6769
     70    /** the editAction used in the bottom panel and for doubleClick */
     71    private EditAction editAction;
     72
    6873    /**
    6974     * Replies the {@link OsmDataLayer} this editor is related to
     
    8590
    8691        add(buildButtonPanel(), BorderLayout.SOUTH);
     92        childTree.setToggleClickCount(0);
     93        childTree.addMouseListener(new MouseAdapter() {
     94            @Override
     95            public void mouseClicked(MouseEvent e) {
     96                if (e.getClickCount() == 2
     97                    && !e.isAltDown() && !e.isAltGraphDown() && !e.isControlDown() && !e.isMetaDown() && !e.isShiftDown()
     98                    && childTree.getRowForLocation(e.getX(), e.getY()) == childTree.getMinSelectionRow()) {
     99                    Relation r = (Relation) childTree.getLastSelectedPathComponent();
     100                    if (r.isIncomplete()) {
     101                        childTree.expandPath(childTree.getSelectionPath());
     102                    } else {
     103                        editAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, null));
     104                    }
     105                }
     106            }
     107        });
    87108    }
    88109
     
    105126
    106127        // ---
    107         EditAction editAction = new EditAction();
     128        editAction = new EditAction();
    108129        childTree.addTreeSelectionListener(editAction);
    109130        pnl.add(new JButton(editAction));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java

    r12675 r13171  
    4545     * Constructs a new {@code ReferringRelationsBrowser}.
    4646     * @param layer OSM data layer
    47      * @param model referrinf relations browser model
     47     * @param model referring relations browser model
    4848     */
    4949    public ReferringRelationsBrowser(OsmDataLayer layer, ReferringRelationsBrowserModel model) {
     
    6262        add(new JScrollPane(referrers), BorderLayout.CENTER);
    6363        referrers.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    64         referrers.addMouseListener(new DblClickMouseAdapter());
     64        referrers.addMouseListener(new MouseAdapter() {
     65            @Override
     66            public void mouseClicked(MouseEvent e) {
     67                if (e.getClickCount() == 2
     68                    && !e.isAltDown() && !e.isAltGraphDown() && !e.isControlDown() && !e.isMetaDown() && !e.isShiftDown()
     69                    && referrers.getCellBounds(referrers.getSelectedIndex(), referrers.getSelectedIndex()).contains(e.getPoint())) {
     70                    editAction.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, null));
     71                }
     72            }
     73        });
    6574
    6675        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
     
    171180        }
    172181    }
    173 
    174     class DblClickMouseAdapter extends MouseAdapter {
    175         @Override
    176         public void mouseClicked(MouseEvent e) {
    177             if (e.getClickCount() == 2) {
    178                 editAction.run();
    179             }
    180         }
    181     }
    182182}
Note: See TracChangeset for help on using the changeset viewer.