Ignore:
Timestamp:
2019-03-03T10:19:49+01:00 (5 years ago)
Author:
GerdP
Message:

fix #17345: ValidatorDialog: Ignore button should be disabled sometimes

File:
1 edited

Legend:

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

    r14381 r14825  
    245245
    246246            Object mainNodeInfo = node.getUserObject();
    247             if (!(mainNodeInfo instanceof TestError)) {
    248                 Set<String> state = new HashSet<>();
    249                 // ask if the whole set should be ignored
    250                 if (asked == JOptionPane.DEFAULT_OPTION) {
    251                     String[] a = new String[] {tr("Whole group"), tr("Single elements"), tr("Nothing")};
    252                     asked = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("Ignore whole group or individual elements?"),
    253                             tr("Ignoring elements"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
    254                             a, a[1]);
    255                 }
    256                 if (asked == JOptionPane.YES_NO_OPTION) {
    257                     ValidatorTreePanel.visitTestErrors(node, err -> {
    258                         err.setIgnored(true);
    259                         changed.set(true);
    260                         state.add(node.getDepth() == 1 ? err.getIgnoreSubGroup() : err.getIgnoreGroup());
    261                     }, processedNodes);
    262                     for (String s : state) {
    263                         OsmValidator.addIgnoredError(s);
     247            final int depth = node.getDepth();
     248            if (depth <= 1) {
     249                if (!(mainNodeInfo instanceof TestError)) {
     250                    Set<String> state = new HashSet<>();
     251                    // ask if the whole set should be ignored
     252                    if (asked == JOptionPane.DEFAULT_OPTION) {
     253                        String[] a = new String[] {tr("Whole group"), tr("Single elements"), tr("Nothing")};
     254                        asked = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("Ignore whole group or individual elements?"),
     255                                tr("Ignoring elements"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
     256                                a, a[1]);
    264257                    }
    265                     continue;
    266                 } else if (asked == JOptionPane.CANCEL_OPTION || asked == JOptionPane.CLOSED_OPTION) {
    267                     continue;
    268                 }
    269             }
    270 
    271             ValidatorTreePanel.visitTestErrors(node, error -> {
    272                 String state = error.getIgnoreState();
    273                 if (state != null) {
    274                     OsmValidator.addIgnoredError(state);
    275                 }
    276                 changed.set(true);
    277                 error.setIgnored(true);
    278             }, processedNodes);
     258                    if (asked == JOptionPane.YES_NO_OPTION) {
     259                        ValidatorTreePanel.visitTestErrors(node, err -> {
     260                            err.setIgnored(true);
     261                            changed.set(true);
     262                            state.add(depth == 1 ? err.getIgnoreSubGroup() : err.getIgnoreGroup());
     263                        }, processedNodes);
     264                        for (String s : state) {
     265                            OsmValidator.addIgnoredError(s);
     266                        }
     267                        continue;
     268                    } else if (asked == JOptionPane.CANCEL_OPTION || asked == JOptionPane.CLOSED_OPTION) {
     269                        continue;
     270                    }
     271                }
     272
     273                ValidatorTreePanel.visitTestErrors(node, error -> {
     274                    String state = error.getIgnoreState();
     275                    if (state != null) {
     276                        OsmValidator.addIgnoredError(state);
     277                    }
     278                    changed.set(true);
     279                    error.setIgnored(true);
     280                }, processedNodes);
     281            }
    279282        }
    280283        if (changed.get()) {
     
    348351            selectButton.setEnabled(true);
    349352            if (ignoreButton != null) {
    350                 ignoreButton.setEnabled(true);
     353                ignoreButton.setEnabled(node.getDepth() <= 1);
    351354            }
    352355        }
Note: See TracChangeset for help on using the changeset viewer.