Ask to save before loading a new maze
model: * Deprecate modified from MazeAppModel, which was misused and misunderstood * Add saved to MazeAppModel to keep track if a maze (or some modification) was saved into a file or not ui: * Use the new saved attribute to know if the maze was saved or not * Move the box asking whether to save the maze or not from QuitMenuItem to SaveBox and call SaveBox from QuitMenuItem * SaveBox now checks if the maze has a source file or not, if not it prompts a box to ask where to save the maze * If the maze was modified, the Load Maze button will pop SaveBox before erasing the current maze
This commit is contained in:
1 parent
80ffabdd69
commit
9b272e5f25
4 files changed
+59
-22
No files matched your search
@@ -23,6 +23,11 @@ public class LoadMazeMenuItem extends JMenuItem
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
|
||||
MazeAppModel mazeAppModel = mazeApp.getMazeAppModel();
|
||||
if (! mazeAppModel.isSaved()) {
|
||||
if (! SaveBox.promptAndContinue(this, mazeApp, "Load maze")){
|
||||
return;
|
||||
}
|
||||
}
|
||||
String filename = FileBox.load(mazeApp);
|
||||
if (filename != null) {
|
||||
mazeApp.getMazeAppModel().loadMaze(filename);
|
||||
|
||||
Reference in new issue
Block a user