Changeset 4697 in josm


Ignore:
Timestamp:
2011-12-22T17:15:25+01:00 (8 years ago)
Author:
bastiK
Message:

see #6883 - property toggle dialog: possibility to select and perform actions on several entries at once. (patch by joshdoe)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4680 r4697  
    128128public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, MapView.EditLayerChangeListener, DataSetListenerAdapter.Listener {
    129129    /**
    130      * Watches for double clicks and from editing or new property, depending on the
    131      * location, the click was.
     130     * Watches for mouse clicks
    132131     * @author imi
    133132     */
    134     public class DblClickWatch extends MouseAdapter {
     133    public class MouseClickWatch extends MouseAdapter {
    135134        @Override public void mouseClicked(MouseEvent e) {
    136135            if (e.getClickCount() < 2)
    137136            {
     137                // single click, clear selection in other table not clicked in
    138138                if (e.getSource() == propertyTable) {
    139139                    membershipTable.clearSelection();
     
    142142                }
    143143            }
     144            // double click, edit or add property
    144145            else if (e.getSource() == propertyTable)
    145146            {
     
    647648
    648649        propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")});
    649         propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     650        propertyTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    650651        propertyTable.getTableHeader().setReorderingAllowed(false);
    651652        propertyTable.addMouseListener(new PopupMenuLauncher() {
     
    833834        }));
    834835
    835         DblClickWatch dblClickWatch = new DblClickWatch();
    836         propertyTable.addMouseListener(dblClickWatch);
    837         membershipTable.addMouseListener(dblClickWatch);
    838         scrollPane.addMouseListener(dblClickWatch);
     836        MouseClickWatch mouseClickWatch = new MouseClickWatch();
     837        propertyTable.addMouseListener(mouseClickWatch);
     838        membershipTable.addMouseListener(mouseClickWatch);
     839        scrollPane.addMouseListener(mouseClickWatch);
    839840
    840841        selectSth.setPreferredSize(scrollPane.getSize());
     
    10971098        @Override
    10981099        public void actionPerformed(ActionEvent e) {
    1099             if (propertyTable.getSelectedRowCount() >0 ) {
    1100                 int row = propertyTable.getSelectedRow();
    1101                 deleteProperty(row);
     1100            if (propertyTable.getSelectedRowCount() > 0) {
     1101                int[] rows = propertyTable.getSelectedRows();
     1102                for (int i = rows.length - 1; i >= 0; i--) {
     1103                    deleteProperty(rows[i]);
     1104                }
    11021105            } else if (membershipTable.getSelectedRowCount() > 0) {
    11031106                int row = membershipTable.getSelectedRow();
     
    11091112        protected void updateEnabledState() {
    11101113            setEnabled(
    1111                     (propertyTable != null && propertyTable.getSelectedRowCount() == 1)
    1112                     ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1)
     1114                    (propertyTable != null && propertyTable.getSelectedRowCount() >= 1)
     1115                    || (membershipTable != null && membershipTable.getSelectedRowCount() == 1)
    11131116                    );
    11141117        }
Note: See TracChangeset for help on using the changeset viewer.