Ignore:
Timestamp:
2011-10-07T21:55:13+02:00 (13 years ago)
Author:
simon04
Message:

see #6774 - Make History dialog more diff-like (patch by olejorgenb)

File:
1 edited

Legend:

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

    r4072 r4498  
    1414import org.openstreetmap.josm.tools.ImageProvider;
    1515
    16 /**
    17  * The {@see TableCellRenderer} for a list of nodes in [@see HistoryBrower}
    18  *
    19  *
    20  */
    2116public class NodeListTableCellRenderer extends JLabel implements TableCellRenderer {
    2217
    2318    public final static Color BGCOLOR_EMPTY_ROW = new Color(234,234,234);
    24     public final static Color BGCOLOR_NOT_IN_OPPOSITE = new Color(255,197,197);
    25     public final static Color BGCOLOR_IN_OPPOSITE = new Color(255,234,213);
     19    public final static Color BGCOLOR_DELETED = new Color(255,197,197);
     20    public final static Color BGCOLOR_INSERTED = new Color(0xDD, 0xFF, 0xDD);
     21    public final static Color BGCOLOR_CHANGED = new Color(255,234,213);
    2622    public final static Color BGCOLOR_SELECTED = new Color(143,170,255);
    2723
     
    3430    }
    3531
    36     protected void renderNode(HistoryBrowserModel.NodeListTableModel model, Long nodeId, int row, boolean isSelected) {
     32    protected void renderNode(TwoColumnDiff.Item item, boolean isSelected) {
    3733        String text = "";
    3834        Color bgColor = Color.WHITE;
    39         if (nodeId == null) {
     35        setIcon(nodeIcon);
     36        if (item.value != null) {
     37            text = tr("Node {0}", item.value.toString());
     38        }
     39        switch(item.state) {
     40        case TwoColumnDiff.Item.EMPTY:
    4041            text = "";
    4142            bgColor = BGCOLOR_EMPTY_ROW;
    4243            setIcon(null);
    43         } else {
    44             text = tr("Node {0}", nodeId.toString());
    45             setIcon(nodeIcon);
    46             if (model.isSameInOppositeWay(row)) {
    47                 bgColor = Color.WHITE;
    48             } else if (model.isInOppositeWay(row)) {
    49                 bgColor = BGCOLOR_IN_OPPOSITE;
    50             } else {
    51                 bgColor = BGCOLOR_NOT_IN_OPPOSITE;
    52             }
     44            break;
     45        case TwoColumnDiff.Item.CHANGED:
     46            bgColor = BGCOLOR_CHANGED;
     47            break;
     48        case TwoColumnDiff.Item.INSERTED:
     49            bgColor = BGCOLOR_INSERTED;
     50            break;
     51        case TwoColumnDiff.Item.DELETED:
     52            bgColor = BGCOLOR_DELETED;
     53            break;
     54        default:
     55            bgColor = BGCOLOR_EMPTY_ROW;
    5356        }
    5457        if (isSelected) {
     
    6467            return this;
    6568
    66         HistoryBrowserModel.NodeListTableModel model = getNodeListTableModel(table);
    67         Long nodeId = (Long)value;
    68         renderNode(model, nodeId, row, isSelected);
     69        renderNode((TwoColumnDiff.Item)value, isSelected);
    6970        return this;
    7071    }
    71 
    72     protected HistoryBrowserModel.NodeListTableModel getNodeListTableModel(JTable table) {
    73         return (HistoryBrowserModel.NodeListTableModel) table.getModel();
    74     }
    7572}
Note: See TracChangeset for help on using the changeset viewer.