Changeset 9111 in osm for applications/editors/josm
- Timestamp:
- 2008-07-17T10:21:52+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
r8905 r9111 58 58 WronglyOrderedWays.class, 59 59 UnclosedWays.class, 60 TagChecker.class, 60 61 }; 61 62 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java
r6303 r9111 131 131 { 132 132 this.severity = severity; 133 } 134 135 /** 136 * Sets the ignore state for this error 137 */ 138 public void getIgnoreState() 139 { 140 System.out.println("Ignore " + message); 141 for (OsmPrimitive o : primitives) 142 { 143 System.out.println(o.id + " - " + o.getClass()); 144 } 133 145 } 134 146 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
r6389 r9111 34 34 private OSMValidatorPlugin plugin; 35 35 36 /** Serializable ID */ 37 private static final long serialVersionUID = 2952292777351992696L; 38 39 /** 40 * The display tree. 41 */ 42 protected ErrorTreePanel tree; 43 44 /** 45 * The fix button 46 */ 47 private JButton fixButton; 48 49 /** 50 * The select button 51 */ 52 private JButton selectButton; 53 54 /** Last selected element */ 55 private DefaultMutableTreeNode lastSelectedNode = null; 56 57 /** 58 * Constructor 59 */ 60 public ValidatorDialog(OSMValidatorPlugin plugin) { 61 super(tr("Validation errors"), "validator", tr("Open the validation window."), KeyEvent.VK_V, 150); 36 /** Serializable ID */ 37 private static final long serialVersionUID = 2952292777351992696L; 38 39 /** The display tree */ 40 protected ErrorTreePanel tree; 41 42 /** The fix button */ 43 private JButton fixButton; 44 45 /** The ignore button */ 46 private JButton ignoreButton; 47 48 /** The select button */ 49 private JButton selectButton; 50 51 /** Last selected element */ 52 private DefaultMutableTreeNode lastSelectedNode = null; 53 54 /** 55 * Constructor 56 */ 57 public ValidatorDialog(OSMValidatorPlugin plugin) { 58 super(tr("Validation errors"), "validator", tr("Open the validation window."), KeyEvent.VK_V, 150); 62 59 63 60 this.plugin = plugin; 64 65 61 62 tree = new ErrorTreePanel(); 66 63 tree.addMouseListener(new ClickWatch()); 67 64 tree.addTreeSelectionListener(new SelectionWatch()); … … 69 66 add(new JScrollPane(tree), BorderLayout.CENTER); 70 67 71 JPanel buttonPanel = new JPanel(new GridLayout(1,2)); 72 73 selectButton = Util.createButton("Select", "mapmode/selection/select", "Set the selected elements on the map to the selected items in the list above.", this); 74 selectButton.setEnabled(false); 75 buttonPanel.add(selectButton); 76 //add(buttonPanel, BorderLayout.SOUTH); 77 buttonPanel.add(Util.createButton("Validate", "dialogs/refresh", "Validate the data.", this)); 78 // add(buttonPanel, BorderLayout.SOUTH); 79 fixButton = Util.createButton("Fix", "dialogs/fix", "Fix the selected errors.", this); 80 fixButton.setEnabled(false); 81 buttonPanel.add(fixButton); 82 add(buttonPanel, BorderLayout.SOUTH); 83 } 68 JPanel buttonPanel = new JPanel(new GridLayout(1,2)); 69 70 selectButton = Util.createButton(tr("Select"), "select", "mapmode/selection/select", 71 tr("Set the selected elements on the map to the selected items in the list above."), this); 72 selectButton.setEnabled(false); 73 buttonPanel.add(selectButton); 74 buttonPanel.add(Util.createButton(tr("Validate"), "validate", "dialogs/refresh", tr("Validate the data."), this)); 75 fixButton = Util.createButton(tr("Fix"), "fix", "dialogs/fix", tr("Fix the selected errors."), this); 76 fixButton.setEnabled(false); 77 buttonPanel.add(fixButton); 78 ignoreButton = Util.createButton(tr("Ignore"), "ignore", "dialogs/delete", tr("Ignore the selected errors next time."), this); 79 ignoreButton.setEnabled(false); 80 buttonPanel.add(ignoreButton); 81 add(buttonPanel, BorderLayout.SOUTH); 82 } 84 83 85 84 @Override … … 139 138 plugin.validateAction.doValidate(e, false); 140 139 } 141 140 141 /** 142 * Set selected errors to ignore state 143 * @param e 144 */ 145 @SuppressWarnings("unchecked") 146 private void ignoreErrors(ActionEvent e) 147 { 148 TreePath[] selectionPaths = tree.getSelectionPaths(); 149 if( selectionPaths == null ) 150 return; 151 152 Set<DefaultMutableTreeNode> processedNodes = new HashSet<DefaultMutableTreeNode>(); 153 for( TreePath path : selectionPaths ) 154 { 155 DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); 156 if( node == null ) 157 continue; 158 159 Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration(); 160 while( children.hasMoreElements() ) 161 { 162 DefaultMutableTreeNode childNode = children.nextElement(); 163 if( processedNodes.contains(childNode) ) 164 continue; 165 166 processedNodes.add(childNode); 167 Object nodeInfo = childNode.getUserObject(); 168 if( nodeInfo instanceof TestError) 169 { 170 TestError error = (TestError)nodeInfo; 171 String error.getIgnoreState(); 172 /* ignore */ 173 } 174 } 175 } 176 177 Main.map.repaint(); 178 DataSet.fireSelectionChanged(Main.ds.getSelected()); 179 180 plugin.validateAction.doValidate(e, false); 181 } 182 142 183 /** 143 184 * Sets the selection of the map to the current selected items. … … 177 218 { 178 219 String actionCommand = e.getActionCommand(); 179 if( actionCommand.equals(" Select"))220 if( actionCommand.equals("select")) 180 221 setSelectedItems(); 181 else if( actionCommand.equals("Validate")) 182 plugin.validateAction.actionPerformed(e); 183 else if( actionCommand.equals("Fix")) 184 fixErrors(e); 222 else if( actionCommand.equals("validate")) 223 plugin.validateAction.actionPerformed(e); 224 else if( actionCommand.equals("fix")) 225 fixErrors(e); 226 else if( actionCommand.equals("ignore")) 227 ignoreErrors(e); 185 228 } 186 229 … … 211 254 } 212 255 } 213 214 215 if( node == null ) 216 256 257 lastSelectedNode = node; 258 if( node == null ) 259 return hasFixes; 217 260 218 261 Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration(); 219 262 while( children.hasMoreElements() ) 220 263 { 221 222 223 224 225 226 227 228 229 230 231 232 233 264 DefaultMutableTreeNode childNode = children.nextElement(); 265 Object nodeInfo = childNode.getUserObject(); 266 if( nodeInfo instanceof TestError) 267 { 268 TestError error = (TestError)nodeInfo; 269 error.setSelected(true); 270 271 hasFixes = hasFixes || error.isFixable(); 272 if( addSelected ) 273 { 274 sel.addAll( error.getPrimitives() ); 275 } 276 } 234 277 } 235 selectButton.setEnabled(true); 278 selectButton.setEnabled(true); 279 ignoreButton.setEnabled(true); 236 280 237 281 return hasFixes; 238 282 } 239 283 240 284 /** 241 285 * Watches for clicks. … … 243 287 public class ClickWatch extends MouseAdapter 244 288 { 245 @Override 246 public void mouseClicked(MouseEvent e) 289 @Override 290 public void mouseClicked(MouseEvent e) 247 291 { 248 fixButton.setEnabled(false); 249 selectButton.setEnabled(false); 250 292 fixButton.setEnabled(false); 293 ignoreButton.setEnabled(false); 294 selectButton.setEnabled(false); 295 251 296 boolean isDblClick = e.getClickCount() > 1; 252 253 297 Collection<OsmPrimitive> sel = isDblClick ? new HashSet<OsmPrimitive>(40) : null; 298 254 299 boolean hasFixes = setSelection(sel, isDblClick); 255 256 257 if(isDblClick)300 fixButton.setEnabled(hasFixes); 301 302 if(isDblClick) 258 303 { 259 304 Main.ds.setSelected(sel); 260 305 } 261 306 } 262 307 } 263 308 264 309 /** 265 310 * Watches for tree selection. … … 267 312 public class SelectionWatch implements TreeSelectionListener 268 313 { 269 270 public void valueChanged(TreeSelectionEvent e) 314 @SuppressWarnings("unchecked") 315 public void valueChanged(TreeSelectionEvent e) 271 316 { 272 fixButton.setEnabled(false); 273 selectButton.setEnabled(false); 274 317 fixButton.setEnabled(false); 318 ignoreButton.setEnabled(false); 319 selectButton.setEnabled(false); 320 275 321 if(e.getSource() instanceof JScrollPane) 276 277 278 279 280 322 { 323 System.out.println(e.getSource()); 324 return; 325 } 326 281 327 boolean hasFixes = setSelection(null, false); 282 283 Main.map.repaint(); 328 fixButton.setEnabled(hasFixes); 329 Main.map.repaint(); 284 330 } 285 331 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnclosedWays.java
r9021 r9111 28 28 { 29 29 super(tr("Unclosed Ways."), 30 tr("This test if ways which should be circular are closed."));30 tr("This tests if ways which should be circular are closed.")); 31 31 } 32 32 … … 101 101 type = tr("waterway type {0}", tr(test)); 102 102 } 103 test = w.get("junction");103 /*test = w.get("junction"); 104 104 if(test != null && test.equals("roundabout")) 105 105 { 106 106 force = true; 107 107 type = tr("junction type {0}", tr(test)); 108 } 108 }*/ 109 109 test = w.get("building"); 110 110 if (test != null && ("true".equalsIgnoreCase(test) || "yes".equalsIgnoreCase(test) || "1".equals(test))) -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java
r6389 r9111 44 44 * @return The created button 45 45 */ 46 public static JButton createButton(String name, String icon, String tooltip, ActionListener action)47 { 48 JButton button = new JButton( tr(name), ImageProvider.get(icon));49 button.setActionCommand( name);46 public static JButton createButton(String name, String actionname, String icon, String tooltip, ActionListener action) 47 { 48 JButton button = new JButton(name, ImageProvider.get(icon)); 49 button.setActionCommand(actionname); 50 50 button.addActionListener(action); 51 51 button.setToolTipText(tr(tooltip)); 52 button.putClientProperty("help", "Dialog/SelectionList/" + name);52 button.putClientProperty("help", "Dialog/SelectionList/" + actionname); 53 53 return button; 54 54 }
Note:
See TracChangeset
for help on using the changeset viewer.