Skip to content

Commit 6f1b837

Browse files
committed
#85: changed save and load chooser handling; changed name of VeLa model
1 parent 7f82d16 commit 6f1b837

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

plugin/src/org/aavso/tools/vstar/external/plugin/VeLaModelCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
public class VeLaModelCreator extends ModelCreatorPluginBase {
3737

38-
private static final String DIALOG_TITLE = "Function Code [model: f(t), optional derivative: df(t)]";
38+
private static final String DIALOG_TITLE = "Function Code [model: f(t:real):real, optional derivative: df(t:real):real]";
3939
private static final String FUNC_NAME = "F";
4040
private static final String DERIV_FUNC_NAME = "DF";
4141
private static final String RESOLUTION_VAR = "RESOLUTION";
@@ -160,7 +160,7 @@ class VeLaModel extends AbstractModel {
160160

161161
if (!velaDialog.isCancelled()) {
162162
modelFuncStr = velaDialog.getCode();
163-
modelNameStr = velaDialog.getPath();
163+
modelNameStr = "VeLa model";
164164
}
165165
}
166166

src/org/aavso/tools/vstar/ui/vela/VeLaDialog.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import java.io.FileDescriptor;
2626
import java.io.FileOutputStream;
2727
import java.io.PrintStream;
28-
import java.net.URISyntaxException;
29-
import java.util.ArrayList;
3028
import java.util.Arrays;
3129
import java.util.List;
3230
import java.util.Optional;
@@ -37,12 +35,13 @@
3735
import javax.swing.JTextArea;
3836

3937
import org.aavso.tools.vstar.ui.dialog.ITextComponent;
38+
import org.aavso.tools.vstar.ui.dialog.LoadChooser;
4039
import org.aavso.tools.vstar.ui.dialog.MessageBox;
40+
import org.aavso.tools.vstar.ui.dialog.SaveChooser;
4141
import org.aavso.tools.vstar.ui.dialog.TextArea;
4242
import org.aavso.tools.vstar.ui.dialog.TextAreaTabs;
4343
import org.aavso.tools.vstar.ui.dialog.TextDialog;
4444
import org.aavso.tools.vstar.ui.mediator.Mediator;
45-
import org.aavso.tools.vstar.ui.resources.ResourceAccessor;
4645
import org.aavso.tools.vstar.util.Pair;
4746
import org.aavso.tools.vstar.util.locale.LocaleProps;
4847
import 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

Comments
 (0)