Changeset 6616 in josm
- Timestamp:
- 2014-01-03T22:17:50+01:00 (11 years ago)
- 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 25 25 BGCOLOR_EMPTY_ROW(marktr("Conflict background: empty row"), new Color(234,234,234)), 26 26 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), 29 29 BGCOLOR(marktr("Conflict background"), Color.white), 30 30 FGCOLOR(marktr("Conflict foreground"), Color.black), … … 32 32 BGCOLOR_NOT_IN_OPPOSITE(marktr("Conflict background: not in opposite"), new Color(255,197,197)), 33 33 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); 35 47 36 48 private final String name; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r6316 r6616 146 146 setBackground(ConflictColors.BGCOLOR_FROZEN.get()); 147 147 } 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()); 150 150 } 151 151 setText(Integer.toString(row+1)); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java
r6316 r6616 87 87 bgc = ConflictColors.BGCOLOR_FROZEN.get(); 88 88 } else if (model.isParticipatingInCurrentComparePair()) { 89 bgc = ConflictColors.BGCOLOR_PARTICIPAING_IN_COMPARISON.get(); 89 bgc = ConflictColors.BGCOLOR_PARTICIPATING_IN_COMPARISON.get(); 90 90 } else if (isSelected) { 91 91 bgc = ConflictColors.BGCOLOR_SELECTED.get(); … … 116 116 Color fgc = ConflictColors.FGCOLOR.get(); 117 117 if (col == 0 && model.isParticipatingInCurrentComparePair() && ! model.getListMergeModel().isFrozen()) { 118 fgc = ConflictColors.FGCOLOR_PARTICIPAING_IN_COMPARISON.get(); 118 fgc = ConflictColors.FGCOLOR_PARTICIPATING_IN_COMPARISON.get(); 119 119 } 120 120 setForeground(fgc); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
r6084 r6616 29 29 private JosmComboBox cbDecisionRenderer; 30 30 31 /** 32 * Constructs a new {@code MultiValueCellRenderer}. 33 */ 31 34 public MultiValueCellRenderer() { 32 35 setOpaque(true); … … 36 39 } 37 40 38 protected void renderColors(MultiValueResolutionDecision decision, boolean selected) { 41 protected void renderColors(MultiValueResolutionDecision decision, boolean selected, boolean conflict) { 39 42 if (selected) { 40 43 setForeground(UIManager.getColor("Table.selectionForeground")); 41 44 setBackground(UIManager.getColor("Table.selectionBackground")); 42 } else{ 43 switch(decision.getDecisionType()) { 45 } else { 46 switch (decision.getDecisionType()) { 44 47 case UNDECIDED: 45 setForeground( UIManager.getColor("Table.foreground"));48 setForeground(ConflictColors.FGCOLOR_UNDECIDED.get()); 46 49 setBackground(ConflictColors.BGCOLOR_UNDECIDED.get()); 47 50 break; 48 51 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()); 51 54 break; 52 55 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 } 55 71 break; 56 72 } … … 60 76 protected void renderValue(MultiValueResolutionDecision decision) { 61 77 model.removeAllElements(); 62 switch(decision.getDecisionType()) { 78 switch (decision.getDecisionType()) { 63 79 case UNDECIDED: 64 80 model.addElement(tr("Choose a value")); … … 88 104 */ 89 105 protected void renderToolTipText(MultiValueResolutionDecision decision) { 90 switch(decision.getDecisionType()) { 106 String toolTipText; 107 switch (decision.getDecisionType()) { 91 108 case UNDECIDED: 92 { 93 String toolTipText = tr("Please decide which values to keep"); 109 toolTipText = tr("Please decide which values to keep"); 94 110 setToolTipText(toolTipText); 95 111 cbDecisionRenderer.setToolTipText(toolTipText); 96 112 break; 97 }98 113 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()); 101 115 setToolTipText(toolTipText); 102 116 cbDecisionRenderer.setToolTipText(toolTipText); 103 117 break; 104 }105 118 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()); 108 120 setToolTipText(toolTipText); 109 121 cbDecisionRenderer.setToolTipText(toolTipText); 110 122 break; 111 }112 123 case KEEP_ALL: 113 StringtoolTipText = 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()); 114 125 setToolTipText(toolTipText); 115 126 cbDecisionRenderer.setToolTipText(toolTipText); … … 125 136 126 137 @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) { 129 139 130 140 reset(); … … 133 143 134 144 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); 136 148 renderToolTipText(decision); 137 149 switch(column) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionRenderer.java
r6084 r6616 14 14 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 15 15 16 public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer{ 16 public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer { 17 17 18 18 private JosmComboBox cbDecisionTypes; … … 32 32 } 33 33 34 /** 35 * Constructs a new {@code RelationMemberConflictDecisionRenderer}. 36 */ 34 37 public RelationMemberConflictDecisionRenderer() { 35 38 cbDecisionTypes = new JosmComboBox(RelationMemberConflictDecisionType.values()); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
r6388 r6616 115 115 } 116 116 117 /** 118 * Constructs a new {@code RelationMemberConflictResolver}. 119 */ 117 120 public RelationMemberConflictResolver() { 118 121 build(); 119 122 } 120 123 124 /** 125 * Initializes for way combining. 126 */ 121 127 public void initForWayCombining() { 122 lblHeader.setText(tr("<html>The combined ways are members in one or emore relations. "128 lblHeader.setText(tr("<html>The combined ways are members in one or more relations. " 123 129 + "Please decide whether you want to <strong>keep</strong> these memberships " 124 130 + "for the combined way or whether you want to <strong>remove</strong> them.<br>" … … 130 136 } 131 137 138 /** 139 * Initializes for node merging. 140 */ 132 141 public void initForNodeMerging() { 133 lblHeader.setText(tr("<html>The merged nodes are members in one or emore relations. "142 lblHeader.setText(tr("<html>The merged nodes are members in one or more relations. " 134 143 + "Please decide whether you want to <strong>keep</strong> these memberships " 135 144 + "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 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Component; 7 8 import javax.swing.JTable; 9 import javax.swing.table.DefaultTableCellRenderer; 6 10 import javax.swing.table.DefaultTableColumnModel; 11 import javax.swing.table.TableCellRenderer; 7 12 import javax.swing.table.TableColumn; 8 13 9 14 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 15 import org.openstreetmap.josm.gui.conflict.ConflictColors; 10 16 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 11 17 12 public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel{ 18 public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel { 13 19 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 14 42 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 16 63 AutoCompletingTextField roleEditor = new AutoCompletingTextField(); 17 64 RelationMemberConflictDecisionRenderer decisionRenderer = new RelationMemberConflictDecisionRenderer(); … … 35 82 col.setWidth(40); 36 83 col.setPreferredWidth(40); 84 col.setCellRenderer(tableRenderer); 37 85 col.setMaxWidth(50); 38 86 addColumn(col); … … 42 90 col.setHeaderValue(tr("Role")); 43 91 col.setResizable(true); 92 col.setCellRenderer(tableRenderer); 44 93 col.setCellEditor(roleEditor); 45 94 col.setWidth(50); … … 55 104 col.setPreferredWidth(100); 56 105 addColumn(col); 106 57 107 // column 4 - New Way 58 108 col = new TableColumn(4); … … 67 117 } 68 118 119 /** 120 * Constructs a new {@code RelationMemberConflictResolverColumnModel}. 121 */ 69 122 public RelationMemberConflictResolverColumnModel() { 70 123 createColumns(); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolver.java
r6084 r6616 92 92 } 93 93 94 /** 95 * Constructs a new {@code TagConflictResolver}. 96 */ 94 97 public TagConflictResolver() { 95 98 this.model = new TagConflictResolverModel(); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverColumnModel.java
r3083 r6616 40 40 } 41 41 42 /** 43 * Constructs a new {@code TagConflictResolverColumnModel}. 44 */ 42 45 public TagConflictResolverColumnModel() { 43 46 createColumns(); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java
r6316 r6616 137 137 rebuild(); 138 138 } 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 } 139 149 140 150 @Override … … 146 156 @Override 147 157 public Object getValueAt(int row, int column) { 148 return decisions.get(displayedKeys.get(row));158 return getDecision(row); 149 159 } 150 160 … … 156 166 @Override 157 167 public void setValueAt(Object value, int row, int column) { 158 MultiValueResolutionDecision decision = decisions.get(displayedKeys.get(row));168 MultiValueResolutionDecision decision = getDecision(row); 159 169 if (value instanceof String) { 160 170 decision.keepOne((String)value); … … 214 224 } 215 225 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 */ 216 231 public MultiValueResolutionDecision getDecision(int row) { 217 return decisions.get( displayedKeys.get(row));232 return decisions.get(getKey(row)); 218 233 } 219 234 … … 254 269 rebuild(); 255 270 } 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 } 257 280 }
Note:
See TracChangeset
for help on using the changeset viewer.