1
1
package edu .wpi .grip .ui ;
2
2
3
+ import edu .wpi .grip .core .GripFileManager ;
3
4
import edu .wpi .grip .core .Palette ;
4
5
import edu .wpi .grip .core .Pipeline ;
5
6
import edu .wpi .grip .core .PipelineRunner ;
33
34
import java .io .IOException ;
34
35
import java .util .Optional ;
35
36
import java .util .Set ;
36
- import java .util .logging .Level ;
37
- import java .util .logging .Logger ;
38
37
39
38
import javafx .application .Platform ;
40
39
import javafx .fxml .FXML ;
63
62
*/
64
63
public class MainWindowController {
65
64
66
- private static final Logger logger = Logger .getLogger (MainWindowController .class .getName ());
67
-
68
65
@ FXML
69
66
private Parent root ;
70
67
@ FXML
@@ -154,11 +151,7 @@ private boolean showConfirmationDialogAndWait() {
154
151
} else if (dialog .getResult ().equals (save )) {
155
152
// If the user chose "Save", automatically show a save dialog and block until the user
156
153
// has had a chance to save the project.
157
- try {
158
- return saveProject ();
159
- } catch (IOException e ) {
160
- logger .log (Level .SEVERE , e .getMessage (), e .getCause ());
161
- }
154
+ return saveProject ();
162
155
}
163
156
}
164
157
return true ;
@@ -219,11 +212,10 @@ public void openProject() {
219
212
* @return true if the user does not cancel the save
220
213
*/
221
214
@ FXML
222
- public boolean saveProject () throws IOException {
215
+ public boolean saveProject () {
223
216
if (project .getFile ().isPresent ()) {
224
217
// Immediately save the project to whatever file it was loaded from or last saved to.
225
- project .save (project .getFile ().get ());
226
- return true ;
218
+ return project .trySave (project .getFile ().get ());
227
219
} else {
228
220
return saveProjectAs ();
229
221
}
@@ -237,10 +229,11 @@ public boolean saveProject() throws IOException {
237
229
* @return true if the user does not cancel the save
238
230
*/
239
231
@ FXML
240
- public boolean saveProjectAs () throws IOException {
232
+ public boolean saveProjectAs () {
241
233
final FileChooser fileChooser = new FileChooser ();
242
234
fileChooser .setTitle ("Save Project As" );
243
235
fileChooser .getExtensionFilters ().add (new ExtensionFilter ("GRIP File" , "*.grip" ));
236
+ fileChooser .setInitialDirectory (GripFileManager .GRIP_DIRECTORY );
244
237
245
238
project .getFile ().ifPresent (file -> fileChooser .setInitialDirectory (file .getParentFile ()));
246
239
@@ -249,8 +242,7 @@ public boolean saveProjectAs() throws IOException {
249
242
return false ;
250
243
}
251
244
252
- project .save (file );
253
- return true ;
245
+ return project .trySave (file );
254
246
}
255
247
256
248
@ FXML
0 commit comments