Changeset 14858 in josm


Ignore:
Timestamp:
2019-03-09T16:12:40+01:00 (6 years ago)
Author:
GerdP
Message:

see #17345: disable ignore button only when the top level (severity) entry is selected
This partly reverts r14825 as it also caused problems with other tests which create different description texts depending on the object(s).

File:
1 edited

Legend:

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

    r14854 r14858  
    5050import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    5151import org.openstreetmap.josm.data.validation.OsmValidator;
     52import org.openstreetmap.josm.data.validation.Severity;
    5253import org.openstreetmap.josm.data.validation.TestError;
    5354import org.openstreetmap.josm.data.validation.ValidatorVisitor;
     
    298299            Object mainNodeInfo = node.getUserObject();
    299300            final int depth = node.getDepth();
    300             if (depth <= 1) {
    301                 if (!(mainNodeInfo instanceof TestError)) {
    302                     Set<Pair<String, String>> state = new HashSet<>();
    303                     // ask if the whole set should be ignored
    304                     if (asked == JOptionPane.DEFAULT_OPTION) {
    305                         String[] a = new String[] {tr("Whole group"), tr("Single elements"), tr("Nothing")};
    306                         asked = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("Ignore whole group or individual elements?"),
    307                                 tr("Ignoring elements"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
    308                                 a, a[1]);
     301            if (!(mainNodeInfo instanceof TestError)) {
     302                Set<Pair<String, String>> state = new HashSet<>();
     303                // ask if the whole set should be ignored
     304                if (asked == JOptionPane.DEFAULT_OPTION) {
     305                    String[] a = new String[] {tr("Whole group"), tr("Single elements"), tr("Nothing")};
     306                    asked = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("Ignore whole group or individual elements?"),
     307                            tr("Ignoring elements"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
     308                            a, a[1]);
     309                }
     310                if (asked == JOptionPane.YES_NO_OPTION) {
     311                    ValidatorTreePanel.visitTestErrors(node, err -> {
     312                        err.setIgnored(true);
     313                        changed.set(true);
     314                        state.add(new Pair<>(depth == 1 ? err.getIgnoreSubGroup() : err.getIgnoreGroup(), err.getMessage()));
     315                    }, processedNodes);
     316                    for (Pair<String, String> s : state) {
     317                        OsmValidator.addIgnoredError(s.a, s.b);
    309318                    }
    310                     if (asked == JOptionPane.YES_NO_OPTION) {
    311                         ValidatorTreePanel.visitTestErrors(node, err -> {
    312                             err.setIgnored(true);
    313                             changed.set(true);
    314                             state.add(new Pair<>(node.getDepth() == 1 ? err.getIgnoreSubGroup() : err.getIgnoreGroup(), err.getMessage()));
    315                         }, processedNodes);
    316                         for (Pair<String, String> s : state) {
    317                             OsmValidator.addIgnoredError(s.a, s.b);
    318                         }
    319                         continue;
    320                     } else if (asked == JOptionPane.CANCEL_OPTION || asked == JOptionPane.CLOSED_OPTION) {
    321                         continue;
    322                     }
    323                 }
    324 
    325                 ValidatorTreePanel.visitTestErrors(node, error -> {
    326                     String state = error.getIgnoreState();
    327                     if (state != null) {
    328                         OsmValidator.addIgnoredError(state, error.getMessage());
    329                     }
    330                     changed.set(true);
    331                     error.setIgnored(true);
    332                 }, processedNodes);
    333             }
     319                    continue;
     320                } else if (asked == JOptionPane.CANCEL_OPTION || asked == JOptionPane.CLOSED_OPTION) {
     321                    continue;
     322                }
     323            }
     324
     325            ValidatorTreePanel.visitTestErrors(node, error -> {
     326                String state = error.getIgnoreState();
     327                if (state != null) {
     328                    OsmValidator.addIgnoredError(state, error.getMessage());
     329                }
     330                changed.set(true);
     331                error.setIgnored(true);
     332            }, processedNodes);
    334333        }
    335334        if (changed.get()) {
     
    402401            selectAction.setEnabled(true);
    403402            if (ignoreAction != null) {
    404                 ignoreAction.setEnabled(node.getDepth() <= 1);
     403                ignoreAction.setEnabled(!(node.getUserObject() instanceof Severity));
    405404            }
    406405        }
Note: See TracChangeset for help on using the changeset viewer.