1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.conflict.pair.tags;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Color;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
|
---|
9 |
|
---|
10 | public class TheirTableCellRenderer extends TagMergeTableCellRenderer {
|
---|
11 |
|
---|
12 | public final static Color BGCOLOR_UNDECIDED = new Color(255,197,197);
|
---|
13 | public final static Color BGCOLOR_MINE = Color.white;
|
---|
14 | public final static Color BGCOLOR_THEIR = new Color(217,255,217);
|
---|
15 | public final static Color BGCOLOR_SELECTED = new Color(143,170,255);
|
---|
16 |
|
---|
17 |
|
---|
18 | protected void setBackgroundColor(TagMergeItem item, boolean isSelected) {
|
---|
19 | if (isSelected) {
|
---|
20 | setBackground(BGCOLOR_SELECTED);
|
---|
21 | return;
|
---|
22 | }
|
---|
23 | if (MergeDecisionType.KEEP_MINE.equals(item.getMergeDecision())) {
|
---|
24 | setBackground(BGCOLOR_MINE);
|
---|
25 | } else if (MergeDecisionType.KEEP_THEIR.equals(item.getMergeDecision())) {
|
---|
26 | setBackground(BGCOLOR_THEIR);
|
---|
27 | } else if (MergeDecisionType.UNDECIDED.equals(item.getMergeDecision())) {
|
---|
28 | setBackground(BGCOLOR_UNDECIDED);
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | protected void setTextColor(TagMergeItem item) {
|
---|
33 | if (MergeDecisionType.KEEP_THEIR.equals(item.getMergeDecision())) {
|
---|
34 | setForeground(Color.black);
|
---|
35 | } else if (MergeDecisionType.KEEP_MINE.equals(item.getMergeDecision())) {
|
---|
36 | setForeground(Color.LIGHT_GRAY);
|
---|
37 | } else if (MergeDecisionType.UNDECIDED.equals(item.getMergeDecision())) {
|
---|
38 | setForeground(Color.black);
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | protected void renderKey(TagMergeItem item, boolean isSelected) {
|
---|
44 | setBackgroundColor(item, isSelected);
|
---|
45 | setTextColor(item);
|
---|
46 | if (item.getTheirTagValue() == null) {
|
---|
47 | setText(tr("<undefined>"));
|
---|
48 | setToolTipText(tr("Their dataset does not include a tag with key {0}", item.getKey()));
|
---|
49 | } else {
|
---|
50 | setText(item.getKey());
|
---|
51 | setToolTipText(item.getKey());
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | protected void renderValue(TagMergeItem item, boolean isSelected) {
|
---|
57 | setBackgroundColor(item,isSelected);
|
---|
58 | setTextColor(item);
|
---|
59 | if (item.getTheirTagValue() == null) {
|
---|
60 | setText(tr("<undefined>"));
|
---|
61 | setToolTipText(tr("Their dataset does not include a tag with key {0}", item.getKey()));
|
---|
62 | } else {
|
---|
63 | setText(item.getTheirTagValue());
|
---|
64 | setToolTipText(item.getTheirTagValue());
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|