- Timestamp:
- 2014-11-08T02:10:18+01:00 (10 years ago)
- 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 315 315 this.tags = new HashMap<>(other.tags); 316 316 this.incomplete = other.incomplete; 317 this.discussion = other.discussion != null ? new ArrayList<>(other.discussion) : null; 317 318 318 319 // FIXME: merging of content required? -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableCellRenderer.java
r7712 r7715 2 2 package org.openstreetmap.josm.gui.dialogs.changeset; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 4 import static org.openstreetmap.josm.tools.I18n.trc; 6 5 7 6 import java.awt.Component; 8 7 import java.awt.Font; 9 import java.text.DateFormat;10 import java.util.Date;11 8 12 import javax.swing.JLabel;13 9 import javax.swing.JTable; 14 10 import javax.swing.UIManager; 15 import javax.swing.table.TableCellRenderer;16 11 17 12 import org.openstreetmap.josm.data.osm.Changeset; 18 import org.openstreetmap.josm.data.osm.User;19 import org.openstreetmap.josm.tools.date.DateUtils;20 13 21 14 /** … … 23 16 * @since 2689 24 17 */ 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 } 18 public class ChangesetCacheTableCellRenderer extends AbstractCellRenderer { 55 19 56 20 protected void renderUploadComment(Changeset cs) { … … 75 39 } 76 40 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 98 41 protected void renderDiscussions(Changeset cs) { 99 42 setText(Integer.toString(cs.getCommentsCount())); … … 110 53 Changeset cs = (Changeset)value; 111 54 switch(column) { 112 case 0: /* id */ renderId(cs ); break;55 case 0: /* id */ renderId(cs.getId()); break; 113 56 case 1: /* upload comment */ renderUploadComment(cs); break; 114 57 case 2: /* open/closed */ renderOpen(cs); break; 115 case 3: /* user */ renderUser(cs ); break;58 case 3: /* user */ renderUser(cs.getUser()); break; 116 59 case 4: /* created at */ renderDate(cs.getCreatedAt()); break; 117 60 case 5: /* closed at */ renderDate(cs.getClosedAt()); break; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java
r7712 r7715 6 6 import java.awt.Component; 7 7 8 import javax.swing.JLabel;9 8 import javax.swing.JTable; 10 import javax.swing.UIManager;11 import javax.swing.table.TableCellRenderer;12 9 13 10 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; … … 17 14 * The table cell renderer used in the changeset content table, except for the "name" 18 15 * column in which we use a {@link org.openstreetmap.josm.gui.OsmPrimitivRenderer}. 19 *20 16 */ 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 } 17 public class ChangesetContentTableCellRenderer extends AbstractCellRenderer { 47 18 48 19 protected void renderModificationType(ChangesetModificationType type) { … … 69 40 case 1: 70 41 HistoryOsmPrimitive primitive = (HistoryOsmPrimitive)value; 71 renderId(primitive );42 renderId(primitive.getId()); 72 43 break; 73 44 default: -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableColumnModel.java
r3083 r7715 46 46 } 47 47 48 /** 49 * Constructs a new {@code ChangesetContentTableColumnModel}. 50 */ 48 51 public ChangesetContentTableColumnModel() { 49 52 createColumns(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
r7005 r7715 63 63 64 64 /** 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. 67 66 * 68 67 * @param ds the changeset content. -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java
r7704 r7715 5 5 6 6 import java.awt.BorderLayout; 7 import java.awt.Component; 7 8 import java.awt.FlowLayout; 8 9 import java.awt.event.ActionEvent; … … 14 15 import javax.swing.BorderFactory; 15 16 import javax.swing.JPanel; 17 import javax.swing.JScrollPane; 18 import javax.swing.JTable; 16 19 import javax.swing.JToolBar; 17 20 … … 31 34 32 35 private final UpdateChangesetDiscussionAction actUpdateChangesets = new UpdateChangesetDiscussionAction(); 36 37 private final ChangesetDiscussionTableModel model = new ChangesetDiscussionTableModel(); 38 39 private JTable table; 33 40 34 41 private Changeset current = null; … … 95 102 setLayout(new BorderLayout()); 96 103 setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); 97 //add(buildDetailViewPanel(), BorderLayout.CENTER);98 104 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; 99 114 } 100 115 101 116 protected void clearView() { 102 // TODO117 model.populate(null); 103 118 } 104 119 105 120 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 } 107 131 } 108 132
Note:
See TracChangeset
for help on using the changeset viewer.