Changeset 7700 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-11-03T13:30:12+01:00 (9 years ago)
Author:
Don-vip
Message:

see #10701 - show changeset comments count in changeset dialog

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r7005 r7700  
    3535    /** the max. coordinates of the bounding box of this changeset */
    3636    private LatLon max;
     37    /** the number of comments for this changeset */
     38    private int commentsCount;
    3739    /** the map of tags */
    3840    private Map<String,String> tags;
     
    161163    }
    162164
     165    /**
     166     * Replies the number of comments for this changeset.
     167     * @return the number of comments for this changeset
     168     * @since 7700
     169     */
     170    public final int getCommentsCount() {
     171        return commentsCount;
     172    }
     173
     174    /**
     175     * Sets the number of comments for this changeset.
     176     * @param commentsCount the number of comments for this changeset
     177     * @since 7700
     178     */
     179    public final void setCommentsCount(int commentsCount) {
     180        this.commentsCount = commentsCount;
     181    }
     182
    163183    @Override
    164184    public Map<String, String> getKeys() {
     
    236256        } else if (!user.equals(other.user))
    237257            return false;
     258        if (commentsCount != other.commentsCount) {
     259            return false;
     260        }
    238261        return true;
    239262    }
     
    286309        this.min = other.min;
    287310        this.max = other.max;
     311        this.commentsCount = other.commentsCount;
    288312        this.tags = new HashMap<>(other.tags);
    289313        this.incomplete = other.incomplete;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableCellRenderer.java

    r7299 r7700  
    9696    }
    9797
     98    protected void renderDiscussions(Changeset cs) {
     99        setText(Integer.toString(cs.getCommentsCount()));
     100        setToolTipText("");
     101    }
     102
    98103    @Override
    99104    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
     
    111116        case 4: /* created at */ renderDate(cs.getCreatedAt()); break;
    112117        case 5: /* closed at */ renderDate(cs.getClosedAt()); break;
     118        case 6: /* discussions */ renderDiscussions(cs); break;
    113119        }
    114120        return this;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableColumnModel.java

    r7509 r7700  
    3636
    3737        // column 2 - Open
    38         createColumn(2, tr("Open"), 50, -1);
     38        createColumn(2, tr("Open"), 25, -1);
    3939
    4040        // column 3 - User
     
    4646        // column 5 - Closed at
    4747        createColumn(5, tr("Closed at"), 100, -1);
     48
     49        // column 6 - Discussions
     50        createColumn(6, tr("Discussions"), 25, -1);
    4851    }
    4952
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r7299 r7700  
    7676                throwException(tr("Missing mandatory attribute ''{0}''.", "id"));
    7777            }
    78             int id = 0;
    79             try {
    80                 id = Integer.parseInt(value);
    81             } catch(NumberFormatException e) {
    82                 throwException(tr("Illegal value for attribute ''{0}''. Got ''{1}''.", "id", value));
    83             }
    84             if (id <= 0) {
    85                 throwException(tr("Illegal numeric value for attribute ''{0}''. Got ''{1}''.", "id", id));
    86             }
    87             current.setId(id);
     78            current.setId(parseNumericAttribute(value, 1));
    8879
    8980            // -- user
     
    156147                current.setMax(new LatLon(maxLon, maxLat));
    157148            }
     149
     150            // -- comments_count
     151            String commentsCount = atts.getValue("comments_count");
     152            if (commentsCount != null) {
     153                current.setCommentsCount(parseNumericAttribute(commentsCount, 0));
     154            }
     155        }
     156
     157        private int parseNumericAttribute(String value, int minAllowed) throws XmlParsingException {
     158            int att = 0;
     159            try {
     160                att = Integer.parseInt(value);
     161            } catch(NumberFormatException e) {
     162                throwException(tr("Illegal value for attribute ''{0}''. Got ''{1}''.", "id", value));
     163            }
     164            if (att < minAllowed) {
     165                throwException(tr("Illegal numeric value for attribute ''{0}''. Got ''{1}''.", "id", att));
     166            }
     167            return att;
    158168        }
    159169
     
    164174                if (atts == null) {
    165175                    throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "version", "osm"));
     176                    return;
    166177                }
    167178                String v = atts.getValue("version");
Note: See TracChangeset for help on using the changeset viewer.