From b1e13119cdfa85f67fedf387cb9583898970f773 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 9 Nov 2020 12:51:12 +0200 Subject: [PATCH] Fix NPEs in tech type command handlers' canExecute() gitlab #93 Change-Id: Ib2ef00feadb6cd98bfacecfd3b0e2055c1767114 --- .../network/ui/techtype/table/ResetComponentsHandler.java | 4 +++- .../district/network/ui/techtype/table/TechTypeTable.java | 4 ++++ .../ui/techtype/table/ValidateTechTypeTableHandler.java | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) 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 -- 2.47.1