2525import java .io .FileDescriptor ;
2626import java .io .FileOutputStream ;
2727import java .io .PrintStream ;
28- import java .net .URISyntaxException ;
29- import java .util .ArrayList ;
3028import java .util .Arrays ;
3129import java .util .List ;
3230import java .util .Optional ;
3735import javax .swing .JTextArea ;
3836
3937import org .aavso .tools .vstar .ui .dialog .ITextComponent ;
38+ import org .aavso .tools .vstar .ui .dialog .LoadChooser ;
4039import org .aavso .tools .vstar .ui .dialog .MessageBox ;
40+ import org .aavso .tools .vstar .ui .dialog .SaveChooser ;
4141import org .aavso .tools .vstar .ui .dialog .TextArea ;
4242import org .aavso .tools .vstar .ui .dialog .TextAreaTabs ;
4343import org .aavso .tools .vstar .ui .dialog .TextDialog ;
4444import org .aavso .tools .vstar .ui .mediator .Mediator ;
45- import org .aavso .tools .vstar .ui .resources .ResourceAccessor ;
4645import org .aavso .tools .vstar .util .Pair ;
4746import org .aavso .tools .vstar .util .locale .LocaleProps ;
4847import org .aavso .tools .vstar .vela .AST ;
@@ -65,7 +64,7 @@ public class VeLaDialog extends TextDialog {
6564
6665 private static String code = "" ;
6766
68- private String path ;
67+ private File path ;
6968
7069 private static List <ITextComponent <String >> createTextAreas () {
7170 codeTextArea = new TextArea ("VeLa Code" , code , 12 , 42 , false , true );
@@ -89,7 +88,7 @@ private static List<ITextComponent<String>> createTextAreas() {
8988
9089 public VeLaDialog (String title ) {
9190 super (title , createTextAreas (), true , true );
92- path = "VeLa model" ;
91+ path = new File ( "Untitled" ) ;
9392 }
9493
9594 public VeLaDialog (String title , String code ) {
@@ -105,7 +104,7 @@ public VeLaDialog() {
105104 /**
106105 * @return the most recently loaded/saved file path
107106 */
108- public String getPath () {
107+ public File getPath () {
109108 return path ;
110109 }
111110
@@ -142,8 +141,8 @@ protected JPanel createButtonPane() {
142141 JButton loadButton = new JButton (LocaleProps .get ("LOAD_BUTTON" ));
143142 loadButton .addActionListener (e -> {
144143 try {
145- Pair < String , String > content = Mediator .getInstance ().getVelaFileLoadDialog (). readFileAsString ( this ,
146- null );
144+ LoadChooser dialog = Mediator .getInstance ().getVelaFileLoadDialog ();
145+ Pair < String , String > content = dialog . readFileAsString ( this , null );
147146 if (content != null ) {
148147 codeTextArea .setValue (content .first );
149148 }
@@ -158,7 +157,10 @@ protected JPanel createButtonPane() {
158157 saveButton .addActionListener (e -> {
159158 try {
160159 String content = codeTextArea .getValue ();
161- Mediator .getInstance ().getVelaFileSaveDialog ().writeStringToFile (this , content , null );
160+ SaveChooser dialog = Mediator .getInstance ().getVelaFileSaveDialog ();
161+ if (dialog .writeStringToFile (this , content , null )) {
162+ path = dialog .getSaveDialogSelectedFile ();
163+ }
162164 } catch (Exception ex ) {
163165 MessageBox .showErrorDialog (this , getTitle (), ex );
164166 }
0 commit comments