Ignore:
Timestamp:
2007-05-06T20:32:32+02:00 (17 years ago)
Author:
frsantos
Message:

Fix all selected errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java

    r2792 r2798  
    9797        private void fixErrors(ActionEvent e)
    9898        {
    99                 DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
    100         if( node == null )
    101                 return;
    102 
     99        TreePath[] selectionPaths = tree.getSelectionPaths();
     100        if( selectionPaths == null )
     101            return;
     102       
    103103        Bag<String, Command> commands = new Bag<String, Command>();
    104 
    105                 Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration();
    106                 while( children.hasMoreElements() )
    107                 {
    108                 DefaultMutableTreeNode childNode = children.nextElement();
    109                 Object nodeInfo = childNode.getUserObject();
    110                 if( nodeInfo instanceof TestError)
     104        Set<DefaultMutableTreeNode> processedNodes = new HashSet<DefaultMutableTreeNode>();
     105        for( TreePath path : selectionPaths )
     106        {
     107            DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
     108                if( node == null )
     109                        continue;
     110           
     111                Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration();
     112                while( children.hasMoreElements() )
    111113                {
    112                         TestError error = (TestError)nodeInfo;
    113                         Command fixCommand = error.getFix();
    114                         if( fixCommand != null )
    115                         {
    116                                 commands.add(error.getMessage(), fixCommand);
    117                         }
     114                        DefaultMutableTreeNode childNode = children.nextElement();
     115                if( processedNodes.contains(childNode) )
     116                    continue;
     117               
     118                processedNodes.add(childNode);
     119                        Object nodeInfo = childNode.getUserObject();
     120                        if( nodeInfo instanceof TestError)
     121                        {
     122                                TestError error = (TestError)nodeInfo;
     123                                Command fixCommand = error.getFix();
     124                                if( fixCommand != null )
     125                                {
     126                                        commands.add(error.getMessage(), fixCommand);
     127                                }
     128                        }
    118129                }
    119                 }
    120                
     130        }
     131               
    121132                Command fixCommand = null;
    122133                if( commands.size() == 0 )
Note: See TracChangeset for help on using the changeset viewer.