Ticket #23527: 23527-alpha.patch
| File 23527-alpha.patch, 4.8 KB (added by , 2 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
405 405 /** 406 406 * builds the panel with the OK and the Cancel button 407 407 * @param okAction OK action 408 * @param deleteAction Delete action 408 409 * @param cancelAction Cancel action 409 410 * 410 411 * @return the panel with the OK and the Cancel button … … 421 422 pnl.add(new JButton(new ContextSensitiveHelpAction(ht("/Dialog/RelationEditor")))); 422 423 // Keep users from saving invalid relations -- a relation MUST have at least a tag with the key "type" 423 424 // AND must contain at least one other OSM object. 424 final TableModelListener listener = l -> updateOkPanel( this.actionAccess.getChangedRelation(),okButton, deleteButton);425 final TableModelListener listener = l -> updateOkPanel(okButton, deleteButton); 425 426 listener.tableChanged(null); 426 427 this.memberTableModel.addTableModelListener(listener); 427 428 this.tagEditorPanel.getModel().addTableModelListener(listener); … … 429 430 } 430 431 431 432 /** 432 * Update the OK panel area 433 * @param newRelation What the new relation would "look" like if it were to be saved now 433 * Update the OK panel area with a temporary relation that looks if it were to be saved now. 434 434 * @param okButton The OK button 435 435 * @param deleteButton The delete button 436 436 */ 437 private void updateOkPanel(IRelation<?> newRelation, JButton okButton, JButton deleteButton) { 437 private void updateOkPanel(JButton okButton, JButton deleteButton) { 438 Relation oldRelation = this.actionAccess.getEditor().getRelation(); 439 IRelation<?> newRelation = this.actionAccess.getChangedRelation(); 438 440 okButton.setVisible(newRelation.isUseful() || this.getRelationSnapshot() == null); 439 441 deleteButton.setVisible(!newRelation.isUseful() && this.getRelationSnapshot() != null); 440 442 if (this.getRelationSnapshot() == null && !newRelation.isUseful()) { … … 442 444 } else { 443 445 okButton.setText(tr("OK")); 444 446 } 447 if (newRelation != oldRelation && newRelation.getMembersCount() > 0) 448 newRelation.setMembers(null); // see #19885, #23527 445 449 } 446 450 447 451 /** -
src/org/openstreetmap/josm/gui/dialogs/relation/actions/ApplyAction.java
5 5 6 6 import java.awt.event.ActionEvent; 7 7 8 import org.openstreetmap.josm.data.osm.IRelation; 9 import org.openstreetmap.josm.data.osm.Relation; 8 10 import org.openstreetmap.josm.tools.ImageProvider; 9 11 10 12 /** … … 35 37 36 38 @Override 37 39 public void updateEnabledState() { 38 setEnabled(this.editorAccess.getChangedRelation().isUseful() && isEditorDirty()); 40 boolean enable = isEditorDirty(); 41 if (enable) { 42 Relation oldRelation = this.getEditor().getRelation(); 43 IRelation<?> newRelation = this.editorAccess.getChangedRelation(); 44 enable = newRelation.isUseful(); 45 if (oldRelation != newRelation && newRelation.getMembersCount() > 0) 46 newRelation.setMembers(null); // see #19885, #23527 47 } 48 setEnabled(enable); 39 49 } 40 50 } -
src/org/openstreetmap/josm/gui/dialogs/relation/actions/CancelAction.java
48 48 if ((!getMemberTableModel().hasSameMembersAs(snapshot) || getTagModel().isDirty()) 49 49 && !(snapshot == null && getTagModel().getTags().isEmpty())) { 50 50 //give the user a chance to save the changes 51 int ret = confirmClosingByCancel(this.editorAccess.getChangedRelation()); 51 Relation oldRel = this.editorAccess.getEditor().getRelation(); 52 IRelation<?> newRelation = this.editorAccess.getChangedRelation(); 53 int ret = confirmClosingByCancel(newRelation); 54 if (oldRel != newRelation && newRelation.getMembersCount() > 0) 55 newRelation.setMembers(null); // see #19885, #23527 52 56 if (ret == 0) { //Yes, save the changes 53 57 //copied from OKAction.run() 54 58 Config.getPref().put("relation.editor.generic.lastrole", Utils.strip(tfRole.getText()));
