- Timestamp:
- 2019-03-19T18:01:44+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r14899 r14907 184 184 oldExpandedRows.add(userObject); 185 185 } else if (userObject instanceof String) { 186 String msg = (String) userObject; 187 int index = msg.lastIndexOf(" ("); 188 if (index > 0) { 189 msg = msg.substring(0, index); 190 } 186 String msg = removeSize((String) userObject); 191 187 oldExpandedRows.add(msg); 192 188 } … … 215 211 216 212 if (oldExpandedRows.contains(severity)) { 217 expandedPaths.add(new TreePath( new Object[] {rootNode, severityNode}));213 expandedPaths.add(new TreePath(severityNode.getPath())); 218 214 } 219 215 … … 221 217 if (errorsWithEmptyMessageByDescription != null) { 222 218 errorsWithEmptyMessageByDescription.forEach((description, noDescriptionErrors) -> { 223 final String msg = tr("{0} ({1})", description, noDescriptionErrors.size());219 final String msg = addSize(description, noDescriptionErrors); 224 220 final DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg); 225 221 severityNode.add(messageNode); 226 222 227 223 if (oldExpandedRows.contains(description)) { 228 expandedPaths.add(new TreePath( new Object[] {rootNode, severityNode, messageNode}));224 expandedPaths.add(new TreePath(messageNode.getPath())); 229 225 } 230 226 // add the matching errors to the current node … … 243 239 severityNode.add(groupNode); 244 240 if (oldExpandedRows.contains(message)) { 245 expandedPaths.add(new TreePath( new Object[] {rootNode, severityNode, groupNode}));241 expandedPaths.add(new TreePath(groupNode.getPath())); 246 242 } 247 243 } else { … … 250 246 251 247 errorsByDescription.forEach((description, errorsWithDescription) -> { 252 boolean emptyDescription = description == null || description.isEmpty();253 248 // Message node 254 final String msg;249 final String searchMsg; 255 250 if (groupNode != null) { 256 msg = tr("{0} ({1})", description, errorsWithDescription.size());257 } else if ( emptyDescription) {258 msg = tr("{0} ({1})", message, errorsWithDescription.size());251 searchMsg = description; 252 } else if (description == null || description.isEmpty()) { 253 searchMsg = message; 259 254 } else { 260 msg = tr("{0} - {1} ({2})", message, description, errorsWithDescription.size());255 searchMsg = message + " - " + description; 261 256 } 257 final String msg = addSize(searchMsg, errorsWithDescription); 258 262 259 final DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg); 263 if (groupNode != null) { 264 groupNode.add(messageNode); 265 } else { 266 severityNode.add(messageNode); 267 } 268 269 if (oldExpandedRows.contains(description) || (emptyDescription && oldExpandedRows.contains(message))) { 270 if (groupNode != null) { 271 expandedPaths.add(new TreePath(new Object[] {rootNode, severityNode, groupNode, messageNode})); 272 } else { 273 expandedPaths.add(new TreePath(new Object[] {rootNode, severityNode, messageNode})); 274 } 260 DefaultMutableTreeNode currNode = groupNode != null ? groupNode : severityNode; 261 currNode.add(messageNode); 262 if (oldExpandedRows.contains(searchMsg)) { 263 expandedPaths.add(new TreePath(messageNode.getPath())); 275 264 } 276 265 … … 300 289 String msg = null; 301 290 if (searchObject instanceof String) { 302 msg = (String) searchObject; 303 int index = msg.lastIndexOf(" ("); 304 if (index > 0) { 305 msg = msg.substring(0, index); 306 } 291 msg = removeSize((String) searchObject); 307 292 } 308 293 String searchString = msg; … … 338 323 } 339 324 325 private static String addSize(String msg, Collection<?> coll) { 326 return msg + " (" + coll.size() + ")"; 327 } 328 329 private static String removeSize(String msg) { 330 int index = msg.lastIndexOf(" ("); 331 return index > 0 ? msg.substring(0, index) : msg; 332 } 333 340 334 /** 341 335 * Sort list of errors in place (#8517).
Note:
See TracChangeset
for help on using the changeset viewer.