From 891197ba541eaf0244c1e3d613e2c81040b02dda Mon Sep 17 00:00:00 2001 From: MMaiero Date: Thu, 30 May 2024 14:15:49 +0200 Subject: [PATCH] fix: Additional fixes to prevent null references Signed-off-by: MMaiero --- .../client/ui/network/TabModemAntennaUi.java | 18 +++---- .../web/client/ui/network/TabModemGpsUi.java | 14 ++--- .../web/client/ui/network/TabWirelessUi.java | 51 +++++++++---------- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemAntennaUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemAntennaUi.java index 18c45ca164b..ec3178dc733 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemAntennaUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemAntennaUi.java @@ -218,16 +218,16 @@ private void update() { this.radio2.setValue(true); this.radio1.setValue(false); } + this.registration.setText(this.selectedModemIfConfig.getHwRegistration()); + this.imsi.setText(this.selectedModemIfConfig.getHwIMSI()); + this.iccid.setText(this.selectedModemIfConfig.getHwICCID()); + this.plmnid.setText(this.selectedModemIfConfig.getHwPLMNID()); + this.network.setText(this.selectedModemIfConfig.getHwNetwork()); + this.radio.setText(this.selectedModemIfConfig.getHwRadio()); + this.band.setText(this.selectedModemIfConfig.getHwBand()); + this.lac.setText(this.selectedModemIfConfig.getHwLAC()); + this.ci.setText(this.selectedModemIfConfig.getHwCI()); } - this.registration.setText(this.selectedModemIfConfig.getHwRegistration()); - this.imsi.setText(this.selectedModemIfConfig.getHwIMSI()); - this.iccid.setText(this.selectedModemIfConfig.getHwICCID()); - this.plmnid.setText(this.selectedModemIfConfig.getHwPLMNID()); - this.network.setText(this.selectedModemIfConfig.getHwNetwork()); - this.radio.setText(this.selectedModemIfConfig.getHwRadio()); - this.band.setText(this.selectedModemIfConfig.getHwBand()); - this.lac.setText(this.selectedModemIfConfig.getHwLAC()); - this.ci.setText(this.selectedModemIfConfig.getHwCI()); refreshForm(); } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemGpsUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemGpsUi.java index 226ccc03a8a..bfd9164c414 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemGpsUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabModemGpsUi.java @@ -176,12 +176,14 @@ private void update() { } private void refreshForm() { - if (this.selectedModemIfConfig.isGpsSupported()) { - this.radio1.setEnabled(true); - this.radio2.setEnabled(true); - } else { - this.radio1.setEnabled(false); - this.radio2.setEnabled(false); + if (this.selectedModemIfConfig != null) { + if (this.selectedModemIfConfig.isGpsSupported()) { + this.radio1.setEnabled(true); + this.radio2.setEnabled(true); + } else { + this.radio1.setEnabled(false); + this.radio2.setEnabled(false); + } } } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java index 1e69e023bc8..a55451e4dd2 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java @@ -809,7 +809,9 @@ private void reset() { this.radio2.setValue(true); this.radio4.setValue(true); - update(); + if (this.selectedNetIfConfig != null) { + update(); + } } private void initHelpButtons() { @@ -1774,37 +1776,34 @@ private void showPasswordVerificationStatus(String statusMessage) { } private void loadChannelFrequencies() { - if (this.selectedNetIfConfig != null) { - this.gwtXSRFService.generateSecurityToken(new AsyncCallback() { - - @Override - public void onFailure(Throwable ex) { - FailureHandler.handle(ex); - } + this.gwtXSRFService.generateSecurityToken(new AsyncCallback() { - @Override - public void onSuccess(GwtXSRFToken token) { - GwtWifiRadioMode radioMode = radioValueToRadioMode(TabWirelessUi.this.radio.getSelectedValue()); + @Override + public void onFailure(Throwable ex) { + FailureHandler.handle(ex); + } - TabWirelessUi.this.gwtNetworkService.findFrequencies(token, - TabWirelessUi.this.selectedNetIfConfig.getName(), radioMode, - new AsyncCallback>() { + @Override + public void onSuccess(GwtXSRFToken token) { + GwtWifiRadioMode radioMode = radioValueToRadioMode(TabWirelessUi.this.radio.getSelectedValue()); - @Override - public void onFailure(Throwable caught) { - logger.info("findFrequencies Failure"); - } + TabWirelessUi.this.gwtNetworkService.findFrequencies(token, + TabWirelessUi.this.selectedNetIfConfig.getName(), radioMode, + new AsyncCallback>() { - @Override - public void onSuccess(List freqChannels) { + @Override + public void onFailure(Throwable caught) { + logger.info("findFrequencies Failure"); + } - updateChannelListValues(freqChannels); + @Override + public void onSuccess(List freqChannels) { + updateChannelListValues(freqChannels); - } - }); - } - }); - } + } + }); + } + }); }