From: Reino Ruusu Date: Mon, 9 Nov 2020 10:51:12 +0000 (+0200) Subject: Fix NPEs in tech type command handlers' canExecute() X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fdistrict.git;a=commitdiff_plain;h=669fec715190918badd9d4f90575a6b703aa6b9f Fix NPEs in tech type command handlers' canExecute() gitlab #93 Change-Id: Ib2ef00feadb6cd98bfacecfd3b0e2055c1767114 (cherry picked from commit b1e13119cdfa85f67fedf387cb9583898970f773) --- diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ResetComponentsHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ResetComponentsHandler.java index a95ecec4..8639fc07 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ResetComponentsHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ResetComponentsHandler.java @@ -16,7 +16,9 @@ public class ResetComponentsHandler { @CanExecute public boolean canExecute() { - return TechTypeTableView.table.getCurrentTable() != null; + return TechTypeTableView.table != null && + TechTypeTableView.table.getCurrentTable() != null && + TechTypeTableView.table.getComponentType() != null; } @Execute diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java index b18e10c8..7438269a 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java @@ -334,6 +334,10 @@ public class TechTypeTable extends Composite { super.dispose(); } + public Resource getComponentType() { + return this.componentType; + } + public void setComponentType(Resource componentType) { if (Objects.equals(this.componentType, componentType)) return; diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ValidateTechTypeTableHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ValidateTechTypeTableHandler.java index 8438fd7b..67998d9a 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ValidateTechTypeTableHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ValidateTechTypeTableHandler.java @@ -17,7 +17,9 @@ import org.simantics.utils.ui.ExceptionUtils; public class ValidateTechTypeTableHandler { @CanExecute public boolean canExecute() { - return TechTypeTableView.table.getCurrentTable() != null; + return TechTypeTableView.table != null && + TechTypeTableView.table.getCurrentTable() != null && + TechTypeTableView.table.getComponentType() != null; } @Execute