Changeset 9194 in josm for trunk/src/org


Ignore:
Timestamp:
2015-12-28T14:13:30+01:00 (4 years ago)
Author:
simon04
Message:

fix #12191 - Color-code the tag history table

File:
1 edited

Legend:

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

    r8893 r9194  
    1515 */
    1616public class TagTableCellRenderer extends JLabel implements TableCellRenderer {
    17     public static final Color BGCOLOR_DIFFERENCE = new Color(255, 197, 197);
     17    public static final Color BGCOLOR_SELECTED = new Color(143, 170, 255);
    1818
    1919    /**
     
    2424    }
    2525
    26     protected void renderName(String key, HistoryBrowserModel.TagTableModel model, boolean isSelected) {
    27         String text = key;
     26    protected void setBackground(String key, HistoryBrowserModel.TagTableModel model, boolean isSelected) {
    2827        Color bgColor = UIManager.getColor("Table.background");
    29         Color fgColor = UIManager.getColor("Table.foreground");
    30         if (!model.hasTag(key)) {
    31             text = "";
    32             bgColor = BGCOLOR_DIFFERENCE;
    33         } else if (!model.oppositeHasTag(key)) {
    34             bgColor = BGCOLOR_DIFFERENCE;
     28        if (!model.hasTag(key) && model.isCurrentPointInTime()
     29                || !model.oppositeHasTag(key) && model.isReferencePointInTime()) {
     30            bgColor = TwoColumnDiff.Item.DiffItemType.DELETED.getColor();
     31        } else if (!model.oppositeHasTag(key) && model.isCurrentPointInTime()
     32                || !model.hasTag(key) && model.isReferencePointInTime()) {
     33            bgColor = TwoColumnDiff.Item.DiffItemType.INSERTED.getColor();
     34        } else if (model.hasTag(key) && model.oppositeHasTag(key) && !model.hasSameValueAsOpposite(key)) {
     35            bgColor = TwoColumnDiff.Item.DiffItemType.CHANGED.getColor();
    3536        }
    3637        if (isSelected) {
    37             bgColor = UIManager.getColor("Table.backgroundSelected");
    38             fgColor = UIManager.getColor("Table.foregroundSelected");
     38            bgColor = BGCOLOR_SELECTED;
    3939        }
    4040
    41         setText(text);
    42         setToolTipText(text);
    4341        setBackground(bgColor);
    44         setForeground(fgColor);
    45     }
    46 
    47     protected void renderValue(String key, HistoryBrowserModel.TagTableModel model, boolean isSelected) {
    48         String text = "";
    49         Color bgColor = UIManager.getColor("Table.background");
    50         Color fgColor = UIManager.getColor("Table.foreground");
    51         if (!model.hasTag(key)) {
    52             bgColor = BGCOLOR_DIFFERENCE;
    53         } else {
    54             text = model.getValue(key);
    55             if (!model.hasSameValueAsOpposite(key)) {
    56                 bgColor = BGCOLOR_DIFFERENCE;
    57             }
    58         }
    59         if (isSelected) {
    60             bgColor = UIManager.getColor("Table.backgroundSelected");
    61             fgColor = UIManager.getColor("Table.foregroundSelected");
    62         }
    63 
    64         setText(text);
    65         setToolTipText(text);
    66         setBackground(bgColor);
    67         setForeground(fgColor);
    6842    }
    6943
     
    8155        case 0:
    8256            // the name column
    83             renderName(key, model, isSelected);
     57            setText(model.hasTag(key) ? key : "");
     58            setToolTipText(getText());
     59            setBackground(key, model, isSelected);
    8460            break;
    8561        case 1:
    8662            // the value column
    87             renderValue(key, model, isSelected);
     63            setText(model.hasTag(key) ? model.getValue(key) : "");
     64            setToolTipText(getText());
     65            setBackground(key, model, isSelected);
    8866            break;
    8967        }
Note: See TracChangeset for help on using the changeset viewer.