-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add save button to toolbar, separate save dialog from Menu
- Loading branch information
Showing
6 changed files
with
112 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package MVC.View.Components.Dialogs; | ||
|
||
import MVC.View.Events.SaveOutputEvent; | ||
import MVC.View.Listeners.Listener; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
*/ | ||
public class SaveDialog { | ||
|
||
private JFileChooser fileChooser; | ||
private OutputTypeChooser outputTypeChooser; | ||
private JFrame mainFrame; | ||
|
||
private Listener<SaveOutputEvent> saveOutputListener; | ||
|
||
private static final String SAVE_FILES_DIALOG_NAME = "Select Directory"; | ||
|
||
public SaveDialog(JFileChooser fileChooser, JFrame mainFrame){ | ||
this.fileChooser = fileChooser; | ||
outputTypeChooser = new OutputTypeChooser(); | ||
this.mainFrame = mainFrame; | ||
} | ||
|
||
public void openDialog(){ | ||
initOutputFileChooser(); | ||
int action = fileChooser.showDialog(mainFrame, SAVE_FILES_DIALOG_NAME); | ||
saveOutputListener.eventOccurred(new SaveOutputEvent(outputTypeChooser.getChosenOutput(), | ||
outputTypeChooser.getDatasetName(), fileChooser.getSelectedFile().getAbsolutePath(), action)); | ||
} | ||
|
||
private void initOutputFileChooser(){ | ||
fileChooser.resetChoosableFileFilters(); | ||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | ||
fileChooser.setAccessory(outputTypeChooser); | ||
} | ||
|
||
public void setSaveOutputListener(Listener<SaveOutputEvent> saveOutputListener) { | ||
this.saveOutputListener = saveOutputListener; | ||
} | ||
} |
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
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
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