Changeset 16458 in josm


Ignore:
Timestamp:
2020-05-17T23:02:27+02:00 (3 weeks ago)
Author:
simon04
Message:

fix #19253 - History browser: highlight selected relation member row

Location:
trunk/src/org/openstreetmap/josm/gui/history
Files:
4 edited

Legend:

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

    r12615 r16458  
    3737    }
    3838
    39     protected void renderNode(TwoColumnDiff.Item item, boolean isSelected) {
     39    protected void renderNode(TwoColumnDiff.Item item, boolean isSelected, boolean hasFocus) {
    4040        String text = "";
    4141        setIcon(nodeIcon);
     
    4343            text = tr("Node {0}", item.value.toString());
    4444        }
    45         Color bgColor = item.state.getColor();
    4645        if (item.state == DiffItemType.EMPTY) {
    4746            text = "";
    4847            setIcon(null);
    4948        }
    50         if (isSelected) {
    51             bgColor = BGCOLOR_SELECTED;
    52         }
    5349        setText(text);
    54         GuiHelper.setBackgroundReadable(this, bgColor);
     50        GuiHelper.setBackgroundReadable(this, item.state.getColor(isSelected, hasFocus));
    5551    }
    5652
     
    6157
    6258        if (value != null) {
    63             renderNode((TwoColumnDiff.Item) value, isSelected);
     59            renderNode((TwoColumnDiff.Item) value, isSelected, hasFocus);
    6460        }
    6561        return this;
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java

    r14864 r16458  
    4141        setText(text);
    4242        setToolTipText(text);
    43         GuiHelper.setBackgroundReadable(this, diffItem.state.getColor());
    4443    }
    4544
     
    5756        setText(text);
    5857        setToolTipText(text);
    59         GuiHelper.setBackgroundReadable(this, diffItem.state.getColor());
    6058    }
    6159
     
    7876        }
    7977
     78        GuiHelper.setBackgroundReadable(this, member.state.getColor(isSelected, hasFocus));
    8079        return this;
    8180    }
  • trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java

    r11647 r16458  
    77import javax.swing.JLabel;
    88import javax.swing.JTable;
    9 import javax.swing.UIManager;
    109import javax.swing.table.TableCellRenderer;
    1110
     
    3433
    3534    protected void setBackgroundReadable(String key, TagTableModel model, boolean isSelected, boolean hasFocus, boolean isValue) {
    36         Color bgColor = UIManager.getColor("Table.background");
     35        final TwoColumnDiff.Item.DiffItemType diffItemType;
    3736        if ((!model.hasTag(key) && model.isCurrentPointInTime())
    3837                || (!model.oppositeHasTag(key) && model.isReferencePointInTime())) {
    39             bgColor = TwoColumnDiff.Item.DiffItemType.DELETED.getColor();
     38            diffItemType = TwoColumnDiff.Item.DiffItemType.DELETED;
    4039        } else if ((!model.oppositeHasTag(key) && model.isCurrentPointInTime())
    4140                || (!model.hasTag(key) && model.isReferencePointInTime())) {
    42             bgColor = TwoColumnDiff.Item.DiffItemType.INSERTED.getColor();
     41            diffItemType = TwoColumnDiff.Item.DiffItemType.INSERTED;
    4342        } else if (isValue && model.hasTag(key) && model.oppositeHasTag(key) && !model.hasSameValueAsOpposite(key)) {
    44             bgColor = TwoColumnDiff.Item.DiffItemType.CHANGED.getColor();
     43            diffItemType = TwoColumnDiff.Item.DiffItemType.CHANGED;
     44        } else {
     45            diffItemType = TwoColumnDiff.Item.DiffItemType.EMPTY;
    4546        }
    46         if (isSelected) {
    47             if (hasFocus) {
    48                 bgColor = BGCOLOR_SELECTED_FOCUS;
    49             } else {
    50                 bgColor = BGCOLOR_SELECTED;
    51             }
    52         }
    53 
    54         GuiHelper.setBackgroundReadable(this, bgColor);
     47        GuiHelper.setBackgroundReadable(this, diffItemType.getColor(isSelected, hasFocus));
    5548    }
    5649
  • trunk/src/org/openstreetmap/josm/gui/history/TwoColumnDiff.java

    r11747 r16458  
    4646            public Color getColor() {
    4747                return color;
     48            }
     49
     50            public Color getColor(boolean isSelected, boolean hasFocus) {
     51                if (isSelected && hasFocus) {
     52                    return TagTableCellRenderer.BGCOLOR_SELECTED_FOCUS;
     53                } else if (isSelected) {
     54                    return TagTableCellRenderer.BGCOLOR_SELECTED;
     55                } else {
     56                    return getColor();
     57                }
    4858            }
    4959        }
Note: See TracChangeset for help on using the changeset viewer.