altosuilib: Make dialogs mostly scrollable
authorKeith Packard <keithp@keithp.com>
Mon, 31 Aug 2020 22:08:08 +0000 (15:08 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 26 Sep 2020 03:07:39 +0000 (20:07 -0700)
When screens are too small, some dialogs aren't usable. Fix that by
wrapping them all with a scrollable pane.

Signed-off-by: Keith Packard <keithp@keithp.com>
23 files changed:
altosui/AltosConfigFCUI.java
altosui/AltosConfigPyroUI.java
altosui/AltosConfigTDUI.java
altosui/AltosFlightUI.java
altosui/AltosIdleMonitorUI.java
altosui/AltosIgniteUI.java
altosui/AltosLaunchUI.java
altosui/install-macosx
altosuilib/AltosBTManage.java
altosuilib/AltosConfigFreqUI.java
altosuilib/AltosEepromMonitorUI.java
altosuilib/AltosFlashUI.java
altosuilib/AltosRomconfigUI.java
altosuilib/AltosScanUI.java
altosuilib/AltosUIAccelCal.java
altosuilib/AltosUIConfigure.java
altosuilib/AltosUIDialog.java
altosuilib/AltosUIFrame.java
altosuilib/AltosUIMapPreload.java
altosuilib/AltosUIPreferences.java
altosuilib/AltosUSBDevice.java
micropeak/MicroDownload.java
telegps/TeleGPSConfigUI.java

index 5ccb107783a9a7922cf17f85c73ee5f86115b654..278d3fea167f076bf0dac50f886f5b94d2040dfd 100644 (file)
@@ -357,7 +357,8 @@ public class AltosConfigFCUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
+
                pane.setLayout(new GridBagLayout());
 
                /* Product */
index 309bb8ee80c7c35fdbdbfe096926423157d3cdba..2b01cee877509d95564de9217776f850af7afb70 100644 (file)
@@ -386,7 +386,7 @@ public class AltosConfigPyroUI
 
                GridBagConstraints      c;
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                int     nrow = 0;
index 0fdf4449938a06cabc7eaaf5e5383e409e800747..b2e8e8030f36be542525a474074f68e7b8c42113 100644 (file)
@@ -82,7 +82,7 @@ public class AltosConfigTDUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                /* Product */
index 608042a544947e05521e8213987a071d2c15fd42..a2d0c3645b898daadb7f7c00e10d141e9aabe45d 100644 (file)
@@ -186,7 +186,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
                voice = in_voice;
                reader = in_reader;
 
-               bag = getContentPane();
+               bag = getScrollablePane();
                bag.setLayout(new GridBagLayout());
 
                setTitle(String.format("AltOS %s", reader.name));
index 26bc06e40f648ba4aa8df345826d685c4fe57106..50994bb27293d55c71e3af9b5311339a49b4ffc6 100644 (file)
@@ -226,7 +226,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
                /* We let the user set the freq/callsign, so don't bother with the cancel dialog */
                link.set_cancel_enable(false);
 
-               bag = getContentPane();
+               bag = getScrollablePane();
                bag.setLayout(new GridBagLayout());
 
                setTitle(String.format("AltOS %s", device.toShortString()));
index 0d848ab86fea079e2c39780f9eecf03533b678e6..8256722a513269405ece3db08e16b5c7d8c0a5ca 100644 (file)
@@ -65,7 +65,7 @@ public class AltosIgniteUI
                }
 
                Igniter(AltosIgniteUI ui, String label, String name, int y) {
-                       Container               pane = getContentPane();
+                       Container               pane = getScrollablePane();
                        GridBagConstraints      c = new GridBagConstraints();
                        Insets                  i = new Insets(4,4,4,4);
 
@@ -388,7 +388,7 @@ public class AltosIgniteUI
        private void make_ui() {
                group = new ButtonGroup();
 
-               Container               pane = getContentPane();
+               Container               pane = getScrollablePane();
 
                GridBagConstraints      c = new GridBagConstraints();
                Insets                  i = new Insets(4,4,4,4);
index 875b786e7c77e6fdb295b26644b05f433ca3079a..6615063badd39bb12f5cb3594312e8a1aeb63e49 100644 (file)
@@ -393,7 +393,7 @@ public class AltosLaunchUI
                if (!open())
                        return;
 
-               Container               pane = getContentPane();
+               Container               pane = getScrollablePane();
                GridBagConstraints      c = new GridBagConstraints();
                Insets                  i = new Insets(4,4,4,4);
 
@@ -510,4 +510,4 @@ public class AltosLaunchUI
 
                setVisible(true);
        }
-}
\ No newline at end of file
+}
index aebfd5276d58fbab1162b513f38979005c805912..aced4ab9280748189f137f223b4b72cdb33fc3db 100755 (executable)
@@ -1,9 +1,37 @@
-#!/bin/sh
+#!/bin/bash
+
+case `id -u` in
+    0)
+    ;;
+    *)
+       # Check for java
+       if [ ! -d /Library/Java/JavaVirtualMachines/ -o `ls /Library/Java/JavaVirtualMachine` == '' ]; then
+           open https://adoptopenjdk.net/
+           osascript -e 'display dialog "Install Java from https://adoptopenjdk.net then click OK" buttons {"Continue"}'
+       fi
+       sudo "$0" "$@"
+       ;;
+esac
+
 dir=`dirname "$0"`
 cd "$dir"
-mkdir -p ~/Applications/AltOS
-find ~/Applications/AltOS -type d -print0 | xargs -0 chmod +w
-cp -f -a * ~/Applications/AltOS
-cd ~/Applications/AltOS
-chmod +w *
-xattr -c *
+APP=`echo *.app`
+LIBRARY=/Library/AltusMetrum
+APPLICATIONS=/Applications/
+for file in *; do
+    case "$i" in
+       *.app)
+           mkdir -p "$(APPLICATIONS)"
+           if [ -d "$(APPLICATIONS)/$(APP)/." ]; then
+               rm -rf "$(APPLICATIONS)/$(APP)"
+           fi
+           cp -a "$i" "$(APPLICATIONS)/$(APP)"
+           chmod +w "$(APPLICATIONS)/$(APP)"/*
+           xattr -c "$(APPLICATIONS)/$(APP)"/*
+           ;;
+       *)
+           mkdir -p "$(LIBRARY)"
+           cp -a "$i" "$(LIBRARY)"
+           ;;
+    esac
+done
index 1726190d58bbdb7b20751bf784643ac260b4775e..37e820b62389178207a08a7fdd1d447839df91fa 100644 (file)
@@ -219,7 +219,7 @@ public class AltosBTManage extends AltosUIDialog implements ActionListener, Iter
 
                found_devices = new LinkedBlockingQueue<AltosBTDevice>();
 
-               Container pane = getContentPane();
+               Container pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                GridBagConstraints c = new GridBagConstraints();
index d24480b33fb7869d37632fd3c5dd95f18db16e74..49fe6b40b48900b6726b756f9be714897ddace3c 100644 (file)
@@ -67,7 +67,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener {
                got_ok = false;
                frame = in_frame;
 
-               Container pane = getContentPane();
+               Container pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                GridBagConstraints c = new GridBagConstraints();
@@ -302,7 +302,7 @@ public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener {
 
                frequencies = new FrequencyList(in_frequencies);
 
-               Container pane = getContentPane();
+               Container pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                GridBagConstraints c = new GridBagConstraints();
index 7da9786cce698bc510ecd14c66669b92a2d107a4..90ce58ac0208f66850c6c3698c2a3613fb363717 100644 (file)
@@ -56,7 +56,7 @@ public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMo
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                c = new GridBagConstraints();
index fd84f921c5d75a5fb0249133321ad0ffd98af247..33fdb6887238f8e530a71f7954a7d6b068fb54ba 100644 (file)
@@ -131,7 +131,7 @@ public class AltosFlashUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                c = new GridBagConstraints();
@@ -637,7 +637,7 @@ public class AltosFlashUI
                        super(in_owner, "Open Flash Target Device", true);
                        owner = in_owner;
 
-                       Container               pane = getContentPane();
+                       Container               pane = getScrollablePane();
                        GridBagConstraints      c = new GridBagConstraints();
                        Insets                  i = new Insets(4,4,4,4);
 
index f2c038a9afaae9d3c7f314f037985a5a4a48fd61..44d3a9f8a685687212aee908c7cbf1a94daadfe4 100644 (file)
@@ -51,7 +51,7 @@ public class AltosRomconfigUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                int y = 0;
index a09142e53406dc0fc7bd0d5a241a71d0c8aa306d..4ec858fa89de9e399921190f6d038286499a488e 100644 (file)
@@ -470,7 +470,7 @@ public class AltosScanUI
                if (!open())
                        return;
 
-               Container               pane = getContentPane();
+               Container               pane = getScrollablePane();
                GridBagConstraints      c = new GridBagConstraints();
                Insets                  i = new Insets(4,4,4,4);
 
index 7ca8ea8292fb589f36a0c9a810024cc23ba5243d..94d80193c2d1b5dbbcc6cffb0cbd7b4aed677729 100644 (file)
@@ -164,7 +164,7 @@ public class AltosUIAccelCal
                this.link = link;
                this.config_values = config_values;
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                GridBagConstraints c = new GridBagConstraints();
index 8ee89dd4400a72a47b9cb459a57af70888e7f76e..09e7daaab595f73cb257e85921f4f32a2e841d81 100644 (file)
@@ -260,7 +260,7 @@ public class AltosUIConfigure
                super(in_owner, name, false);
 
                owner = in_owner;
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                row = 0;
index 34bd50d80ecf82ffaec1156aab534362abaa345e..be883a1479baa48fe486c8bd1f01a554394640d1 100644 (file)
@@ -30,6 +30,30 @@ class AltosUIDialogListener extends WindowAdapter {
 
 public class AltosUIDialog extends JDialog implements AltosUIListener {
 
+       private Container scrollPane;
+
+       public Container getScrollablePane() {
+               if (scrollPane == null) {
+                       Container content = super.getContentPane();
+                       /* Create a container to hold the dialog contents */
+                       scrollPane = new Container();
+
+                       /* Make an opaque box to use the right color */
+                       Box box = new Box(BoxLayout.X_AXIS);
+                       box.add(scrollPane);
+                       box.setOpaque(true);
+
+                       /* Create a scrollpane to hold the box */
+                       JScrollPane scroll = new JScrollPane();
+                       JViewport view = scroll.getViewport();
+                       view.add(box);
+
+                       /* Add the scroll pane to the top level */
+                       content.add(scroll);
+               }
+               return (Container) scrollPane;
+       }
+
        public void ui_changed(String look_and_feel) {
                SwingUtilities.updateComponentTreeUI(this);
                this.pack();
index 71e16e1d372ec00820938b73197aa77380a58a5f..f701ce7afa0d1b8243a1736dfecb470ae64f0e69 100644 (file)
@@ -41,6 +41,30 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi
                this.pack();
        }
 
+       private Container scrollPane;
+
+       public Container getScrollablePane() {
+               if (scrollPane == null) {
+                       Container content = super.getContentPane();
+                       /* Create a container to hold the dialog contents */
+                       scrollPane = new Container();
+
+                       /* Make an opaque box to use the right color */
+                       Box box = new Box(BoxLayout.X_AXIS);
+                       box.add(scrollPane);
+                       box.setOpaque(true);
+
+                       /* Create a scrollpane to hold the box */
+                       JScrollPane scroll = new JScrollPane();
+                       JViewport view = scroll.getViewport();
+                       view.add(box);
+
+                       /* Add the scroll pane to the top level */
+                       content.add(scroll);
+               }
+               return (Container) scrollPane;
+       }
+
        static String[] altos_icon_names = {
                "/altusmetrum-altosui-16.png",
                "/altusmetrum-altosui-32.png",
index 31c8ed1b8abc9911df9ef2d77a3807b616039916..9ba273553885242686840c1f74230ba5798dc400 100644 (file)
@@ -336,7 +336,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I
        public AltosUIMapPreload(AltosUIFrame in_owner) {
                owner = in_owner;
 
-               Container               pane = getContentPane();
+               Container               pane = getScrollablePane();
                GridBagConstraints      c = new GridBagConstraints();
                Insets                  i = new Insets(4,4,4,4);
 
index 7e3178d8dd887a926ebc28d127e084801b91d056..c40903ced0c37c590214b11d764af264bde8714e 100644 (file)
@@ -129,18 +129,23 @@ public class AltosUIPreferences extends AltosPreferences {
                        backend.putInt(fontSizePreference, font_size);
                        flush_preferences();
                        AltosUILib.set_fonts(font_size);
-                       for (AltosFontListener l : font_listeners)
+                       for (AltosFontListener l : font_listeners) {
+                               System.out.printf("notifying %s of font size change\n", l);
                                l.font_size_changed(font_size);
+                       }
+                       System.out.printf("all fonts changed\n");
                }
        }
 
        public static void register_font_listener(AltosFontListener l) {
+               System.out.printf("register font listener\n");
                synchronized (backend) {
                        font_listeners.add(l);
                }
        }
 
        public static void unregister_font_listener(AltosFontListener l) {
+               System.out.printf("unregister font listener\n");
                synchronized (backend) {
                        font_listeners.remove(l);
                }
index 50ec4c03bc843399d380df97b6645926d9c6fd83..585bd7740d293b1b256c408d6c5d32a31912c1cd 100644 (file)
@@ -26,7 +26,7 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
 
        public String toString() {
                String  name = getName();
-               if (name == null)
+               if (name == null || "".equals(name))
                        name = "Altus Metrum";
                return String.format("%-20.20s %4d %s",
                                     name, getSerial(), getPath());
@@ -34,7 +34,7 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
 
        public String toShortString() {
                String  name = getName();
-               if (name == null)
+               if (name == null || "".equals(name))
                        name = "Altus Metrum";
                return String.format("%s %d %s",
                                     name, getSerial(), getPath());
index 33c5587b9c2217c45657fae4bc924efaaab93159..7e3d1e593dfc6658d737902ec5546afecdffb905 100644 (file)
@@ -224,7 +224,7 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList
                this.owner = owner;
                this.device = device;
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                c = new GridBagConstraints();
index 7c5d186e9864728f5b959b69e594e21c69314768..465916ec81ea0c2efebdc26cef86f9ede96c81f9 100644 (file)
@@ -211,7 +211,7 @@ public class TeleGPSConfigUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                /* Product */