Changeset 2945 in josm
- Timestamp:
- 2010-02-06T09:37:48+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r2512 r2945 72 72 conflict.getMy().setDeleted(true); 73 73 } else { 74 conflict.getMy().setDeleted( conflict.getTheir().isDeleted());74 conflict.getMy().setDeleted(false); 75 75 } 76 76 } else -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
r2936 r2945 231 231 setMy(my); 232 232 setTheir(their); 233 propertiesMerger. getModel().populate(my, their);233 propertiesMerger.populate(my, their); 234 234 if (propertiesMerger.getModel().hasVisibleStateConflict()) { 235 235 tabbedPane.setEnabledAt(1, false); … … 239 239 } 240 240 tabbedPane.setEnabledAt(0, true); 241 tagMerger. getModel().populate(my, their);241 tagMerger.populate(my, their); 242 242 tabbedPane.setEnabledAt(1, true); 243 243 … … 246 246 tabbedPane.setEnabledAt(3,false); 247 247 } else if (my instanceof Way) { 248 nodeListMerger.populate( (Way)my, (Way)their);248 nodeListMerger.populate(my, their); 249 249 tabbedPane.setEnabledAt(2, true); 250 250 tabbedPane.setEnabledAt(3, false); … … 252 252 tabbedPane.setIconAt(3, null); 253 253 } else if (my instanceof Relation) { 254 relationMemberMerger.populate( (Relation)my, (Relation)their);254 relationMemberMerger.populate(my, their); 255 255 tabbedPane.setEnabledAt(2, false); 256 256 tabbedPane.setTitleAt(2,tr("Nodes")); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java
r2936 r2945 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.conflict.pair; 3 4 import org.openstreetmap.josm.data.osm.OsmPrimitive; 3 5 4 6 public interface IConflictResolver { 5 7 6 8 void deletePrimitive(boolean deleted); 9 void populate(OsmPrimitive my, OsmPrimitive their); 7 10 8 11 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r2936 r2945 310 310 } 311 311 312 public void copyAll(ListRole source) { 313 getMergedEntries().clear(); 314 getMergedEntries().addAll(entries.get(source)); 315 fireModelDataChanged(); 316 } 317 312 318 /** 313 319 * Copies the nodes given by indices in rows from the list of nodes <code>source</code> to the -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r2846 r2945 57 57 private CopyAfterCurrentLeftAction copyAfterCurrentLeftAction; 58 58 private CopyEndLeftAction copyEndLeftAction; 59 private CopyAllLeft copyAllLeft; 59 60 60 61 private CopyStartRightAction copyStartRightAction; … … 62 63 private CopyAfterCurrentRightAction copyAfterCurrentRightAction; 63 64 private CopyEndRightAction copyEndRightAction; 65 private CopyAllRight copyAllRight; 64 66 65 67 private MoveUpMergedAction moveUpMergedAction; … … 118 120 mergedEntriesTable.getSelectionModel().addListSelectionListener(moveDownMergedAction); 119 121 mergedEntriesTable.getSelectionModel().addListSelectionListener(removeMergedAction); 122 123 model.addObserver(copyAllLeft); 124 model.addObserver(copyAllRight); 125 model.addPropertyChangeListener(copyAllLeft); 126 model.addPropertyChangeListener(copyAllRight); 120 127 } 121 128 … … 153 160 pnl.add(btn, gc); 154 161 162 gc.gridx = 0; 163 gc.gridy = 4; 164 copyAllLeft = new CopyAllLeft(); 165 btn = new JButton(copyAllLeft); 166 btn.setName("button.copyallleft"); 167 pnl.add(btn, gc); 168 155 169 return pnl; 156 170 } … … 180 194 copyEndRightAction = new CopyEndRightAction(); 181 195 pnl.add(new JButton(copyEndRightAction), gc); 196 197 gc.gridx = 0; 198 gc.gridy = 4; 199 copyAllRight = new CopyAllRight(); 200 pnl.add(new JButton(copyAllRight), gc); 182 201 183 202 return pnl; … … 614 633 && ! mergedEntriesTable.getSelectionModel().isSelectionEmpty() 615 634 ); 635 } 636 } 637 638 class CopyAllLeft extends AbstractAction implements Observer, PropertyChangeListener { 639 640 public CopyAllLeft() { 641 ImageIcon icon = ImageProvider.get("dialogs/conflict", "useallleft.png"); 642 putValue(Action.SMALL_ICON, icon); 643 putValue(Action.SHORT_DESCRIPTION, tr("Use all mine elements")); 644 } 645 646 public void actionPerformed(ActionEvent arg0) { 647 model.copyAll(ListRole.MY_ENTRIES); 648 model.setFrozen(true); 649 } 650 651 private void updateEnabledState() { 652 setEnabled(model.getMergedEntries().isEmpty() && !model.isFrozen()); 653 } 654 655 public void update(Observable o, Object arg) { 656 updateEnabledState(); 657 } 658 659 public void propertyChange(PropertyChangeEvent evt) { 660 updateEnabledState(); 661 } 662 } 663 664 class CopyAllRight extends AbstractAction implements Observer, PropertyChangeListener { 665 666 public CopyAllRight() { 667 ImageIcon icon = ImageProvider.get("dialogs/conflict", "useallright.png"); 668 putValue(Action.SMALL_ICON, icon); 669 putValue(Action.SHORT_DESCRIPTION, tr("Use all their elements")); 670 } 671 672 public void actionPerformed(ActionEvent arg0) { 673 model.copyAll(ListRole.THEIR_ENTRIES); 674 model.setFrozen(true); 675 } 676 677 private void updateEnabledState() { 678 setEnabled(model.getMergedEntries().isEmpty() && !model.isFrozen()); 679 } 680 681 public void update(Observable o, Object arg) { 682 updateEnabledState(); 683 } 684 685 public void propertyChange(PropertyChangeEvent evt) { 686 updateEnabledState(); 616 687 } 617 688 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java
r2936 r2945 5 5 6 6 import org.openstreetmap.josm.data.osm.Node; 7 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 8 import org.openstreetmap.josm.data.osm.Way; 8 9 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver; … … 62 63 } 63 64 64 public void populate( Way my, Waytheir) {65 ((NodeListMergeModel)model).populate( my,their);65 public void populate(OsmPrimitive my, OsmPrimitive their) { 66 ((NodeListMergeModel)model).populate((Way)my, (Way)their); 66 67 } 67 68 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java
r2940 r2945 717 717 } 718 718 } 719 720 public void populate(OsmPrimitive my, OsmPrimitive their) { 721 model.populate(my, their); 722 } 719 723 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java
r2936 r2945 5 5 import javax.swing.JTable; 6 6 7 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 8 import org.openstreetmap.josm.data.osm.Relation; 8 9 import org.openstreetmap.josm.data.osm.RelationMember; … … 53 54 } 54 55 55 public void populate( Relation my, Relationtheir) {56 public void populate(OsmPrimitive my, OsmPrimitive their) { 56 57 RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel(); 57 model.populate( my,their);58 model.populate((Relation)my, (Relation)their); 58 59 } 59 60 -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java
r2936 r2945 6 6 import java.util.ArrayList; 7 7 import java.util.HashSet; 8 import java.util.List; 8 9 import java.util.Set; 9 10 … … 33 34 34 35 /** the list of tag merge items */ 35 private final ArrayList<TagMergeItem> tagMergeItems;36 private final List<TagMergeItem> tagMergeItems; 36 37 37 38 /** the property change listeners */ 38 private final ArrayList<PropertyChangeListener> listeners;39 private final List<PropertyChangeListener> listeners; 39 40 40 41 private int numUndecidedTags = 0; … … 210 211 211 212 } 213 214 public int getFirstUndecided(int startIndex) { 215 for (int i=startIndex; i<tagMergeItems.size(); i++) { 216 if (tagMergeItems.get(i).getMergeDecision() == MergeDecisionType.UNDECIDED) 217 return i; 218 } 219 return -1; 220 } 212 221 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
r2936 r2945 26 26 import javax.swing.event.ListSelectionListener; 27 27 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; 28 29 import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver; 29 30 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; … … 241 242 public TagMergeModel getModel() { 242 243 return model; 244 } 245 246 private void selectNextConflict(int[] rows) { 247 int max = rows[0]; 248 for (int row: rows) { 249 if (row > max) { 250 max = row; 251 } 252 } 253 int index = model.getFirstUndecided(max+1); 254 if (index == -1) { 255 index = model.getFirstUndecided(0); 256 } 257 mineTable.getSelectionModel().setSelectionInterval(index, index); 258 theirTable.getSelectionModel().setSelectionInterval(index, index); 243 259 } 244 260 … … 265 281 return; 266 282 model.decide(rows, MergeDecisionType.KEEP_MINE); 283 selectNextConflict(rows); 267 284 } 268 285 … … 294 311 return; 295 312 model.decide(rows, MergeDecisionType.KEEP_THEIR); 313 selectNextConflict(rows); 296 314 } 297 315 … … 402 420 } 403 421 } 422 423 public void populate(OsmPrimitive my, OsmPrimitive their) { 424 model.populate(my, their); 425 mineTable.getSelectionModel().setSelectionInterval(0, 0); 426 theirTable.getSelectionModel().setSelectionInterval(0, 0); 427 } 404 428 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r2930 r2945 137 137 */ 138 138 private final void resolve() { 139 if (conflicts == null) return; 140 if (conflicts.size() == 1) { 141 lstConflicts.setSelectedIndex(0); 142 } 143 144 if (lstConflicts.getSelectedIndex() == -1) 145 return; 146 147 int [] selectedRows = lstConflicts.getSelectedIndices(); 148 if (selectedRows == null || selectedRows.length == 0) 149 return; 150 int row = selectedRows[0]; 151 Conflict<?> c = conflicts.get(row); 139 if (conflicts == null || model.getSize() == 0) return; 140 141 int index = lstConflicts.getSelectedIndex(); 142 if (index < 0) { 143 index = 0; 144 } 145 146 Conflict<?> c = conflicts.get(index); 152 147 OsmPrimitive my = c.getMy(); 153 148 OsmPrimitive their = c.getTheir(); … … 155 150 dialog.getConflictResolver().populate(my, their); 156 151 dialog.setVisible(true); 152 153 lstConflicts.setSelectedIndex(index); 154 157 155 Main.map.mapView.repaint(); 158 156 }
Note:
See TracChangeset
for help on using the changeset viewer.