From cf17139567fbc4ec29dea2368a465423f6408ff2 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 16 Sep 2015 14:47:13 +0200 Subject: [client] SatList: fix NPE if user closes SatListW added nullcheck for generating radio button so that we can call it with null to force/fake a manual IP input field --- .../gui/window/layout/SatelliteListWindowLayout.java | 20 +++++++++++--------- .../org/openslx/dozmod/thrift/ThriftActions.java | 3 +-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/SatelliteListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/SatelliteListWindowLayout.java index ecfc8bbe..399a9241 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/SatelliteListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/SatelliteListWindowLayout.java @@ -39,16 +39,18 @@ public class SatelliteListWindowLayout extends JDialog { ButtonGroup btnGroup = new ButtonGroup(); // --------------- radio buttons sat selection -------------------------------------- - selectionPanelGrid.add(new JLabel("Vorgegebene Server"), 2); - selectionPanelGrid.nextRow(); - // create the radioButtons, add them to the map, button group and the selection grid. - for (Satellite sat : satList) { - JRadioButton radioButton = new JRadioButton(sat.getDisplayName()); - radioButton.setEnabled(sat.addressList != null && !sat.addressList.isEmpty()); - radioToSat.put(radioButton, sat); - btnGroup.add(radioButton); - selectionPanelGrid.add(radioButton, 2).fill(true, false).expand(true, false); + if (satList != null && !satList.isEmpty()) { + selectionPanelGrid.add(new JLabel("Vorgegebene Server"), 2); selectionPanelGrid.nextRow(); + // create the radioButtons, add them to the map, button group and the selection grid. + for (Satellite sat : satList) { + JRadioButton radioButton = new JRadioButton(sat.getDisplayName()); + radioButton.setEnabled(sat.addressList != null && !sat.addressList.isEmpty()); + radioToSat.put(radioButton, sat); + btnGroup.add(radioButton); + selectionPanelGrid.add(radioButton, 2).fill(true, false).expand(true, false); + selectionPanelGrid.nextRow(); + } } // --------------- end radio buttons for sat selection ------------------------------------ diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index b67b41b9..5a6f4566 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -109,7 +109,6 @@ public class ThriftActions { MessageType.ERROR, LOGGER, null); return false; } - // TODO: Show list if > 1 // Satellite sat = data.satellites.get(0); Satellite sat = null; if (data.satellites.size() == 1 && !LoginWindow.forceCustomSatellite) { @@ -118,7 +117,7 @@ public class ThriftActions { sat = SatelliteListWindow.open(window , data.satellites); } - if (sat.addressList == null) { + if (sat == null || sat.addressList == null) { // TODO: Ask for manual IP address entry Gui.asyncMessageBox( "Login erfolgreich, aber es wurde kein Satelliten-Server ausgewählt.\n" -- cgit v1.2.3-55-g7522