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?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F4607%2F1;p=simantics%2Fdistrict.git Fix NPEs in tech type command handlers' canExecute() gitlab #93 Change-Id: Ib2ef00feadb6cd98bfacecfd3b0e2055c1767114 --- 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