Changeset 6616 in josm for trunk/src


Ignore:
Timestamp:
2014-01-03T22:17:50+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #4073 - colour coding of conflicting tags/memberships in way combining dialog

Location:
trunk/src/org/openstreetmap/josm/gui/conflict
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/ConflictColors.java

    r5926 r6616  
    2525    BGCOLOR_EMPTY_ROW(marktr("Conflict background: empty row"), new Color(234,234,234)),
    2626    BGCOLOR_FROZEN(marktr("Conflict background: frozen"), new Color(234,234,234)),
    27     BGCOLOR_PARTICIPAING_IN_COMPARISON(marktr("Conflict background: in comparison"), Color.black),
    28     FGCOLOR_PARTICIPAING_IN_COMPARISON(marktr("Conflict foreground: in comparison"), Color.white),
     27    BGCOLOR_PARTICIPATING_IN_COMPARISON(marktr("Conflict background: in comparison"), Color.black),
     28    FGCOLOR_PARTICIPATING_IN_COMPARISON(marktr("Conflict foreground: in comparison"), Color.white),
    2929    BGCOLOR(marktr("Conflict background"), Color.white),
    3030    FGCOLOR(marktr("Conflict foreground"), Color.black),
     
    3232    BGCOLOR_NOT_IN_OPPOSITE(marktr("Conflict background: not in opposite"), new Color(255,197,197)),
    3333    BGCOLOR_IN_OPPOSITE(marktr("Conflict background: in opposite"), new Color(255,234,213)),
    34     BGCOLOR_SAME_POSITION_IN_OPPOSITE(marktr("Conflict background: same position in opposite"), new Color(217,255,217));
     34    BGCOLOR_SAME_POSITION_IN_OPPOSITE(marktr("Conflict background: same position in opposite"), new Color(217,255,217)),
     35
     36    BGCOLOR_TAG_KEEP_ONE (marktr("Conflict background: keep one tag"), new Color(217,255,217)),
     37    FGCOLOR_TAG_KEEP_ONE (marktr("Conflict foreground: keep one tag"), Color.black),
     38    BGCOLOR_TAG_KEEP_NONE(marktr("Conflict background: drop tag"), Color.lightGray),
     39    FGCOLOR_TAG_KEEP_NONE(marktr("Conflict foreground: drop tag"), Color.black),
     40    BGCOLOR_TAG_KEEP_ALL (marktr("Conflict background: keep all tags"), new Color(255,234,213)),
     41    FGCOLOR_TAG_KEEP_ALL (marktr("Conflict foreground: keep all tags"), Color.black),
     42
     43    BGCOLOR_MEMBER_KEEP  (marktr("Conflict background: keep member"), new Color(217,255,217)),
     44    FGCOLOR_MEMBER_KEEP  (marktr("Conflict foreground: keep member"), Color.black),
     45    BGCOLOR_MEMBER_REMOVE(marktr("Conflict background: remove member"), Color.lightGray),
     46    FGCOLOR_MEMBER_REMOVE(marktr("Conflict foreground: remove member"), Color.black);
    3547
    3648    private final String name;
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java

    r6316 r6616  
    146146            setBackground(ConflictColors.BGCOLOR_FROZEN.get());
    147147        } else if (model.isParticipatingInCurrentComparePair()) {
    148             setBackground(ConflictColors.BGCOLOR_PARTICIPAING_IN_COMPARISON.get());
    149             setForeground(ConflictColors.FGCOLOR_PARTICIPAING_IN_COMPARISON.get());
     148            setBackground(ConflictColors.BGCOLOR_PARTICIPATING_IN_COMPARISON.get());
     149            setForeground(ConflictColors.FGCOLOR_PARTICIPATING_IN_COMPARISON.get());
    150150        }
    151151        setText(Integer.toString(row+1));
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java

    r6316 r6616  
    8787                bgc = ConflictColors.BGCOLOR_FROZEN.get();
    8888            } else if (model.isParticipatingInCurrentComparePair()) {
    89                 bgc = ConflictColors.BGCOLOR_PARTICIPAING_IN_COMPARISON.get();
     89                bgc = ConflictColors.BGCOLOR_PARTICIPATING_IN_COMPARISON.get();
    9090            } else if (isSelected) {
    9191                bgc = ConflictColors.BGCOLOR_SELECTED.get();
     
    116116        Color fgc = ConflictColors.FGCOLOR.get();
    117117        if (col == 0 && model.isParticipatingInCurrentComparePair() && ! model.getListMergeModel().isFrozen()) {
    118             fgc = ConflictColors.FGCOLOR_PARTICIPAING_IN_COMPARISON.get();
     118            fgc = ConflictColors.FGCOLOR_PARTICIPATING_IN_COMPARISON.get();
    119119        }
    120120        setForeground(fgc);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java

    r6084 r6616  
    2929    private JosmComboBox cbDecisionRenderer;
    3030
     31    /**
     32     * Constructs a new {@code MultiValueCellRenderer}.
     33     */
    3134    public MultiValueCellRenderer() {
    3235        setOpaque(true);
     
    3639    }
    3740
    38     protected void renderColors(MultiValueResolutionDecision decision, boolean selected) {
     41    protected void renderColors(MultiValueResolutionDecision decision, boolean selected, boolean conflict) {
    3942        if (selected) {
    4043            setForeground(UIManager.getColor("Table.selectionForeground"));
    4144            setBackground(UIManager.getColor("Table.selectionBackground"));
    42         } else{
    43             switch(decision.getDecisionType()) {
     45        } else {
     46            switch (decision.getDecisionType()) {
    4447            case UNDECIDED:
    45                 setForeground(UIManager.getColor("Table.foreground"));
     48                setForeground(ConflictColors.FGCOLOR_UNDECIDED.get());
    4649                setBackground(ConflictColors.BGCOLOR_UNDECIDED.get());
    4750                break;
    4851            case KEEP_NONE:
    49                 setForeground(UIManager.getColor("Panel.foreground"));
    50                 setBackground(UIManager.getColor("Panel.background"));
     52                setForeground(ConflictColors.FGCOLOR_TAG_KEEP_NONE.get());
     53                setBackground(ConflictColors.BGCOLOR_TAG_KEEP_NONE.get());
    5154                break;
    5255            default:
    53                 setForeground(UIManager.getColor("Table.foreground"));
    54                 setBackground(UIManager.getColor("Table.background"));
     56                if (conflict) {
     57                    switch (decision.getDecisionType()) {
     58                    case KEEP_ONE:
     59                        setForeground(ConflictColors.FGCOLOR_TAG_KEEP_ONE.get());
     60                        setBackground(ConflictColors.BGCOLOR_TAG_KEEP_ONE.get());
     61                        break;
     62                    case KEEP_ALL:
     63                        setForeground(ConflictColors.FGCOLOR_TAG_KEEP_ALL.get());
     64                        setBackground(ConflictColors.BGCOLOR_TAG_KEEP_ALL.get());
     65                        break;
     66                    }
     67                } else {
     68                    setForeground(UIManager.getColor("Table.foreground"));
     69                    setBackground(UIManager.getColor("Table.background"));
     70                }
    5571                break;
    5672            }
     
    6076    protected void renderValue(MultiValueResolutionDecision decision) {
    6177        model.removeAllElements();
    62         switch(decision.getDecisionType()) {
     78        switch (decision.getDecisionType()) {
    6379        case UNDECIDED:
    6480            model.addElement(tr("Choose a value"));
     
    88104     */
    89105    protected void renderToolTipText(MultiValueResolutionDecision decision) {
    90         switch(decision.getDecisionType()) {
     106        String toolTipText;
     107        switch (decision.getDecisionType()) {
    91108        case UNDECIDED:
    92         {
    93             String toolTipText = tr("Please decide which values to keep");
     109            toolTipText = tr("Please decide which values to keep");
    94110            setToolTipText(toolTipText);
    95111            cbDecisionRenderer.setToolTipText(toolTipText);
    96112            break;
    97         }
    98113        case KEEP_ONE:
    99         {
    100             String toolTipText = tr("Value ''{0}'' is going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey());
     114            toolTipText = tr("Value ''{0}'' is going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey());
    101115            setToolTipText(toolTipText);
    102116            cbDecisionRenderer.setToolTipText(toolTipText);
    103117            break;
    104         }
    105118        case KEEP_NONE:
    106         {
    107             String toolTipText = tr("The key ''{0}'' and all its values are going to be removed", decision.getKey());
     119            toolTipText = tr("The key ''{0}'' and all its values are going to be removed", decision.getKey());
    108120            setToolTipText(toolTipText);
    109121            cbDecisionRenderer.setToolTipText(toolTipText);
    110122            break;
    111         }
    112123        case KEEP_ALL:
    113             String toolTipText = tr("All values joined as ''{0}'' are going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey());
     124            toolTipText = tr("All values joined as ''{0}'' are going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey());
    114125            setToolTipText(toolTipText);
    115126            cbDecisionRenderer.setToolTipText(toolTipText);
     
    125136
    126137    @Override
    127     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
    128             int row, int column) {
     138    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    129139
    130140        reset();
     
    133143
    134144        MultiValueResolutionDecision decision = (MultiValueResolutionDecision)value;
    135         renderColors(decision,isSelected);
     145        TagConflictResolverModel model = (TagConflictResolverModel) table.getModel();
     146        boolean conflict = model.getKeysWithConflicts().contains(model.getKey(row));
     147        renderColors(decision, isSelected, conflict);
    136148        renderToolTipText(decision);
    137149        switch(column) {
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionRenderer.java

    r6084 r6616  
    1414import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    1515
    16 public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer{
     16public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer {
    1717
    1818    private JosmComboBox cbDecisionTypes;
     
    3232    }
    3333
     34    /**
     35     * Constructs a new {@code RelationMemberConflictDecisionRenderer}.
     36     */
    3437    public RelationMemberConflictDecisionRenderer() {
    3538        cbDecisionTypes = new JosmComboBox(RelationMemberConflictDecisionType.values());
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

    r6388 r6616  
    115115    }
    116116
     117    /**
     118     * Constructs a new {@code RelationMemberConflictResolver}.
     119     */
    117120    public RelationMemberConflictResolver() {
    118121        build();
    119122    }
    120123
     124    /**
     125     * Initializes for way combining.
     126     */
    121127    public void initForWayCombining() {
    122         lblHeader.setText(tr("<html>The combined ways are members in one ore more relations. "
     128        lblHeader.setText(tr("<html>The combined ways are members in one or more relations. "
    123129                + "Please decide whether you want to <strong>keep</strong> these memberships "
    124130                + "for the combined way or whether you want to <strong>remove</strong> them.<br>"
     
    130136    }
    131137
     138    /**
     139     * Initializes for node merging.
     140     */
    132141    public void initForNodeMerging() {
    133         lblHeader.setText(tr("<html>The merged nodes are members in one ore more relations. "
     142        lblHeader.setText(tr("<html>The merged nodes are members in one or more relations. "
    134143                + "Please decide whether you want to <strong>keep</strong> these memberships "
    135144                + "for the target node or whether you want to <strong>remove</strong> them.<br>"
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java

    r3210 r6616  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Component;
     7
     8import javax.swing.JTable;
     9import javax.swing.table.DefaultTableCellRenderer;
    610import javax.swing.table.DefaultTableColumnModel;
     11import javax.swing.table.TableCellRenderer;
    712import javax.swing.table.TableColumn;
    813
    914import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
     15import org.openstreetmap.josm.gui.conflict.ConflictColors;
    1016import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    1117
    12 public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel{
     18public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel {
    1319
     20    private static Component setColors(Component comp, JTable table, boolean isSelected, int row) {
     21        RelationMemberConflictResolverModel model = (RelationMemberConflictResolverModel) table.getModel();
     22       
     23        if (!isSelected && comp != null) {
     24            switch (model.getDecision(row).getDecision()) {
     25            case UNDECIDED:
     26                comp.setForeground(ConflictColors.FGCOLOR_UNDECIDED.get());
     27                comp.setBackground(ConflictColors.BGCOLOR_UNDECIDED.get());
     28                break;
     29            case KEEP:
     30                comp.setForeground(ConflictColors.FGCOLOR_MEMBER_KEEP.get());
     31                comp.setBackground(ConflictColors.BGCOLOR_MEMBER_KEEP.get());
     32                break;
     33            case REMOVE:
     34                comp.setForeground(ConflictColors.FGCOLOR_MEMBER_REMOVE.get());
     35                comp.setBackground(ConflictColors.BGCOLOR_MEMBER_REMOVE.get());
     36                break;
     37            }
     38        }
     39        return comp;
     40    }
     41   
    1442    protected void createColumns() {
    15         OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer();
     43        final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
     44       
     45        OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
     46            @Override
     47            public Component getTableCellRendererComponent(JTable table,
     48                    Object value, boolean isSelected, boolean hasFocus, int row, int column) {
     49                return setColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
     50                        table, isSelected, row);
     51            }
     52        };
     53       
     54        TableCellRenderer tableRenderer = new TableCellRenderer() {
     55            @Override
     56            public Component getTableCellRendererComponent(JTable table, Object value,
     57                    boolean isSelected, boolean hasFocus, int row, int column) {
     58                return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
     59                        table, isSelected, row);
     60            }
     61        };
     62       
    1663        AutoCompletingTextField roleEditor = new AutoCompletingTextField();
    1764        RelationMemberConflictDecisionRenderer decisionRenderer = new RelationMemberConflictDecisionRenderer();
     
    3582        col.setWidth(40);
    3683        col.setPreferredWidth(40);
     84        col.setCellRenderer(tableRenderer);
    3785        col.setMaxWidth(50);
    3886        addColumn(col);
     
    4290        col.setHeaderValue(tr("Role"));
    4391        col.setResizable(true);
     92        col.setCellRenderer(tableRenderer);
    4493        col.setCellEditor(roleEditor);
    4594        col.setWidth(50);
     
    55104        col.setPreferredWidth(100);
    56105        addColumn(col);
     106       
    57107        // column 4 - New Way
    58108        col = new TableColumn(4);
     
    67117    }
    68118
     119    /**
     120     * Constructs a new {@code RelationMemberConflictResolverColumnModel}.
     121     */
    69122    public RelationMemberConflictResolverColumnModel() {
    70123        createColumns();
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolver.java

    r6084 r6616  
    9292    }
    9393
     94    /**
     95     * Constructs a new {@code TagConflictResolver}.
     96     */
    9497    public TagConflictResolver() {
    9598        this.model = new TagConflictResolverModel();
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverColumnModel.java

    r3083 r6616  
    4040    }
    4141
     42    /**
     43     * Constructs a new {@code TagConflictResolverColumnModel}.
     44     */
    4245    public TagConflictResolverColumnModel() {
    4346        createColumns();
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java

    r6316 r6616  
    137137        rebuild();
    138138    }
     139   
     140    /**
     141     * Returns the OSM key at the given row.
     142     * @param row The table row
     143     * @return the OSM key at the given row.
     144     * @since 6616
     145     */
     146    public final String getKey(int row) {
     147        return displayedKeys.get(row);
     148    }
    139149
    140150    @Override
     
    146156    @Override
    147157    public Object getValueAt(int row, int column) {
    148         return decisions.get(displayedKeys.get(row));
     158        return getDecision(row);
    149159    }
    150160
     
    156166    @Override
    157167    public void setValueAt(Object value, int row, int column) {
    158         MultiValueResolutionDecision decision = decisions.get(displayedKeys.get(row));
     168        MultiValueResolutionDecision decision = getDecision(row);
    159169        if (value instanceof String) {
    160170            decision.keepOne((String)value);
     
    214224    }
    215225
     226    /**
     227     * Returns the conflict resolution decision at the given row.
     228     * @param row The table row
     229     * @return the conflict resolution decision at the given row.
     230     */
    216231    public MultiValueResolutionDecision getDecision(int row) {
    217         return decisions.get(displayedKeys.get(row));
     232        return decisions.get(getKey(row));
    218233    }
    219234
     
    254269        rebuild();
    255270    }
    256 
     271   
     272    /**
     273     * Returns the set of keys in conflict.
     274     * @return the set of keys in conflict.
     275     * @since 6616
     276     */
     277    public final Set<String> getKeysWithConflicts() {
     278        return new HashSet<String>(keysWithConflicts);
     279    }
    257280}
Note: See TracChangeset for help on using the changeset viewer.