Changeset 1795 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-07-15T18:44:58+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1794 r1795 45 45 import org.openstreetmap.josm.command.AddCommand; 46 46 import org.openstreetmap.josm.command.ChangeCommand; 47 import org.openstreetmap.josm.data.conflict.Conflict; 47 48 import org.openstreetmap.josm.data.osm.DataSet; 48 49 import org.openstreetmap.josm.data.osm.DataSource; … … 534 535 * This function saves the user's changes. Must be invoked manually. 535 536 */ 536 pr ivatevoid applyChanges() {537 protected void applyChanges() { 537 538 if (getRelation()== null) { 538 539 // If the user wanted to create a new relation, but hasn't added any members or … … 546 547 DataSet.fireSelectionChanged(Main.ds.getSelected()); 547 548 } else if (! memberTableModel.hasSameMembersAs(getRelation()) || tagEditorModel.isDirty()) { 548 Relation clone = new Relation(getRelation()); 549 tagEditorModel.applyToPrimitive(clone); 550 memberTableModel.applyToRelation(clone); 551 Main.main.undoRedo.add(new ChangeCommand(getRelation(), clone)); 552 DataSet.fireSelectionChanged(Main.ds.getSelected()); 549 Relation editedRelation = new Relation(getRelation()); 550 tagEditorModel.applyToPrimitive(editedRelation); 551 memberTableModel.applyToRelation(editedRelation); 552 if (isDirtyRelation()) { 553 Conflict<Relation> conflict = new Conflict<Relation>(getRelation(), editedRelation); 554 getLayer().getConflicts().add(conflict); 555 JOptionPane op = new JOptionPane( 556 tr("<html>The relation has changed outside of the editor.<br>" 557 + "Your edit can't be applied directly, a conflict has been created instead.</html>" 558 ), 559 JOptionPane.WARNING_MESSAGE 560 ); 561 JDialog dialog = op.createDialog(Main.pleaseWaitDlg, tr("Conflict created")); 562 dialog.setAlwaysOnTop(true); 563 dialog.setModal(true); 564 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 565 dialog.setVisible(true); 566 } else { 567 Relation clone = new Relation(getRelation()); 568 tagEditorModel.applyToPrimitive(clone); 569 memberTableModel.applyToRelation(clone); 570 Main.main.undoRedo.add(new ChangeCommand(getRelation(), clone)); 571 DataSet.fireSelectionChanged(Main.ds.getSelected()); 572 } 553 573 } 554 574 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
r1790 r1795 37 37 38 38 /** 39 * The relation that this editor is working on, and the clone made for 40 * editing. 39 * The relation that this editor is working on. 41 40 */ 42 41 private Relation relation; 42 43 /** The version of the relation when editing is started. */ 44 private Relation relationSnapshot; 43 45 44 46 /** the data layer the relation belongs to */ … … 100 102 ); 101 103 104 this.relationSnapshot = new Relation(relation); 102 105 this.relation = relation; 103 106 this.layer = layer; … … 111 114 return layer; 112 115 } 116 117 protected Relation getRelationSnapshot() { 118 return relationSnapshot; 119 } 120 121 /** 122 * Replies true if the currently edited relation has been changed elsewhere. 123 * 124 * In this case a relation editor can't apply updates to the relation directly. Rather, 125 * it has to create a conflict. 126 * 127 * @return true if the currently edited relation has been changed elsewhere. 128 */ 129 protected boolean isDirtyRelation() { 130 return ! relation.hasEqualSemanticAttributes(relationSnapshot); 131 } 113 132 }
Note:
See TracChangeset
for help on using the changeset viewer.