Ignore:
Timestamp:
2016-01-18T19:35:32+01:00 (3 years ago)
Author:
simon04
Message:

fix #10789 - History dialog: indicate the number of changeset comments

Clicking on the button opens the changeset manager and displays the comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r9468 r9526  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trn;
    56
    67import java.awt.BorderLayout;
     
    3132import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    3233import org.openstreetmap.josm.gui.dialogs.ChangesetDialog;
     34import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager;
     35import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetDiscussionPanel;
    3336import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3437import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
     
    5154    private UrlLabel lblUser;
    5255    private UrlLabel lblChangeset;
    53     private final OpenChangesetDialogAction changesetDialogAction = new OpenChangesetDialogAction();
     56    private final JButton lblChangesetComments = new JButton(ImageProvider.get("dialogs/notes/note_comment"));
     57    private final OpenChangesetDialogAction changesetCommentsDialogAction = new OpenChangesetDialogAction(ChangesetDiscussionPanel.class);
     58    private final OpenChangesetDialogAction changesetDialogAction = new OpenChangesetDialogAction(null);
    5459    private final JButton changesetButton = new JButton(changesetDialogAction);
    5560    private JPanel pnlChangesetSource;
     
    100105        pnlUserAndChangeset.add(changesetButton);
    101106        lblChangeset = new UrlLabel("", 2);
    102         pnlUserAndChangeset.add(lblChangeset);
     107        final JPanel pnlChangesetInfo = new JPanel(new BorderLayout());
     108        pnlChangesetInfo.add(lblChangeset, BorderLayout.CENTER);
     109        lblChangesetComments.setAction(changesetCommentsDialogAction);
     110        lblChangesetComments.setMargin(new Insets(0, 0, 0, 0));
     111        lblChangesetComments.setIcon(new ImageProvider("dialogs/notes/note_comment").setMaxSize(12).get());
     112        pnlChangesetInfo.add(lblChangesetComments, BorderLayout.EAST);
     113        pnlUserAndChangeset.add(pnlChangesetInfo);
    103114
    104115        texChangesetComment = buildTextArea(tr("Changeset comment"));
     
    193204    }
    194205
     206    /**
     207     * Updates the content of this panel based on the changeset information given by {@code primitive}.
     208     * @param primitive the primitive to extract the changeset information from
     209     * @param isLatest whether this relates to a not yet commited changeset
     210     */
    195211    public void update(final OsmPrimitive primitive, final boolean isLatest) {
    196212        update(Changeset.fromPrimitive(primitive), isLatest, primitive.getTimestamp(), primitive.getVersion());
    197213    }
    198214
     215    /**
     216     * Updates the content of this panel based on the changeset information given by {@code cs}.
     217     * @param cs the changeset information
     218     * @param isLatest whether this relates to a not yet commited changeset
     219     * @param timestamp the timestamp
     220     * @param version the version of the primitive
     221     */
    199222    public void update(final Changeset cs, final boolean isLatest, final Date timestamp, final long version) {
    200223        lblInfo.setText(getInfoText(timestamp, version, isLatest));
     
    205228            lblChangeset.setUrl(url);
    206229            lblChangeset.setDescription(Long.toString(cs.getId()));
     230            changesetCommentsDialogAction.setId(cs.getId());
     231            lblChangesetComments.setVisible(cs.getCommentsCount() > 0);
     232            lblChangesetComments.setText(String.valueOf(cs.getCommentsCount()));
     233            lblChangesetComments.setToolTipText(trn("This changeset has {0} comment", "This changeset has {0} comments",
     234                    cs.getCommentsCount(), cs.getCommentsCount()));
    207235            changesetDialogAction.setId(cs.getId());
    208236            changesetButton.setEnabled(true);
     
    229257            lblChangeset.setDescription(tr("none"));
    230258            lblChangeset.setUrl(null);
     259            lblChangesetComments.setVisible(false);
    231260            changesetDialogAction.setId(null);
    232261            changesetButton.setEnabled(false);
     
    251280
    252281    static class OpenChangesetDialogAction extends AbstractAction {
     282        private final Class<? extends JComponent> componentToSelect;
    253283        private Integer id;
    254284
    255         OpenChangesetDialogAction() {
     285        OpenChangesetDialogAction(Class<? extends JComponent> componentToSelect) {
    256286            super(tr("Changeset"), new ImageProvider("dialogs/changeset", "changesetmanager").resetMaxSize(new Dimension(16, 16)).get());
    257287            putValue(SHORT_DESCRIPTION, tr("Opens the Changeset Manager window for the selected changesets"));
    258         }
    259 
    260         public void setId(Integer id) {
     288            this.componentToSelect = componentToSelect;
     289        }
     290
     291        void setId(Integer id) {
    261292            this.id = id;
    262293        }
     
    265296        public void actionPerformed(ActionEvent e) {
    266297            ChangesetDialog.LaunchChangesetManager.displayChangesets(Collections.singleton(id));
     298            if (componentToSelect != null) {
     299                ChangesetCacheManager.getInstance().setSelectedComponentInDetailPanel(componentToSelect);
     300            }
    267301        }
    268302    }
Note: See TracChangeset for help on using the changeset viewer.