Changeset 14860 in josm for trunk/src/org
- Timestamp:
- 2019-03-09T17:27:17+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r14857 r14860 12 12 import java.util.List; 13 13 import java.util.Map; 14 import java.util.Map.Entry; 14 15 import java.util.Set; 15 16 import java.util.function.Consumer; … … 164 165 165 166 // Remember the currently expanded rows 166 Set<Object> old SelectedRows = new HashSet<>();167 Set<Object> oldExpandedRows = new HashSet<>(); 167 168 Enumeration<TreePath> expanded = getExpandedDescendants(new TreePath(getRoot())); 168 169 if (expanded != null) { … … 172 173 Object userObject = node.getUserObject(); 173 174 if (userObject instanceof Severity) { 174 old SelectedRows.add(userObject);175 oldExpandedRows.add(userObject); 175 176 } else if (userObject instanceof String) { 176 177 String msg = (String) userObject; … … 179 180 msg = msg.substring(0, index); 180 181 } 181 old SelectedRows.add(msg);182 oldExpandedRows.add(msg); 182 183 } 183 184 } … … 195 196 196 197 final List<TreePath> expandedPaths = new ArrayList<>(); 197 errorsBySeverityMessageDescription.forEach((severity, errorsByMessageDescription) -> { 198 for (Entry<Severity, Map<String, Map<String, List<TestError>>>> entry: errorsBySeverityMessageDescription.entrySet()) { 199 Severity severity = entry.getKey(); 200 Map<String, Map<String, List<TestError>>> errorsByMessageDescription = entry.getValue(); 201 198 202 // Severity node 199 203 final DefaultMutableTreeNode severityNode = new GroupTreeNode(severity); 200 204 rootNode.add(severityNode); 201 205 202 if (oldSelectedRows.contains(severity)) {203 expandedPaths.add(new TreePath(new Object[] {rootNode, severityNode}));204 }205 206 206 final Map<String, List<TestError>> errorsWithEmptyMessageByDescription = errorsByMessageDescription.get(""); 207 207 if (errorsWithEmptyMessageByDescription != null) { 208 errorsWithEmptyMessageByDescription.forEach((description, errors) -> {209 final String msg = tr("{0} ({1})", description, errors.size());208 errorsWithEmptyMessageByDescription.forEach((description, noDescriptionErrors) -> { 209 final String msg = tr("{0} ({1})", description, noDescriptionErrors.size()); 210 210 final DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg); 211 211 severityNode.add(messageNode); 212 212 213 if (old SelectedRows.contains(description)) {214 expandedPaths.add(new TreePath(new Object[] { rootNode, severityNode, messageNode}));213 if (oldExpandedRows.contains(description)) { 214 expandedPaths.add(new TreePath(new Object[] { rootNode, severityNode, messageNode })); 215 215 } 216 217 errors.stream().map(DefaultMutableTreeNode::new).forEach(messageNode::add);216 // add the matching errors to the current node 217 noDescriptionErrors.stream().map(DefaultMutableTreeNode::new).forEach(messageNode::add); 218 218 }); 219 219 } … … 228 228 groupNode = new GroupTreeNode(message); 229 229 severityNode.add(groupNode); 230 if (old SelectedRows.contains(message)) {230 if (oldExpandedRows.contains(message)) { 231 231 expandedPaths.add(new TreePath(new Object[] {rootNode, severityNode, groupNode})); 232 232 } … … 235 235 } 236 236 237 errorsByDescription.forEach((description, errors ) -> {237 errorsByDescription.forEach((description, errorsWithDescription) -> { 238 238 boolean emptyDescription = description == null || description.isEmpty(); 239 239 // Message node 240 240 final String msg; 241 241 if (groupNode != null) { 242 msg = tr("{0} ({1})", description, errors .size());242 msg = tr("{0} ({1})", description, errorsWithDescription.size()); 243 243 } else if (emptyDescription) { 244 msg = tr("{0} ({1})", message, errors .size());244 msg = tr("{0} ({1})", message, errorsWithDescription.size()); 245 245 } else { 246 msg = tr("{0} - {1} ({2})", message, description, errors .size());246 msg = tr("{0} - {1} ({2})", message, description, errorsWithDescription.size()); 247 247 } 248 248 final DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg); … … 253 253 } 254 254 255 if (old SelectedRows.contains(description) || (emptyDescription && oldSelectedRows.contains(message))) {255 if (oldExpandedRows.contains(description) || (emptyDescription && oldExpandedRows.contains(message))) { 256 256 if (groupNode != null) { 257 257 expandedPaths.add(new TreePath(new Object[] {rootNode, severityNode, groupNode, messageNode})); … … 261 261 } 262 262 263 // add the matching errors to the current node264 errors .stream().map(DefaultMutableTreeNode::new).forEach(messageNode::add);263 // add the matching errors to the current node 264 errorsWithDescription.stream().map(DefaultMutableTreeNode::new).forEach(messageNode::add); 265 265 }); 266 266 }); 267 } );267 } 268 268 269 269 valTreeModel.setRoot(rootNode);
Note:
See TracChangeset
for help on using the changeset viewer.