- Timestamp:
- 2020-05-23T22:23:01+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/DiffTableModel.java
r16438 r16490 16 16 class DiffTableModel extends AbstractTableModel { 17 17 private transient List<TwoColumnDiff.Item> rows = new ArrayList<>(); 18 private transient int[] rowNumbers; 18 19 private boolean reversed; 19 20 … … 21 22 this.rows = rows; 22 23 this.reversed = reversed; 24 computeRowNumbers(); 23 25 fireTableDataChanged(); 24 26 } … … 48 50 .findFirst().orElse(-1); 49 51 } 52 53 void computeRowNumbers() { 54 rowNumbers = new int[rows.size()]; 55 int rowNumber = reversed ? rows.size() : 1; 56 int i = 0; 57 for (TwoColumnDiff.Item item : rows) { 58 if (item.state == DiffItemType.EMPTY) { 59 rowNumbers[i] = -1; 60 } else if (reversed) { 61 rowNumbers[i] = rowNumber--; 62 } else { 63 rowNumbers[i] = rowNumber++; 64 } 65 i++; 66 } 67 } 68 69 public int getRowNumber(int rowIndex) { 70 return rowNumbers[rowIndex]; 71 } 50 72 } -
trunk/src/org/openstreetmap/josm/gui/history/NodeListTableCellRenderer.java
r16458 r16490 37 37 } 38 38 39 protected void renderNode(TwoColumnDiff.Item item, boolean isSelected, boolean hasFocus) { 39 protected void renderIndex(DiffTableModel model, int row) { 40 int rowNumber = model.getRowNumber(row); 41 setText(rowNumber > 0 ? Integer.toString(rowNumber) : ""); 42 setToolTipText(null); 43 setHorizontalAlignment(CENTER); 44 setIcon(null); 45 } 46 47 protected void renderNode(TwoColumnDiff.Item item) { 40 48 String text = ""; 41 49 setIcon(nodeIcon); … … 48 56 } 49 57 setText(text); 50 GuiHelper.setBackgroundReadable(this, item.state.getColor(isSelected, hasFocus));58 setHorizontalAlignment(LEFT); 51 59 } 52 60 … … 56 64 int row, int column) { 57 65 58 if (value != null) { 59 renderNode((TwoColumnDiff.Item) value, isSelected, hasFocus); 66 if (value == null) return this; 67 TwoColumnDiff.Item item = (TwoColumnDiff.Item) value; 68 GuiHelper.setBackgroundReadable(this, item.state.getColor(isSelected, hasFocus)); 69 switch(column) { 70 case NodeListTableColumnModel.INDEX_COLUMN: 71 renderIndex((DiffTableModel) table.getModel(), row); 72 break; 73 case NodeListTableColumnModel.NODE_COLUMN: 74 renderNode(item); 75 break; 60 76 } 61 77 return this; -
trunk/src/org/openstreetmap/josm/gui/history/NodeListTableColumnModel.java
r15773 r16490 13 13 public class NodeListTableColumnModel extends DefaultTableColumnModel { 14 14 15 static final int INDEX_COLUMN = 0; 16 static final int NODE_COLUMN = 1; 17 15 18 /** 16 19 * Constructs a new {@code NodeListTableColumnModel}. … … 23 26 NodeListTableCellRenderer renderer = new NodeListTableCellRenderer(); 24 27 25 // column 0 - Nodes 26 TableColumn col = new TableColumn(0); 28 TableColumn col = new TableColumn(INDEX_COLUMN, 0); 29 col.setHeaderValue(tr("\u2116")); 30 col.setCellRenderer(renderer); 31 addColumn(col); 32 33 col = new TableColumn(NODE_COLUMN); 27 34 col.setHeaderValue(tr("Nodes")); 28 35 col.setCellRenderer(renderer); -
trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java
r16458 r16490 36 36 } 37 37 38 protected void renderIndex(DiffTableModel model, int row) { 39 int rowNumber = model.getRowNumber(row); 40 setText(rowNumber > 0 ? Integer.toString(rowNumber) : ""); 41 setToolTipText(null); 42 setHorizontalAlignment(CENTER); 43 renderIcon(null); 44 } 45 38 46 protected void renderRole(Item diffItem) { 39 47 RelationMemberData member = (RelationMemberData) diffItem.value; … … 41 49 setText(text); 42 50 setToolTipText(text); 51 setHorizontalAlignment(LEFT); 52 renderIcon(null); 43 53 } 44 54 … … 56 66 setText(text); 57 67 setToolTipText(text); 68 setHorizontalAlignment(LEFT); 69 renderIcon((RelationMemberData) diffItem.value); 58 70 } 59 71 … … 65 77 if (value == null) return this; 66 78 Item member = (TwoColumnDiff.Item) value; 67 renderIcon((RelationMemberData) member.value);79 Item.DiffItemType type = member.state; 68 80 switch(column) { 69 case 0: 81 case RelationMemberTableColumnModel.INDEX_COLUMN: 82 type = Item.DiffItemType.EMPTY; 83 renderIndex(((DiffTableModel) table.getModel()), row); 84 break; 85 case RelationMemberTableColumnModel.ROLE_COLUMN: 70 86 renderRole(member); 71 87 break; 72 case 1:88 case RelationMemberTableColumnModel.OBJECT_COLUMN: 73 89 renderPrimitive(member); 74 90 break; … … 76 92 } 77 93 78 GuiHelper.setBackgroundReadable(this, member.state.getColor(isSelected, hasFocus));94 GuiHelper.setBackgroundReadable(this, type.getColor(isSelected, hasFocus)); 79 95 return this; 80 96 } -
trunk/src/org/openstreetmap/josm/gui/history/RelationMemberTableColumnModel.java
r15773 r16490 13 13 public class RelationMemberTableColumnModel extends DefaultTableColumnModel { 14 14 15 static final int INDEX_COLUMN = 0; 16 static final int ROLE_COLUMN = 1; 17 static final int OBJECT_COLUMN = 2; 18 15 19 /** 16 20 * Constructs a new {@code RelationMemberTableColumnModel}. … … 23 27 RelationMemberListTableCellRenderer renderer = new RelationMemberListTableCellRenderer(); 24 28 25 // column 0 - Role 26 TableColumn col = new TableColumn(0); 29 TableColumn col = new TableColumn(INDEX_COLUMN, 0); 30 col.setHeaderValue(tr("\u2116")); 31 col.setCellRenderer(renderer); 32 addColumn(col); 33 34 col = new TableColumn(ROLE_COLUMN); 27 35 col.setHeaderValue(tr("Role")); 28 36 col.setCellRenderer(renderer); 29 37 addColumn(col); 30 38 31 // column 1 - Object 32 col = new TableColumn(1); 39 col = new TableColumn(OBJECT_COLUMN); 33 40 col.setHeaderValue(tr("Object")); 34 41 col.setCellRenderer(renderer);
Note:
See TracChangeset
for help on using the changeset viewer.