Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18070e0
commit 708c285
Showing
3 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.jamesshore.finances.ui; | ||
|
||
import java.awt.*; | ||
import java.io.*; | ||
import javax.swing.*; | ||
|
||
public class SaveAsDialog extends FileDialog { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private ApplicationModel model; | ||
|
||
public SaveAsDialog(Frame parentWindow, ApplicationModel model) { | ||
super(parentWindow, "Save As", FileDialog.SAVE); | ||
this.model = model; | ||
} | ||
|
||
public void display() { | ||
this.setVisible(true); | ||
this.doSave(); // this line of code is untested | ||
} | ||
|
||
// non-private for testing purposes | ||
void doSave() { | ||
try { | ||
String directory = this.getDirectory(); | ||
String file = this.getFile(); | ||
|
||
if (file != null) model.save(new File(directory, file)); | ||
} | ||
catch (IOException e) { | ||
JOptionPane.showMessageDialog(this, "Could not save file: " + e.getLocalizedMessage(), "Save File", JOptionPane.WARNING_MESSAGE); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters