altoslib: Use common constants for flash action messages
authorKeith Packard <keithp@keithp.com>
Thu, 23 Aug 2018 00:42:13 +0000 (17:42 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 23 Aug 2018 00:42:13 +0000 (17:42 -0700)
Place messages in AltosFlashListener instead of using the same strings
in three different places.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosFlash.java
altoslib/AltosFlashListener.java
altoslib/AltosSelfFlash.java
altosuilib/AltosFlashUI.java

index 520663b7d8f567f00c228878a79ba2ac11346289..e6b0571342212f93d763a746ab1d17753b672640 100644 (file)
@@ -257,7 +257,7 @@ public class AltosFlash extends AltosProgrammer {
                        int flash_addr = (int) image.address;
                        int image_start = 0;
 
-                       action("start", 0);
+                       action(AltosFlashListener.flash_start, 0);
                        action(0, image.data.length);
                        while (remain > 0 && !aborted) {
                                int this_time = remain;
@@ -293,7 +293,7 @@ public class AltosFlash extends AltosProgrammer {
                                action(image.data.length - remain, image.data.length);
                        }
                        if (!aborted) {
-                               action("done", 100);
+                               action(AltosFlashListener.flash_done, 100);
                                if (debug != null) {
                                        debug.set_pc((int) image.address);
                                        debug.resume();
index f9eaf00f1f4df5d7ddd4c1df555143c1b8f24733..120e714688533dc45aef64f99dc738b4b2e08f30 100644 (file)
@@ -19,5 +19,9 @@
 package org.altusmetrum.altoslib_13;
 
 public interface AltosFlashListener {
+
+       public final static String flash_start = "start";
+       public final static String flash_done = "done";
+
        public void position(String label, int percent);
 }
index 75fc7946f682c885ec0affd044579ce6d4a8c452..20839ce41a3ef912a8fea022bdc041caadde40c6 100644 (file)
@@ -101,7 +101,7 @@ public class AltosSelfFlash extends AltosProgrammer {
                        long flash_addr = image.address;
                        int image_start = 0;
 
-                       action("start", 0);
+                       action(AltosFlashListener.flash_start, 0);
                        action(0, image.data.length);
                        while (remain > 0 && !aborted) {
                                int this_time = remain;
@@ -129,7 +129,7 @@ public class AltosSelfFlash extends AltosProgrammer {
                                action(image.data.length - remain, image.data.length);
                        }
                        if (!aborted) {
-                               action("done", 100);
+                               action(AltosFlashListener.flash_done, 100);
                        }
                        close();
                } catch (IOException ie) {
index 6dc80272a6772089517ef07bf9da02b0551efd19..4d9c662cc65bad5342c52668967552895ff34f77 100644 (file)
@@ -116,10 +116,10 @@ public class AltosFlashUI
                                                              JOptionPane.ERROR_MESSAGE);
                                setVisible(false);
                                dispose();
-                       } else if (cmd.equals("done")) {
+                       } else if (cmd.equals(AltosFlashListener.flash_done)) {
                                setVisible(false);
                                dispose();
-                       } else if (cmd.equals("start")) {
+                       } else if (cmd.equals(AltosFlashListener.flash_start)) {
                                setVisible(true);
                        } else {
                                pbar.setValue(e.getID());