altosui: Improve configuration save feedback
authorKeith Packard <keithp@keithp.com>
Sun, 23 Aug 2020 17:53:25 +0000 (10:53 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 23 Aug 2020 17:53:25 +0000 (10:53 -0700)
Mark window title as (modified) with any unsaved changes. Disable the
'Save' button while the save is happening. Wait for the re-load of
configuration values before clearing the '(modified)' state. This lets
you see when the flight computer has accepted the updated values.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosConfigFCUI.java

index 5143b83754754a05edd235c1d4d6313f2f5bc97b..5ccb107783a9a7922cf17f85c73ee5f86115b654 100644 (file)
@@ -97,6 +97,8 @@ public class AltosConfigFCUI
 
        ActionListener          listener;
 
+       static final String     title = "Configure Flight Computer";
+
        static String[]         main_deploy_values_m = {
                "100", "150", "200", "250", "300", "350",
                "400", "450", "500"
@@ -346,7 +348,7 @@ public class AltosConfigFCUI
 
        /* Build the UI using a grid bag */
        public AltosConfigFCUI(JFrame in_owner, boolean remote) {
-               super (in_owner, "Configure Flight Computer", false);
+               super (in_owner, title, false);
 
                owner = in_owner;
                GridBagConstraints c;
@@ -1044,11 +1046,13 @@ public class AltosConfigFCUI
 
        public void set_dirty() {
                dirty = true;
+               setTitle(title + " (modified)");
                save.setEnabled(true);
        }
 
        public void set_clean() {
                dirty = false;
+               setTitle(title);
                save.setEnabled(false);
        }
 
@@ -1076,13 +1080,13 @@ public class AltosConfigFCUI
                if (cmd.equals("Close") || cmd.equals("Reboot"))
                        if (!check_dirty(cmd))
                                return;
+               if (cmd.equals("Save"))
+                       save.setEnabled(false);
                listener.actionPerformed(e);
                if (cmd.equals("Close") || cmd.equals("Reboot")) {
                        setVisible(false);
                        dispose();
                }
-               if (cmd.equals("Save") || cmd.equals("Reset"))
-                       set_clean();
        }
 
        /* ItemListener interface method */