Changeset 5081 in josm


Ignore:
Timestamp:
Mar 14, 2012 6:16:14 PM (14 months ago)
Author:
simon04
Message:

fix #7168 - add "Select previous/next Gap" to relation editor as popup menu of the relation members

File:
1 edited

Legend:

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

    r4792 r5081  
    172172            getSelectionModel().addListSelectionListener(zoomToGap); 
    173173            popupMenu.add(zoomToGap); 
     174            popupMenu.addSeparator(); 
     175            popupMenu.add(new SelectPreviousGapAction()); 
     176            popupMenu.add(new SelectNextGapAction()); 
    174177        } 
    175178        return popupMenu; 
     
    247250        public void layerRemoved(Layer oldLayer) { 
    248251            updateEnabledState(); 
     252        } 
     253    } 
     254 
     255    private class SelectPreviousGapAction extends AbstractAction { 
     256 
     257        public SelectPreviousGapAction() { 
     258            putValue(NAME, tr("Select previous Gap")); 
     259            putValue(SHORT_DESCRIPTION, tr("Select the previous relation member which gives rise to a gap")); 
     260        } 
     261 
     262        @Override 
     263        public void actionPerformed(ActionEvent e) { 
     264            int i = getSelectedRow() - 1; 
     265            while (i >= 0 && getMemberTableModel().getWayConnection(i).linkPrev) { 
     266                i--; 
     267            } 
     268            if (i >= 0) { 
     269                getSelectionModel().setSelectionInterval(i, i); 
     270            } 
     271        } 
     272    } 
     273 
     274    private class SelectNextGapAction extends AbstractAction { 
     275 
     276        public SelectNextGapAction() { 
     277            putValue(NAME, tr("Select next Gap")); 
     278            putValue(SHORT_DESCRIPTION, tr("Select the next relation member which gives rise to a gap")); 
     279        } 
     280 
     281        @Override 
     282        public void actionPerformed(ActionEvent e) { 
     283            int i = getSelectedRow() + 1; 
     284            while (i < getRowCount() && getMemberTableModel().getWayConnection(i).linkNext) { 
     285                i++; 
     286            } 
     287            if (i < getRowCount()) { 
     288                getSelectionModel().setSelectionInterval(i, i); 
     289            } 
    249290        } 
    250291    } 
Note: See TracChangeset for help on using the changeset viewer.