Changeset 4563 in josm
- Timestamp:
- 2011-11-02T10:34:30+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r4238 r4563 68 68 import org.openstreetmap.josm.gui.DefaultNameFormatter; 69 69 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 70 import org.openstreetmap.josm.gui.SideButton; 70 71 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 71 import org.openstreetmap.josm.gui.SideButton;72 72 import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel.PresetHandler; 73 73 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; … … 1118 1118 @Override 1119 1119 public void run() { 1120 1120 // Relation list gets update in EDT so selecting my be postponed to following EDT run 1121 1121 Main.map.relationListDialog.selectRelation(newRelation); 1122 1122 } … … 1268 1268 } 1269 1269 1270 class CancelAction extends AbstractAction {1270 class CancelAction extends SavingAction { 1271 1271 public CancelAction() { 1272 1272 putValue(SHORT_DESCRIPTION, tr("Cancel the updates and close the dialog")); … … 1281 1281 1282 1282 public void actionPerformed(ActionEvent e) { 1283 if (!memberTableModel.hasSameMembersAs(getRelationSnapshot()) || tagEditorPanel.getModel().isDirty()) { 1284 //give the user a chance to save the changes 1285 int ret = confirmClosingByCancel(); 1286 if (ret == 0) { //Yes, save the changes 1287 //copied from OKAction.run() 1288 Main.pref.put("relation.editor.generic.lastrole", tfRole.getText()); 1289 if (getRelation() == null) { 1290 applyNewRelation(); 1291 } else if (!memberTableModel.hasSameMembersAs(getRelationSnapshot()) 1292 || tagEditorPanel.getModel().isDirty()) { 1293 if (isDirtyRelation()) { 1294 if (confirmClosingBecauseOfDirtyState()) { 1295 if (getLayer().getConflicts().hasConflictForMy(getRelation())) { 1296 warnDoubleConflict(); 1297 return; 1298 } 1299 applyExistingConflictingRelation(); 1300 } else 1301 return; 1302 } else { 1303 applyExistingNonConflictingRelation(); 1304 } 1305 } 1306 } 1307 else if (ret == 2) //Cancel, continue editing 1308 return; 1309 //in case of "No, discard", there is no extra action to be performed here. 1310 } 1283 1311 setVisible(false); 1312 } 1313 1314 protected int confirmClosingByCancel() { 1315 ButtonSpec [] options = new ButtonSpec[] { 1316 new ButtonSpec( 1317 tr("Yes, save the changes and close"), 1318 ImageProvider.get("ok"), 1319 tr("Click to save the changes and close this relation editor") , 1320 null /* no specific help topic */ 1321 ), 1322 new ButtonSpec( 1323 tr("No, discard the changes and close"), 1324 ImageProvider.get("cancel"), 1325 tr("Click to discard the changes and close this relation editor") , 1326 null /* no specific help topic */ 1327 ), 1328 new ButtonSpec( 1329 tr("Cancel, continue editing"), 1330 ImageProvider.get("cancel"), 1331 tr("Click to return to the relation editor and to resume relation editing") , 1332 null /* no specific help topic */ 1333 ) 1334 }; 1335 1336 int ret = HelpAwareOptionPane.showOptionDialog( 1337 Main.parent, 1338 tr("<html>The relation has been changed.<br>" 1339 + "<br>" 1340 + "Do you want to save your changes?</html>"), 1341 tr("Unsaved changes"), 1342 JOptionPane.WARNING_MESSAGE, 1343 null, 1344 options, 1345 options[0], // OK is default, 1346 "/Dialog/RelationEditor#DiscardChanges" 1347 ); 1348 return ret; 1284 1349 } 1285 1350 }
Note:
See TracChangeset
for help on using the changeset viewer.