]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Contextual adapters must throw instead of returning null 52/4252/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 1 Jun 2020 15:11:13 +0000 (18:11 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 1 Jun 2020 16:10:14 +0000 (16:10 +0000)
gitlab #540

Change-Id: I98cb667afcc6e54d41afc6c0a25051c5ee7b49b3
(cherry picked from commit 4e8f62e4f5a8da113ee576a856b18274ca2a472f)

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/ObtainedDoubleAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/ObtainedColorAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/ObtainedExpressionAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/ObtainedFontAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/ObtainedFormatterAdapter.java

index 79f32fcd2fee1e144bdd89e25e4317ecfdfc5ff7..ff257169ca01e1272b57e62ff1dd259d82aa6601 100644 (file)
@@ -20,6 +20,7 @@ import org.simantics.db.RelationContext;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.property.OrderedResource;
 import org.simantics.operation.Layer0X;
@@ -46,7 +47,7 @@ public class ObtainedDoubleAdapter extends SimpleContextualAdapter<Double, Relat
                 return result;
         }
 
-        return null;
+        throw new AdaptionException("No obtained double available");
     }
 
 }
index 21c8208644c1d56a10a2337d7f22ec6a533b1b85..acb2581106e54640f0028af1211c2bf5ea9796e5 100644 (file)
@@ -10,6 +10,7 @@ import org.simantics.db.RelationContext;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.property.OrderedResource;
 import org.simantics.diagram.stubs.DiagramResource;
@@ -34,7 +35,7 @@ public class ObtainedColorAdapter extends SimpleContextualAdapter<Color, Relatio
                        if(result != null) return result;
                }
                
-               return null;
+               throw new AdaptionException("No obtained color available");
                
        }
 
index 2d136e8abfbb1d942c44f5daa14f34da6d1d3c78..71988116da9782cd66ee8565ebbe31ce170b87a3 100644 (file)
@@ -9,6 +9,7 @@ import org.simantics.db.RelationContext;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.property.OrderedResource;
 import org.simantics.operation.Layer0X;
@@ -31,7 +32,7 @@ public class ObtainedExpressionAdapter extends SimpleContextualAdapter<String, R
                        if(result != null) return result;
                }
                
-               return null;
+               throw new AdaptionException("No obtained expression available");
                
        }
 
index cbb91402042645b659233146479b9859dc8c5b14..1c7d1d823720ce48499a959a28944a846736a1c1 100644 (file)
@@ -9,6 +9,7 @@ import org.simantics.db.RelationContext;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.property.OrderedResource;
 import org.simantics.diagram.stubs.DiagramResource;
@@ -34,7 +35,7 @@ public class ObtainedFontAdapter extends SimpleContextualAdapter<FontDescriptor,
                        if(result != null) return result;
                }
                
-               return null;
+               throw new AdaptionException("No obtained font available");
                
        }
 
index d8bd993bd40cec57c5ea621b2d5efce4d500016c..3f0200c961ecfbe34c4bcc82123c9f95d08a8305 100644 (file)
@@ -10,6 +10,7 @@ import org.simantics.db.RelationContext;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.property.OrderedResource;
 import org.simantics.diagram.stubs.DiagramResource;
@@ -34,7 +35,7 @@ public class ObtainedFormatterAdapter extends SimpleContextualAdapter<Formatter,
                        if(result != null) return result;
                }
                
-               return null;
+               throw new AdaptionException("No obtained formatter available");
                
        }