I'm writing code to handle saving of the current project when the user attempts to load or create a new project or exit the program. When such an attempt is made, the user is prompted if he want to save the current project before completing the action. Currently this is handled in an inner class implementing javax.swing.Action and in an inner class implementing java.awt.WindowListener in the controller. Handling is then passed on to a method in the controller who tells the view to prompt the user and then returns a boolean whether or not a save is wanted and lets the inner class save and then take the wanted action. The problem is in the cancel-option. Part of the point of the saveFirst() method is that I don't want to have to rewrite the switch/case-block for each of new/load/exit. Therefore I would like to handle the cancel-option in that method instead. My thought here was to use Thread.currentThread().interrupt(). My knowledge of threads is however limited so I do not know how good-looking this is code-wise and if I might run into problems later so that is what I'm seeking help for.
The inner class:
The saveFirst() method in the controller
The inner class:
The saveFirst() method in the controller