Changeset 9440 in josm
- Timestamp:
- 2016-01-14T16:42:50+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java
r8840 r9440 347 347 relationMemberMerger.unlinkAsListener(); 348 348 } 349 350 public void decideRemaining(MergeDecisionType decision) { 351 propertiesMerger.decideRemaining(decision); 352 tagMerger.decideRemaining(decision); 353 if (my instanceof Way) { 354 nodeListMerger.decideRemaining(decision); 355 } else if (my instanceof Relation) { 356 relationMemberMerger.decideRemaining(decision); 357 } 358 updateResolvedCompletely(); 359 if (!isResolvedCompletely()) { 360 throw new AssertionError(); 361 } 362 } 349 363 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java
r8510 r9440 10 10 11 11 void populate(Conflict<? extends OsmPrimitive> conflict); 12 13 void decideRemaining(MergeDecisionType decision); 12 14 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r8836 r9440 917 917 return null; 918 918 } 919 920 public void decideRemaining(MergeDecisionType decision) { 921 if (!model.isFrozen()) { 922 model.copyAll(MergeDecisionType.KEEP_MINE.equals(decision) ? ListRole.MY_ENTRIES : ListRole.THEIR_ENTRIES); 923 } 924 } 919 925 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java
r8836 r9440 508 508 model.populate(conflict); 509 509 } 510 511 @Override 512 public void decideRemaining(MergeDecisionType decision) { 513 if (!model.isDecidedCoord()) { 514 model.decideDeletedStateConflict(decision); 515 } 516 if (!model.isDecidedCoord()) { 517 model.decideCoordsConflict(decision); 518 } 519 } 510 520 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java
r8840 r9440 202 202 } 203 203 204 public void decideRemaining(MergeDecisionType decision) { 205 for (TagMergeItem item: tagMergeItems) { 206 if (item.getMergeDecision().equals(MergeDecisionType.UNDECIDED)) 207 item.decide(decision); 208 } 209 } 210 204 211 public int getNumResolvedConflicts() { 205 212 int n = 0; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
r8836 r9440 443 443 } 444 444 } 445 446 @Override 447 public void decideRemaining(MergeDecisionType decision) { 448 model.decideRemaining(decision); 449 } 445 450 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r9059 r9440 13 13 import java.awt.event.KeyEvent; 14 14 import java.awt.event.MouseEvent; 15 import java.util.ArrayList; 15 16 import java.util.Arrays; 16 17 import java.util.Collection; 17 18 import java.util.HashSet; 18 19 import java.util.LinkedList; 20 import java.util.List; 19 21 import java.util.Set; 20 22 import java.util.concurrent.CopyOnWriteArrayList; … … 22 24 import javax.swing.AbstractAction; 23 25 import javax.swing.JList; 26 import javax.swing.JMenuItem; 24 27 import javax.swing.JOptionPane; 25 28 import javax.swing.JPopupMenu; … … 30 33 import javax.swing.event.ListSelectionEvent; 31 34 import javax.swing.event.ListSelectionListener; 35 import javax.swing.event.PopupMenuEvent; 36 import javax.swing.event.PopupMenuListener; 32 37 33 38 import org.openstreetmap.josm.Main; 34 39 import org.openstreetmap.josm.actions.AbstractSelectAction; 40 import org.openstreetmap.josm.actions.ExpertToggleAction; 41 import org.openstreetmap.josm.command.Command; 42 import org.openstreetmap.josm.command.SequenceCommand; 35 43 import org.openstreetmap.josm.data.SelectionChangedListener; 36 44 import org.openstreetmap.josm.data.conflict.Conflict; … … 52 60 import org.openstreetmap.josm.gui.PopupMenuHandler; 53 61 import org.openstreetmap.josm.gui.SideButton; 62 import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver; 63 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType; 54 64 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 55 65 import org.openstreetmap.josm.gui.util.GuiHelper; … … 118 128 119 129 popupMenuHandler.addAction(Main.main.menu.autoScaleActions.get("conflict")); 130 131 final ResolveTpMyVersionAction resolveTpMyVersionAction = new ResolveTpMyVersionAction(); 132 final ResolveToTheirVersionAction resolveToTheirVersionAction = new ResolveToTheirVersionAction(); 133 addListSelectionListener(resolveTpMyVersionAction); 134 addListSelectionListener(resolveToTheirVersionAction); 135 final JMenuItem btnResolveMy = popupMenuHandler.addAction(resolveTpMyVersionAction); 136 final JMenuItem btnResolveTheir = popupMenuHandler.addAction(resolveToTheirVersionAction); 137 138 popupMenuHandler.addListener(new PopupMenuListener() { 139 @Override 140 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 141 btnResolveMy.setVisible(ExpertToggleAction.isExpert()); 142 btnResolveTheir.setVisible(ExpertToggleAction.isExpert()); 143 } 144 145 @Override 146 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 147 // Do nothing 148 } 149 150 @Override 151 public void popupMenuCanceled(PopupMenuEvent e) { 152 // Do nothing 153 } 154 }); 120 155 } 121 156 … … 319 354 } 320 355 356 private boolean isConflictSelected() { 357 final ListSelectionModel model = lstConflicts.getSelectionModel(); 358 return model.getMinSelectionIndex() >= 0 && model.getMaxSelectionIndex() >= model.getMinSelectionIndex(); 359 } 360 321 361 @Override 322 362 public void onConflictsAdded(ConflictCollection conflicts) { … … 445 485 @Override 446 486 public void valueChanged(ListSelectionEvent e) { 447 ListSelectionModel model = (ListSelectionModel) e.getSource(); 448 boolean enabled = model.getMinSelectionIndex() >= 0 449 && model.getMaxSelectionIndex() >= model.getMinSelectionIndex(); 450 setEnabled(enabled); 487 setEnabled(isConflictSelected()); 451 488 } 452 489 } … … 471 508 @Override 472 509 public void valueChanged(ListSelectionEvent e) { 473 ListSelectionModel model = (ListSelectionModel) e.getSource(); 474 boolean enabled = model.getMinSelectionIndex() >= 0 475 && model.getMaxSelectionIndex() >= model.getMinSelectionIndex(); 476 setEnabled(enabled); 510 setEnabled(isConflictSelected()); 511 } 512 } 513 514 abstract class ResolveToAction extends ResolveAction { 515 private final String name; 516 private final MergeDecisionType type; 517 518 ResolveToAction(String name, String description, MergeDecisionType type) { 519 this.name = name; 520 this.type = type; 521 putValue(NAME, name); 522 putValue(SHORT_DESCRIPTION, description); 523 } 524 525 @Override 526 public void actionPerformed(ActionEvent e) { 527 final ConflictResolver resolver = new ConflictResolver(); 528 final List<Command> commands = new ArrayList<>(); 529 for (OsmPrimitive osmPrimitive : lstConflicts.getSelectedValuesList()) { 530 Conflict<? extends OsmPrimitive> c = conflicts.getConflictForMy(osmPrimitive); 531 resolver.populate(c); 532 resolver.decideRemaining(type); 533 commands.add(resolver.buildResolveCommand()); 534 } 535 Main.main.undoRedo.add(new SequenceCommand(name, commands)); 536 refreshView(); 537 Main.map.mapView.repaint(); 538 } 539 } 540 541 class ResolveTpMyVersionAction extends ResolveToAction { 542 public ResolveTpMyVersionAction() { 543 super(tr("Resolve to my versions"), tr("Resolves all unresolved conflicts to ''my'' version"), 544 MergeDecisionType.KEEP_MINE); 545 } 546 } 547 548 class ResolveToTheirVersionAction extends ResolveToAction { 549 public ResolveToTheirVersionAction() { 550 super(tr("Resolve to their versions"), tr("Resolves all unresolved conflicts to ''their'' version"), 551 MergeDecisionType.KEEP_THEIR); 477 552 } 478 553 }
Note:
See TracChangeset
for help on using the changeset viewer.