Changeset 16844 in josm for trunk


Ignore:
Timestamp:
2020-08-03T22:46:16+02:00 (4 years ago)
Author:
simon04
Message:

fix #12484 - Disable inappropriate AdvancedPreference actions

Edit requires exactly one selected row.
Reset requires at least one selected row.

Location:
trunk/src/org/openstreetmap/josm/gui/preferences/advanced
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r16630 r16844  
    219219                applyFilter();
    220220        });
     221        table.getSelectionModel().addListSelectionListener(event -> edit.setEnabled(table.getSelectedRowCount() == 1));
    221222
    222223        JButton reset = new JButton(tr("Reset"));
    223224        p.add(reset, GBC.std().insets(0, 5, 0, 0));
    224225        reset.addActionListener(e -> table.resetPreferences(gui));
     226        table.getSelectionModel().addListSelectionListener(event -> reset.setEnabled(table.getSelectedRowCount() > 0));
    225227
    226228        JButton read = new JButton(tr("Read from file"));
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r16438 r16844  
    2121import javax.swing.JComponent;
    2222import javax.swing.JLabel;
    23 import javax.swing.JOptionPane;
    2423import javax.swing.JPanel;
    2524import javax.swing.JRadioButton;
     
    9392    public boolean editPreference(final JComponent gui) {
    9493        if (getSelectedRowCount() != 1) {
    95             JOptionPane.showMessageDialog(
    96                     gui,
    97                     tr("Please select the row to edit."),
    98                     tr("Warning"),
    99                     JOptionPane.WARNING_MESSAGE
    100                     );
    10194            return false;
    10295        }
     
    277270    public void resetPreferences(final JComponent gui) {
    278271        if (getSelectedRowCount() == 0) {
    279             JOptionPane.showMessageDialog(
    280                     gui,
    281                     tr("Please select the row to delete."),
    282                     tr("Warning"),
    283                     JOptionPane.WARNING_MESSAGE
    284                     );
    285272            return;
    286273        }
Note: See TracChangeset for help on using the changeset viewer.