Changeset 10529 in osm for applications/editors/josm/plugins/validator/src
- Timestamp:
- 2008-09-07T11:55:00+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ErrorLayer.java
r6389 r10529 36 36 super(tr("Validation errors")); 37 37 this.plugin = plugin; 38 38 Layer.listeners.add(this); 39 39 } 40 40 … … 46 46 } 47 47 48 /** 49 * Draw all primitives in this layer but do not draw modified ones (they 50 * are drawn by the edit layer). 51 * Draw nodes last to overlap the ways they belong to. 52 */ 53 @SuppressWarnings("unchecked") 54 @Override 55 public void paint(final Graphics g, final MapView mv) 56 { 57 DefaultMutableTreeNode root = plugin.validationDialog.tree.getRoot(); 58 if( root == null || root.getChildCount() == 0) 59 return; 60 61 DefaultMutableTreeNode severity = (DefaultMutableTreeNode)root.getLastChild(); 62 while( severity != null ) 63 { 64 Enumeration<DefaultMutableTreeNode> errorMessages = severity.children(); 65 while( errorMessages.hasMoreElements() ) 66 { 67 DefaultMutableTreeNode errorMessage = errorMessages.nextElement(); 68 Enumeration<DefaultMutableTreeNode> errors = errorMessage.children(); 69 while( errors.hasMoreElements() ) 70 { 71 TestError error = (TestError)errors.nextElement().getUserObject(); 72 error.paint(g, mv); 73 } 74 } 75 76 // Severities in inverse order 77 severity= severity.getPreviousSibling(); 78 } 48 /** 49 * Draw all primitives in this layer but do not draw modified ones (they 50 * are drawn by the edit layer). 51 * Draw nodes last to overlap the ways they belong to. 52 */ 53 @SuppressWarnings("unchecked") 54 @Override 55 public void paint(final Graphics g, final MapView mv) 56 { 57 DefaultMutableTreeNode root = plugin.validationDialog.tree.getRoot(); 58 if( root == null || root.getChildCount() == 0) 59 return; 60 61 DefaultMutableTreeNode severity = (DefaultMutableTreeNode)root.getLastChild(); 62 while( severity != null ) 63 { 64 Enumeration<DefaultMutableTreeNode> errorMessages = severity.breadthFirstEnumeration(); 65 while(errorMessages.hasMoreElements()) 66 { 67 Object tn = errorMessages.nextElement().getUserObject(); 68 if(tn instanceof TestError) 69 ((TestError)tn).paint(g, mv); 70 } 71 72 // Severities in inverse order 73 severity = severity.getPreviousSibling(); 74 } 79 75 } 80 76 81 77 @Override 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 78 public String getToolTipText() 79 { 80 Bag<Severity, TestError> errorTree = new Bag<Severity, TestError>(); 81 List<TestError> errors = plugin.validationDialog.tree.getErrors(); 82 for(TestError e : errors) 83 { 84 errorTree.add(e.getSeverity(), e); 85 } 86 87 StringBuilder b = new StringBuilder(); 88 for(Severity s : Severity.values()) 89 { 90 if( errorTree.containsKey(s) ) 91 b.append(tr(s.toString())).append(": ").append(errorTree.get(s).size()).append("<br>"); 92 } 93 94 if( b.length() == 0 ) 95 return "<html>"+tr("No validation errors") + "</html>"; 96 else 97 return "<html>" + tr("Validation errors") + ":<br>" + b + "</html>"; 102 98 } 103 99 … … 111 107 112 108 @Override public Object getInfoComponent() 113 114 109 { 110 return getToolTipText(); 115 111 } 116 112 117 113 @Override public Component[] getMenuEntries() 118 119 120 121 122 123 124 125 126 114 { 115 return new Component[]{ 116 new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 117 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), 118 new JSeparator(), 119 new JMenuItem(new RenameLayerAction(null, this)), 120 new JSeparator(), 121 new JMenuItem(new LayerListPopup.InfoAction(this))}; 122 } 127 123 128 124 @Override public void destroy() { } 129 125 130 126 public void activeLayerChange(Layer oldLayer, Layer newLayer) { } 131 127 132 128 public void layerAdded(Layer newLayer) { } 133 129 134 135 136 137 138 139 140 141 142 143 130 /** 131 * If layer is the OSM Data layer, remove all errors 132 */ 133 public void layerRemoved(Layer oldLayer) 134 { 135 if(oldLayer == Main.map.mapView.editLayer ) 136 { 137 Main.map.mapView.removeLayer(this); 138 } 139 } 144 140 }
Note:
See TracChangeset
for help on using the changeset viewer.