- Timestamp:
- 2015-10-19T23:30:55+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r8802 r8913 64 64 @Override 65 65 public void actionPerformed(ActionEvent e) { 66 try { 67 saveSession(); 68 } catch (CancelException ignore) { 69 } 70 } 71 72 /** 73 * Denotes that the user has cancelled the save process. 74 * @since 8913 75 */ 76 public static class CancelException extends Exception { 77 } 78 79 /** 80 * Attempts to save the session. 81 * @throws CancelException when the user has cancelled the save process. 82 * @since 8913 83 */ 84 public void saveSession() throws CancelException { 66 85 if (!isEnabled()) { 67 86 return; … … 70 89 SessionSaveAsDialog dlg = new SessionSaveAsDialog(); 71 90 dlg.showDialog(); 72 if (dlg.getValue() != 1) return; 91 if (dlg.getValue() != 1) { 92 throw new CancelException(); 93 } 73 94 74 95 boolean zipRequired = false; … … 93 114 } 94 115 95 if (fc == null) 96 return; 116 if (fc == null) { 117 throw new CancelException(); 118 } 97 119 98 120 File file = fc.getSelectedFile(); … … 116 138 if (fn.indexOf('.') == -1) { 117 139 file = new File(file.getPath() + (zip ? ".joz" : ".jos")); 118 if (!SaveActionBase.confirmOverwrite(file)) 119 return; 140 if (!SaveActionBase.confirmOverwrite(file)) { 141 throw new CancelException(); 142 } 120 143 } 121 144 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r8912 r8913 42 42 43 43 import org.openstreetmap.josm.Main; 44 import org.openstreetmap.josm.actions.SessionSaveAsAction; 44 45 import org.openstreetmap.josm.actions.UploadAction; 45 46 import org.openstreetmap.josm.gui.ExceptionDialogUtil; … … 67 68 68 69 private SaveAndProceedAction saveAndProceedAction; 70 private SaveSessionAction saveSessionAction; 69 71 private DiscardAndProceedAction discardAndProceedAction; 70 72 private CancelAction cancelAction; … … 105 107 saveAndProceedAction = new SaveAndProceedAction(); 106 108 model.addPropertyChangeListener(saveAndProceedAction); 107 pnl.add(saveAndProceedActionButton = new JButton(saveAndProceedAction), GBC.std().insets(5, 5, 5, 5).fill(GBC.HORIZONTAL)); 109 pnl.add(saveAndProceedActionButton = new JButton(saveAndProceedAction), GBC.std(0, 0).insets(5, 5, 0, 0).fill(GBC.HORIZONTAL)); 110 111 saveSessionAction = new SaveSessionAction(); 112 pnl.add(new JButton(saveSessionAction), GBC.std(1, 0).insets(5, 5, 5, 0). fill(GBC.HORIZONTAL)); 108 113 109 114 discardAndProceedAction = new DiscardAndProceedAction(); 110 115 model.addPropertyChangeListener(discardAndProceedAction); 111 pnl.add(new JButton(discardAndProceedAction), GBC.std().insets( 0, 0, 5, 0).fill(GBC.HORIZONTAL));116 pnl.add(new JButton(discardAndProceedAction), GBC.std(0, 1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL)); 112 117 113 118 cancelAction = new CancelAction(); 114 pnl.add(new JButton(cancelAction), GBC.std().insets( 0, 0, 5, 0).fill(GBC.HORIZONTAL));119 pnl.add(new JButton(cancelAction), GBC.std(1, 1).insets(5, 5, 5, 5). fill(GBC.HORIZONTAL)); 115 120 116 121 JPanel pnl2 = new JPanel(); … … 363 368 } 364 369 370 class SaveSessionAction extends SessionSaveAsAction { 371 @Override 372 public void actionPerformed(ActionEvent e) { 373 try { 374 saveSession(); 375 setUserAction(UserAction.PROCEED); 376 closeDialog(); 377 } catch (CancelException ignore) { 378 } 379 } 380 } 381 365 382 final class SaveAndProceedAction extends AbstractAction implements PropertyChangeListener { 366 383 private static final int is = 24; // icon size
Note:
See TracChangeset
for help on using the changeset viewer.