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 org.openstreetmap.josm.gui.conflict.ConflictColors;
|
---|
7 | import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
|
---|
8 |
|
---|
9 | public class MineTableCellRenderer extends TagMergeTableCellRenderer {
|
---|
10 |
|
---|
11 | protected void setBackgroundColor(TagMergeItem item, boolean isSelected) {
|
---|
12 | if (isSelected) {
|
---|
13 | setBackground(ConflictColors.BGCOLOR_SELECTED.get());
|
---|
14 | return;
|
---|
15 | }
|
---|
16 | if (MergeDecisionType.KEEP_MINE.equals(item.getMergeDecision())) {
|
---|
17 | setBackground(ConflictColors.BGCOLOR_KEEP.get());
|
---|
18 | } else if (MergeDecisionType.KEEP_THEIR.equals(item.getMergeDecision())) {
|
---|
19 | setBackground(ConflictColors.BGCOLOR_DROP.get());
|
---|
20 | } else if (MergeDecisionType.UNDECIDED.equals(item.getMergeDecision())) {
|
---|
21 | setBackground(ConflictColors.BGCOLOR_UNDECIDED.get());
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | protected void setTextColor(TagMergeItem item) {
|
---|
26 | if (MergeDecisionType.KEEP_MINE.equals(item.getMergeDecision())) {
|
---|
27 | setForeground(ConflictColors.FGCOLOR_KEEP.get());
|
---|
28 | } else if (MergeDecisionType.KEEP_THEIR.equals(item.getMergeDecision())) {
|
---|
29 | setForeground(ConflictColors.FGCOLOR_DROP.get());
|
---|
30 | } else if (MergeDecisionType.UNDECIDED.equals(item.getMergeDecision())) {
|
---|
31 | setForeground(ConflictColors.FGCOLOR_UNDECIDED.get());
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | protected void renderKey(TagMergeItem item, boolean isSelected) {
|
---|
37 | setBackgroundColor(item, isSelected);
|
---|
38 | setTextColor(item);
|
---|
39 | if (item.getMyTagValue() == null) {
|
---|
40 | setText(tr("<undefined>"));
|
---|
41 | setToolTipText(tr("My dataset does not include a tag with key {0}", item.getKey()));
|
---|
42 | } else {
|
---|
43 | setText(item.getKey());
|
---|
44 | setToolTipText(item.getKey());
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | protected void renderValue(TagMergeItem item, boolean isSelected) {
|
---|
50 | setBackgroundColor(item,isSelected);
|
---|
51 | setTextColor(item);
|
---|
52 | if (item.getMyTagValue() == null) {
|
---|
53 | setText(tr("<undefined>"));
|
---|
54 | setToolTipText(tr("My dataset does not include a tag with key {0}", item.getKey()));
|
---|
55 | } else {
|
---|
56 | setText(item.getMyTagValue());
|
---|
57 | setToolTipText(item.getMyTagValue());
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|