Changeset 4023 in osm for applications/editors/josm/plugins
- Timestamp:
- 2007-08-08T22:28:09+02:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorLayer.java
r2804 r4023 6 6 import java.awt.Graphics; 7 7 import java.util.Enumeration; 8 import java.util.List; 8 9 9 import javax.swing.*; 10 import javax.swing.Icon; 11 import javax.swing.JMenuItem; 12 import javax.swing.JSeparator; 10 13 import javax.swing.tree.DefaultMutableTreeNode; 11 14 … … 42 45 */ 43 46 @Override public Icon getIcon() { 44 return ImageProvider.get(" preferences", "validator");47 return ImageProvider.get("layer", "validator"); 45 48 } 46 49 … … 82 85 { 83 86 Bag<Severity, TestError> errorTree = new Bag<Severity, TestError>(); 84 for(TestError e : OSMValidatorPlugin.getPlugin().errors) 87 List<TestError> errors = OSMValidatorPlugin.getPlugin().validationDialog.tree.getErrors(); 88 for(TestError e : errors) 85 89 { 86 90 errorTree.add(e.getSeverity(), e); -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorTreePanel.java
r2801 r4023 34 34 public ErrorTreePanel(List<TestError> errors) 35 35 { 36 this.errors = errors;37 36 this.setModel(treeModel); 38 37 this.setRootVisible(false); … … 42 41 this.setCellRenderer(new ErrorTreeRenderer()); 43 42 this.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); 44 45 buildTree(); 43 setErrorList(errors); 46 44 } 47 45 … … 152 150 153 151 /** 154 * Set the errors of the tree 155 * @param errors 152 * Sets the errors list used by a data layer 153 * @param errors The error list that is used by a data layer 154 */ 155 public void setErrorList(List<TestError> errors) 156 { 157 this.errors = errors; 158 if( isVisible() ) 159 buildTree(); 160 } 161 162 /** 163 * Clears the current error list and adds thiese errors to it 164 * @param errors The validation errors 156 165 */ 157 166 public void setErrors(List<TestError> errors) 158 167 { 159 this.errors = errors; 160 } 161 168 this.errors.clear(); 169 this.errors.addAll(errors); 170 if( isVisible() ) 171 buildTree(); 172 } 173 174 /** 175 * Returns the errors of the tree 176 * @return the errors of the tree 177 */ 178 public List<TestError> getErrors() 179 { 180 return errors != null ? errors : Collections.<TestError>emptyList(); 181 } 182 162 183 /** 163 184 * Expands all tree -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
r3261 r4023 14 14 import org.openstreetmap.josm.actions.UploadAction.UploadHook; 15 15 import org.openstreetmap.josm.gui.MapFrame; 16 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 17 import org.openstreetmap.josm.gui.layer.Layer; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 19 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 17 20 import org.openstreetmap.josm.plugins.Plugin; … … 25 28 * @author Francisco R. Santos <frsantos@gmail.com> 26 29 */ 27 public class OSMValidatorPlugin extends Plugin 30 public class OSMValidatorPlugin extends Plugin implements LayerChangeListener 28 31 { 29 32 /** The validate action */ … … 33 36 ValidatorDialog validationDialog; 34 37 35 /** The list of errors */36 List<TestError> errors = new ArrayList<TestError>(30);37 38 /** The list of errors per layer*/ 39 Map<Layer, List<TestError>> layerErrors = new HashMap<Layer, List<TestError>>(); 40 38 41 /** 39 42 * All available tests … … 54 57 CrossingSegments.class, 55 58 SimilarNamedWays.class, 59 Coastlines.class, 56 60 }; 57 61 … … 75 79 if (newFrame != null) 76 80 { 77 errors = new ArrayList<TestError>(50);78 81 validationDialog = new ValidatorDialog(); 79 82 newFrame.addToggleDialog(validationDialog); 80 83 Main.main.addLayer(new ErrorLayer(tr("Validation errors"))); 81 } 84 Main.map.mapView.addLayerChangeListener(this); 85 } 86 else 87 oldFrame.mapView.removeLayerChangeListener(this); 82 88 83 89 // Add/Remove the upload hook … … 163 169 * Gets the list of all available test classes 164 170 * 165 * @return An array of the test classes 171 * @return An array of the test classes validationDialog.tree.setErrorList(errors); 166 172 */ 167 173 public static Class[] getAllAvailableTests() … … 197 203 } 198 204 } 205 206 public void activeLayerChange(Layer oldLayer, Layer newLayer) 207 { 208 if( newLayer instanceof OsmDataLayer ) 209 { 210 List<TestError> errors = layerErrors.get(newLayer); 211 validationDialog.tree.setErrorList(errors); 212 Main.map.repaint(); 213 } 214 } 215 216 public void layerAdded(Layer newLayer) 217 { 218 if( newLayer instanceof OsmDataLayer ) 219 { 220 layerErrors.put(newLayer, new ArrayList<TestError>() ); 221 } 222 } 223 224 public void layerRemoved(Layer oldLayer) 225 { 226 layerErrors.remove(oldLayer); 227 } 199 228 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java
r2800 r4023 5 5 import java.util.ArrayList; 6 6 import java.util.Collection; 7 import java.util.List; 7 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.actions.JosmAction; 11 import org.openstreetmap.josm.data.osm.DataSet; 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 13 import org.openstreetmap.josm.plugins.validator.util.AgregatePrimitivesVisitor; … … 56 58 return; 57 59 58 plugin.errors = new ArrayList<TestError>();59 60 60 Collection<Test> tests = OSMValidatorPlugin.getTests(true); 61 61 if( tests.isEmpty() ) … … 86 86 } 87 87 88 List<TestError> errors = new ArrayList<TestError>(); 88 89 for(Test test : tests) 89 90 { … … 92 93 test.visit(selection); 93 94 test.endTest(); 94 plugin.errors.addAll( test.getErrors() );95 errors.addAll( test.getErrors() ); 95 96 } 96 97 tests = null; 97 98 98 plugin.validationDialog.tree.setErrors( plugin.errors);99 plugin.validationDialog.tree.setErrors(errors); 99 100 plugin.validationDialog.setVisible(true); 100 Main.map.repaint(); 101 Main.ds.fireSelectionChanged(Main.ds.getSelected()); 102 101 DataSet.fireSelectionChanged(Main.ds.getSelected()); 103 102 } 104 103 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
r3439 r4023 17 17 import org.openstreetmap.josm.command.Command; 18 18 import org.openstreetmap.josm.command.SequenceCommand; 19 import org.openstreetmap.josm.data.osm.DataSet; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 21 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 87 88 action.button.setSelected(v); 88 89 super.setVisible(v); 90 Main.map.repaint(); 89 91 } 90 92 … … 145 147 fixCommand = new SequenceCommand("Fix errors", allComands); 146 148 else 147 fixCommand = (Command)allComands.get(0);149 fixCommand = allComands.get(0); 148 150 149 Main.main. editLayer().add( fixCommand );151 Main.main.undoRedo.add( fixCommand ); 150 152 Main.map.repaint(); 151 Main.ds.fireSelectionChanged(Main.ds.getSelected());153 DataSet.fireSelectionChanged(Main.ds.getSelected()); 152 154 153 155 OSMValidatorPlugin.getPlugin().validateAction.doValidate(e, false); … … 199 201 } 200 202 201 /**202 * Refresh the error messages display203 * @param errors The errors to display204 */205 public void refresh(List<TestError> errors)206 {207 tree.setErrors(errors);208 tree.buildTree();209 }210 211 203 /** 212 204 * Checks for fixes in selected element and, if needed, adds to the sel parameter all selected elements
Note:
See TracChangeset
for help on using the changeset viewer.