Changeset 7715 in josm for trunk/src


Ignore:
Timestamp:
2014-11-08T02:10:18+01:00 (10 years ago)
Author:
Don-vip
Message:

see #10701 - display discussion comments in changeset dialog

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

Legend:

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

    r7704 r7715  
    315315        this.tags = new HashMap<>(other.tags);
    316316        this.incomplete = other.incomplete;
     317        this.discussion = other.discussion != null ? new ArrayList<>(other.discussion) : null;
    317318
    318319        // FIXME: merging of content required?
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableCellRenderer.java

    r7712 r7715  
    22package org.openstreetmap.josm.gui.dialogs.changeset;
    33
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    54import static org.openstreetmap.josm.tools.I18n.trc;
    65
    76import java.awt.Component;
    87import java.awt.Font;
    9 import java.text.DateFormat;
    10 import java.util.Date;
    118
    12 import javax.swing.JLabel;
    139import javax.swing.JTable;
    1410import javax.swing.UIManager;
    15 import javax.swing.table.TableCellRenderer;
    1611
    1712import org.openstreetmap.josm.data.osm.Changeset;
    18 import org.openstreetmap.josm.data.osm.User;
    19 import org.openstreetmap.josm.tools.date.DateUtils;
    2013
    2114/**
     
    2316 * @since 2689
    2417 */
    25 public class ChangesetCacheTableCellRenderer extends JLabel implements TableCellRenderer{
    26 
    27     /**
    28      * Constructs a new {@code ChangesetCacheTableCellRenderer}.
    29      */
    30     public ChangesetCacheTableCellRenderer() {
    31         setOpaque(true);
    32     }
    33 
    34     protected void reset() {
    35         setBackground(UIManager.getColor("Table.background"));
    36         setForeground(UIManager.getColor("Table.foreground"));
    37         setFont(UIManager.getFont("Table.font"));
    38         setToolTipText(null);
    39     }
    40 
    41     protected void renderColors(boolean isSelected) {
    42         if (isSelected) {
    43             setBackground(UIManager.getColor("Table.selectionBackground"));
    44             setForeground(UIManager.getColor("Table.selectionForeground"));
    45         } else {
    46             setBackground(UIManager.getColor("Table.background"));
    47             setForeground(UIManager.getColor("Table.foreground"));
    48         }
    49     }
    50 
    51     protected void renderId(Changeset cs) {
    52         setText(Integer.toString(cs.getId()));
    53         setToolTipText(null);
    54     }
     18public class ChangesetCacheTableCellRenderer extends AbstractCellRenderer {
    5519
    5620    protected void renderUploadComment(Changeset cs) {
     
    7539    }
    7640
    77     protected void renderUser(Changeset cs) {
    78         User user = cs.getUser();
    79         if (user == null || user.getName().trim().isEmpty()) {
    80             setFont(UIManager.getFont("Table.font").deriveFont(Font.ITALIC));
    81             setText(tr("anonymous"));
    82         } else {
    83             setFont(UIManager.getFont("Table.font"));
    84             setText(user.getName());
    85             setToolTipText(user.getName());
    86         }
    87     }
    88 
    89     protected void renderDate(Date d) {
    90         if (d == null) {
    91             setText("");
    92         } else {
    93             setText(DateUtils.formatDateTime(d, DateFormat.SHORT, DateFormat.SHORT));
    94         }
    95         setToolTipText(null);
    96     }
    97 
    9841    protected void renderDiscussions(Changeset cs) {
    9942        setText(Integer.toString(cs.getCommentsCount()));
     
    11053        Changeset cs = (Changeset)value;
    11154        switch(column) {
    112         case 0: /* id */ renderId(cs); break;
     55        case 0: /* id */ renderId(cs.getId()); break;
    11356        case 1: /* upload comment */ renderUploadComment(cs); break;
    11457        case 2: /* open/closed */ renderOpen(cs); break;
    115         case 3: /* user */ renderUser(cs); break;
     58        case 3: /* user */ renderUser(cs.getUser()); break;
    11659        case 4: /* created at */ renderDate(cs.getCreatedAt()); break;
    11760        case 5: /* closed at */ renderDate(cs.getClosedAt()); break;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java

    r7712 r7715  
    66import java.awt.Component;
    77
    8 import javax.swing.JLabel;
    98import javax.swing.JTable;
    10 import javax.swing.UIManager;
    11 import javax.swing.table.TableCellRenderer;
    129
    1310import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
     
    1714 * The table cell renderer used in the changeset content table, except for the "name"
    1815 * column in which we use a {@link org.openstreetmap.josm.gui.OsmPrimitivRenderer}.
    19  *
    2016 */
    21 public class ChangesetContentTableCellRenderer extends JLabel implements TableCellRenderer{
    22 
    23     public ChangesetContentTableCellRenderer() {
    24         setOpaque(true);
    25     }
    26 
    27     protected void reset() {
    28         setBackground(UIManager.getColor("Table.background"));
    29         setForeground(UIManager.getColor("Table.foreground"));
    30         setFont(UIManager.getFont("Table.font"));
    31     }
    32 
    33     protected void renderColors(boolean isSelected) {
    34         if (isSelected) {
    35             setBackground(UIManager.getColor("Table.selectionBackground"));
    36             setForeground(UIManager.getColor("Table.selectionForeground"));
    37         } else {
    38             setBackground(UIManager.getColor("Table.background"));
    39             setForeground(UIManager.getColor("Table.foreground"));
    40         }
    41     }
    42 
    43     protected void renderId(HistoryOsmPrimitive primitive) {
    44         setText(Long.toString(primitive.getId()));
    45         setToolTipText(null);
    46     }
     17public class ChangesetContentTableCellRenderer extends AbstractCellRenderer {
    4718
    4819    protected void renderModificationType(ChangesetModificationType type) {
     
    6940        case 1:
    7041            HistoryOsmPrimitive primitive = (HistoryOsmPrimitive)value;
    71             renderId(primitive);
     42            renderId(primitive.getId());
    7243            break;
    7344        default:
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableColumnModel.java

    r3083 r7715  
    4646    }
    4747
     48    /**
     49     * Constructs a new {@code ChangesetContentTableColumnModel}.
     50     */
    4851    public ChangesetContentTableColumnModel() {
    4952        createColumns();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java

    r7005 r7715  
    6363
    6464    /**
    65      * Populates the model with the content of a model. If ds is null, the
    66      * table is cleared.
     65     * Populates the model with the content of a changeset. If ds is null, the table is cleared.
    6766     *
    6867     * @param ds the changeset content.
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java

    r7704 r7715  
    55
    66import java.awt.BorderLayout;
     7import java.awt.Component;
    78import java.awt.FlowLayout;
    89import java.awt.event.ActionEvent;
     
    1415import javax.swing.BorderFactory;
    1516import javax.swing.JPanel;
     17import javax.swing.JScrollPane;
     18import javax.swing.JTable;
    1619import javax.swing.JToolBar;
    1720
     
    3134
    3235    private final UpdateChangesetDiscussionAction actUpdateChangesets = new UpdateChangesetDiscussionAction();
     36
     37    private final ChangesetDiscussionTableModel model = new ChangesetDiscussionTableModel();
     38
     39    private JTable table;
    3340
    3441    private Changeset current = null;
     
    95102        setLayout(new BorderLayout());
    96103        setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
    97         //add(buildDetailViewPanel(), BorderLayout.CENTER);
    98104        add(buildActionButtonPanel(), BorderLayout.WEST);
     105        add(buildDiscussionPanel(), BorderLayout.CENTER);
     106    }
     107
     108    private Component buildDiscussionPanel() {
     109        JPanel pnl = new JPanel(new BorderLayout());
     110        table = new JTable(model, new ChangesetDiscussionTableColumnModel());
     111        //tblContent.addMouseListener(new PopupMenuLauncher(new ChangesetContentTablePopupMenu()));
     112        pnl.add(new JScrollPane(table), BorderLayout.CENTER);
     113        return pnl;
    99114    }
    100115
    101116    protected void clearView() {
    102         // TODO
     117        model.populate(null);
    103118    }
    104119
    105120    protected void updateView(Changeset cs) {
    106         // TODO
     121        model.populate(cs.getDiscussion());
     122        // Update row heights
     123        for (int row = 0; row < table.getRowCount(); row++) {
     124            int rowHeight = table.getRowHeight();
     125
     126            Component comp = table.prepareRenderer(table.getCellRenderer(row, 2), row, 2);
     127            rowHeight = Math.max(rowHeight, comp.getPreferredSize().height);
     128
     129            table.setRowHeight(row, rowHeight);
     130        }
    107131    }
    108132
Note: See TracChangeset for help on using the changeset viewer.