Changeset 15280 in josm for trunk


Ignore:
Timestamp:
2019-08-04T22:30:23+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17979 - display number of incomplete objects in OSM data layer information

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r15121 r15280  
    294294         */
    295295        public int deletedRelations;
     296        /**
     297         * Incomplete nodes that have been visited
     298         */
     299        public int incompleteNodes;
     300        /**
     301         * Incomplete ways that have been visited
     302         */
     303        public int incompleteWays;
     304        /**
     305         * Incomplete relations that have been visited
     306         */
     307        public int incompleteRelations;
    296308
    297309        @Override
     
    301313                deletedNodes++;
    302314            }
     315            if (n.isIncomplete()) {
     316                incompleteNodes++;
     317            }
    303318        }
    304319
     
    309324                deletedWays++;
    310325            }
     326            if (w.isIncomplete()) {
     327                incompleteWays++;
     328            }
    311329        }
    312330
     
    316334            if (r.isDeleted()) {
    317335                deletedRelations++;
     336            }
     337            if (r.isIncomplete()) {
     338                incompleteRelations++;
    318339            }
    319340        }
     
    650671    }
    651672
     673    private static String counterText(String text, int deleted, int incomplete) {
     674        StringBuilder sb = new StringBuilder(text);
     675        if (deleted > 0 || incomplete > 0) {
     676            sb.append(" (");
     677            if (deleted > 0) {
     678                sb.append(trn("{0} deleted", "{0} deleted", deleted, deleted));
     679            }
     680            if (deleted > 0 && incomplete > 0) {
     681                sb.append(", ");
     682            }
     683            if (incomplete > 0) {
     684                sb.append(trn("{0} incomplete", "{0} incomplete", incomplete, incomplete));
     685            }
     686            sb.append(')');
     687        }
     688        return sb.toString();
     689    }
     690
    652691    @Override
    653692    public Object getInfoComponent() {
     
    658697        final JPanel p = new JPanel(new GridBagLayout());
    659698
    660         String nodeText = trn("{0} node", "{0} nodes", counter.nodes, counter.nodes);
    661         if (counter.deletedNodes > 0) {
    662             nodeText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedNodes, counter.deletedNodes)+')';
    663         }
    664 
    665         String wayText = trn("{0} way", "{0} ways", counter.ways, counter.ways);
    666         if (counter.deletedWays > 0) {
    667             wayText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedWays, counter.deletedWays)+')';
    668         }
    669 
    670         String relationText = trn("{0} relation", "{0} relations", counter.relations, counter.relations);
    671         if (counter.deletedRelations > 0) {
    672             relationText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedRelations, counter.deletedRelations)+')';
    673         }
     699        String nodeText = counterText(trn("{0} node", "{0} nodes", counter.nodes, counter.nodes),
     700                counter.deletedNodes, counter.incompleteNodes);
     701        String wayText = counterText(trn("{0} way", "{0} ways", counter.ways, counter.ways),
     702                counter.deletedWays, counter.incompleteWays);
     703        String relationText = counterText(trn("{0} relation", "{0} relations", counter.relations, counter.relations),
     704                counter.deletedRelations, counter.incompleteRelations);
    674705
    675706        p.add(new JLabel(tr("{0} consists of:", getName())), GBC.eol());
Note: See TracChangeset for help on using the changeset viewer.