]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fix NPEs in tech type command handlers' canExecute()
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 9 Nov 2020 10:51:12 +0000 (12:51 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 9 Nov 2020 13:14:27 +0000 (15:14 +0200)
gitlab #93

Change-Id: Ib2ef00feadb6cd98bfacecfd3b0e2055c1767114
(cherry picked from commit b1e13119cdfa85f67fedf387cb9583898970f773)

org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ResetComponentsHandler.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/ValidateTechTypeTableHandler.java

index a95ecec4fd62901a673a058e5cad5633f766b650..8639fc07214bbb699485fd7e68431789ac95daaf 100644 (file)
@@ -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
index b18e10c8d63f50c8971ef2fd90150ae783b37e69..7438269aba7071990b2b052cc21c539725d48d3d 100644 (file)
@@ -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;
index 8438fd7b3898cb0000cda112fa13a299549ea5c5..67998d9af63fb5fcc7364eae763b3b4352cbdfba 100644 (file)
@@ -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