Skip to content

Commit ef8e972

Browse files
committed
Fix VeLa dialog scratch code not retained when closed without OK (#553)
Persist editor text to the static cache in dispose() so Cancel and window close behave like dismiss, matching user expectation for the Tools -> VeLa scratch buffer. Made-with: Cursor
1 parent c1c6d63 commit ef8e972

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,26 @@ protected JPanel createButtonPane() {
178178

179179
@Override
180180
protected void okAction() {
181-
VeLaDialog.code = VeLaDialog.codeTextArea.getValue();
182181
super.okAction();
183182
}
184183

184+
/**
185+
* Retain VeLa source across dialog invocations whenever the window is closed
186+
* (OK, Cancel, or window close), not only when the dismiss button runs
187+
* {@link #okAction()}.
188+
*/
189+
@Override
190+
public void dispose() {
191+
persistCodeFromEditor();
192+
super.dispose();
193+
}
194+
195+
private static void persistCodeFromEditor() {
196+
if (codeTextArea != null) {
197+
code = codeTextArea.getValue();
198+
}
199+
}
200+
185201
private static void addKeyListener() {
186202
JTextArea area = (JTextArea) (codeTextArea.getUIComponent());
187203
area.addKeyListener(new KeyAdapter() {

0 commit comments

Comments
 (0)