Changeset 2099 in josm
- Timestamp:
- 2009-09-12T16:39:20+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2095 r2099 104 104 } 105 105 106 protected void completeTagCollectionWithMissingTags(TagCollection tc, Collection<Way> combinedWays) { 106 protected static void completeTagCollectionWithMissingTags(TagCollection tc, Collection<? extends OsmPrimitive> merged) { 107 for (String key: tc.getKeys()) { 108 // make sure the empty value is in the tag set if a tag is not present 109 // on all merged nodes 110 // 111 for (OsmPrimitive p: merged) { 112 if (p.get(key) == null) { 113 tc.add(new Tag(key)); // add a tag with key and empty value 114 } 115 } 116 } 117 // remove irrelevant tags 118 // 119 tc.removeByKey("created_by"); 120 } 121 122 protected static void completeTagCollectionForEditing(TagCollection tc) { 107 123 for (String key: tc.getKeys()) { 108 124 // make sure the empty value is in the tag set such that we can delete the tag … … 110 126 // 111 127 tc.add(new Tag(key,"")); 112 for (Way w: combinedWays) { 113 if (w.get(key) == null) { 114 tc.add(new Tag(key)); // add a tag with key and empty value 115 } 116 } 117 } 118 // remove irrelevant tags 119 // 120 tc.removeByKey("created_by"); 128 } 121 129 } 122 130 … … 165 173 TagCollection completeWayTags = new TagCollection(wayTags); 166 174 completeTagCollectionWithMissingTags(completeWayTags, ways); 175 TagCollection tagsToEdit = new TagCollection(completeWayTags); 176 completeTagCollectionForEditing(tagsToEdit); 167 177 168 178 CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance(); 169 dialog.getTagConflictResolverModel().populate( completeWayTags);179 dialog.getTagConflictResolverModel().populate(tagsToEdit); 170 180 dialog.setTargetPrimitive(targetWay); 171 181 dialog.getRelationMemberConflictResolverModel().populate( … … 177 187 // resolve tag conflicts if necessary 178 188 // 179 if (! wayTags.isApplicableToPrimitive() || !referringRelations.getRelations().isEmpty()) {189 if (!completeWayTags.isApplicableToPrimitive() || !referringRelations.getRelations().isEmpty()) { 180 190 dialog.setVisible(true); 181 191 if (dialog.isCancelled()) 182 192 return; 183 193 } 184 185 186 194 187 195 LinkedList<Command> cmds = new LinkedList<Command>(); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r2095 r2099 36 36 37 37 /** 38 * This dialog helps to resolve conflicts occuring when combining or merging primitives. 38 * This dialog helps to resolve conflicts occurring when ways are combined ore 39 * primitives are merged. 39 40 * 40 41 * There is a singleton instance of this dialog which can be retrieved using 41 42 * {@see #getInstance()}. 42 43 * 43 * The dialog uses two model : one model for resolving tag conflicts, the other model44 * for resolving conflicts in relation membership . For both models there are accessors,44 * The dialog uses two models: one for resolving tag conflicts, the other 45 * for resolving conflicts in relation memberships. For both models there are accessors, 45 46 * i.e {@see #getTagConflictResolverModel()} and {@see #getRelationMemberConflictResolverModel()}. 46 47 * … … 54 55 * 55 56 * You should also set the target primitive which other primitives (ways or nodes) are 56 * merged to . Use {@see #setTargetPrimitive(OsmPrimitive)}.57 * merged to, see {@see #setTargetPrimitive(OsmPrimitive)}. 57 58 * 58 59 * After the dialog closed use {@see #isCancelled()} to check whether the user cancelled 59 * the dialog. If it wasn't cancel led you may build a collection of {@see Command} objects60 * the dialog. If it wasn't canceled you may build a collection of {@see Command} objects 60 61 * which reflect the conflict resolution decisions the user made in the dialog: 61 62 * see {@see #buildResolutionCommands()} … … 259 260 spTagConflictTypes.setDividerLocation(0.5); 260 261 } 262 pnlRelationMemberConflictResolver.prepareForEditing(); 261 263 } 262 264 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
r2008 r2099 7 7 import java.awt.Font; 8 8 9 import javax.swing.DefaultComboBoxModel; 9 10 import javax.swing.ImageIcon; 11 import javax.swing.JComboBox; 10 12 import javax.swing.JLabel; 11 13 import javax.swing.JTable; … … 15 17 import org.openstreetmap.josm.tools.ImageProvider; 16 18 19 /** 20 * This is a {@see TableCellRenderer} for {@see MultiValueResolutionDecision}s. 21 * 22 23 */ 17 24 public class MultiValueCellRenderer extends JLabel implements TableCellRenderer { 18 25 19 26 private ImageIcon iconDecided; 20 27 private ImageIcon iconUndecided; 28 private DefaultComboBoxModel model; 29 private JComboBox cbDecisionRenderer; 21 30 22 31 public MultiValueCellRenderer() { … … 24 33 iconDecided = ImageProvider.get("dialogs/conflict", "tagconflictresolved"); 25 34 iconUndecided = ImageProvider.get("dialogs/conflict", "tagconflictunresolved"); 35 cbDecisionRenderer = new JComboBox(model = new DefaultComboBoxModel()); 26 36 } 27 37 … … 37 47 38 48 protected void renderValue(MultiValueResolutionDecision decision) { 49 model.removeAllElements(); 39 50 switch(decision.getDecisionType()) { 40 case UNDECIDED: 41 setText(tr("Choose a value")); 42 setFont(getFont().deriveFont(Font.ITALIC)); 43 setToolTipText(tr("Please decided which values to keep")); 44 break; 45 case KEEP_ONE: 46 setText(decision.getChosenValue()); 47 setToolTipText(tr("Value ''{0}'' is going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey())); 48 break; 49 case KEEP_NONE: 50 setText(tr("deleted")); 51 setFont(getFont().deriveFont(Font.ITALIC)); 52 setToolTipText(tr("The key ''{0}'' and all it's values are going to be removed", decision.getKey())); 53 break; 54 case KEEP_ALL: 55 setText(decision.getChosenValue()); 56 setToolTipText(tr("All values joined as ''{0}'' are going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey())); 57 break; 51 case UNDECIDED: 52 model.addElement(tr("Choose a value")); 53 setFont(getFont().deriveFont(Font.ITALIC)); 54 setToolTipText(tr("Please decided which values to keep")); 55 cbDecisionRenderer.setSelectedIndex(0); 56 break; 57 case KEEP_ONE: 58 model.addElement(decision.getChosenValue()); 59 setToolTipText(tr("Value ''{0}'' is going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey())); 60 cbDecisionRenderer.setSelectedIndex(0); 61 break; 62 case KEEP_NONE: 63 model.addElement(tr("deleted")); 64 setFont(getFont().deriveFont(Font.ITALIC)); 65 setToolTipText(tr("The key ''{0}'' and all it's values are going to be removed", decision.getKey())); 66 cbDecisionRenderer.setSelectedIndex(0); 67 break; 68 case KEEP_ALL: 69 model.addElement(decision.getChosenValue()); 70 setToolTipText(tr("All values joined as ''{0}'' are going to be applied for key ''{1}''", decision.getChosenValue(), decision.getKey())); 71 cbDecisionRenderer.setSelectedIndex(0); 72 break; 58 73 } 59 74 } 60 75 61 76 protected void reset() { 77 setFont(UIManager.getFont("Table.font")); 62 78 setIcon(null); 63 79 setText(""); 64 setFont(UIManager.getFont("Table.font"));65 80 } 66 81 … … 72 87 MultiValueResolutionDecision decision = (MultiValueResolutionDecision)value; 73 88 switch(column) { 74 75 76 77 78 79 80 break;89 case 0: 90 if (decision.isDecided()) { 91 setIcon(iconDecided); 92 } else { 93 setIcon(iconUndecided); 94 } 95 return this; 81 96 82 83 84 break;97 case 1: 98 setText(decision.getKey()); 99 return this; 85 100 86 87 88 break;101 case 2: 102 renderValue(decision); 103 return cbDecisionRenderer; 89 104 } 90 105 return this; -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionRenderer.java
r2070 r2099 44 44 } 45 45 46 /* --------------------------------------------------------------------------------- */ 47 /* ListCellRenderer */ 48 /* --------------------------------------------------------------------------------- */ 46 49 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, 47 50 boolean cellHasFocus) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java
r2070 r2099 6 6 import java.awt.Font; 7 7 8 import javax.swing.DefaultComboBoxModel; 9 import javax.swing.JComboBox; 8 10 import javax.swing.JLabel; 9 11 … … 28 30 static public void prepareLabel(RelationMemberConflictDecisionType decision, JLabel label) { 29 31 switch(decision) { 30 case REMOVE: 31 label.setText(tr("Remove")); 32 label.setToolTipText(tr("Remove this relation member from the relation")); 33 break; 34 case REPLACE: 35 label.setText(tr("Replace")); 36 label.setToolTipText(tr("Replace the way this member refers with the combined way")); 37 break; 38 case UNDECIDED: 39 label.setText(tr("Undecided")); 40 label.setToolTipText(tr("Not decided yet")); 41 break; 32 case REMOVE: 33 label.setText(tr("Remove")); 34 label.setToolTipText(tr("Remove this relation member from the relation")); 35 break; 36 case REPLACE: 37 label.setText(tr("Replace")); 38 label.setToolTipText(tr("Replace the way this member refers to with the combined way")); 39 break; 40 case UNDECIDED: 41 label.setText(tr("Undecided")); 42 label.setToolTipText(tr("Not decided yet")); 43 break; 44 } 45 } 46 47 static public void prepareComboBox(RelationMemberConflictDecisionType decision, JComboBox comboBox) { 48 DefaultComboBoxModel model = (DefaultComboBoxModel)comboBox.getModel(); 49 model.removeAllElements(); 50 switch(decision) { 51 case REMOVE: 52 model.addElement(tr("Remove")); 53 comboBox.setToolTipText(tr("Remove this relation member from the relation")); 54 comboBox.setSelectedIndex(0); 55 break; 56 case REPLACE: 57 model.addElement(tr("Replace")); 58 comboBox.setToolTipText(tr("Replace the way this member refers to with the combined way")); 59 comboBox.setSelectedIndex(0); 60 break; 61 case UNDECIDED: 62 model.addElement(tr("Undecided")); 63 comboBox.setToolTipText(tr("Not decided yet")); 64 comboBox.setSelectedIndex(0); 65 break; 42 66 } 43 67 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
r2070 r2099 8 8 import java.awt.event.ActionEvent; 9 9 import java.util.Collection; 10 import java.util.LinkedList;11 import java.util.List;12 10 13 11 import javax.swing.AbstractAction; … … 24 22 import javax.swing.event.ChangeListener; 25 23 24 import org.openstreetmap.josm.Main; 26 25 import org.openstreetmap.josm.command.ChangePropertyCommand; 27 26 import org.openstreetmap.josm.command.Command; 28 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 28 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 29 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 30 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 30 31 import org.openstreetmap.josm.tools.ImageProvider; 31 32 … … 37 38 private JCheckBox cbTagRelations; 38 39 private RelationMemberConflictResolverModel model; 40 private RelationMemberConflictResolverTable tblResolver; 39 41 40 42 protected void build() { 41 43 setLayout(new BorderLayout()); 42 44 model=new RelationMemberConflictResolverModel(); 43 add (new JScrollPane( new RelationMemberConflictResolverTable(model)), BorderLayout.CENTER);45 add (new JScrollPane(tblResolver = new RelationMemberConflictResolverTable(model)), BorderLayout.CENTER); 44 46 JPanel pnl = new JPanel(); 45 47 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); … … 111 113 return new ChangePropertyCommand(primitives, tfKey.getText(), tfValue.getText()); 112 114 } 115 116 public void prepareForEditing() { 117 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).initFromDataSet(); 118 AutoCompletionList acList = new AutoCompletionList(); 119 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithMemberRoles(acList); 120 tfRole.setAutoCompletionList(acList); 121 AutoCompletingTextField editor = (AutoCompletingTextField)tblResolver.getColumnModel().getColumn(2).getCellEditor(); 122 if (editor != null) { 123 editor.setAutoCompletionList(acList); 124 } 125 AutoCompletionList acList2 = new AutoCompletionList(); 126 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithKeys(acList2, false /* don't append */); 127 tfKey.setAutoCompletionList(acList2); 128 } 113 129 }
Note:
See TracChangeset
for help on using the changeset viewer.