]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
BrowseContext creation fails when including invalid contributions 63/3763/1
authorAntti Villberg <antti.villberg@semantum.fi>
Thu, 9 Jan 2020 09:44:36 +0000 (11:44 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Thu, 9 Jan 2020 09:44:36 +0000 (11:44 +0200)
gitlab #439

Change-Id: Ie985db8ac57c43c081a77df390c48e7b32c1042f

bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java

index 42ac584209e721dafcffc5d6b9a24e650445fde2..c4f8c26829081fa290a6df3cd35549817f6d3439 100644 (file)
@@ -57,6 +57,7 @@ import org.simantics.browsing.ui.model.visuals.VisualsContribution;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
+import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ResourceNotFoundException;
 import org.simantics.db.layer0.variable.Variable;
@@ -125,24 +126,32 @@ public class BrowseContext {
             
             for(Resource childContributionResource : 
                 g.getObjects(browseContextResource, vr.BrowseContext_HasChildContribution)) {
-                ChildContribution contribution = ChildContribution.create(g, childContributionResource);
-                browseContext.childContributions.put(contribution.getParentNodeType(), contribution);
-                browseContext.parentContributions.put(contribution.getChildNodeType(), contribution);
+                try {
+                    ChildContribution contribution = ChildContribution.create(g, childContributionResource);
+                    browseContext.childContributions.put(contribution.getParentNodeType(), contribution);
+                    browseContext.parentContributions.put(contribution.getChildNodeType(), contribution);
+                } catch (DatabaseException e) {
+                    LOGGER.error("Failed to load child contribution " + NameUtils.getSafeName(g, childContributionResource), e);
+                }
             }
             
             for(Resource visualsContributionResource : 
                 g.getObjects(browseContextResource, vr.BrowseContext_HasVisualsContribution)) {
-                VisualsContribution.load(g, visualsContributionResource,
-                        browseContext.labelContributions,
-                        browseContext.imageContributions,
-                        browseContext.checkedStateContributions,
-                        browseContext.labelDecorationContributions,
-                        browseContext.imageDecorationContributions,
-                        browseContext.modifierContributions,
-                        browseContext.sorterContributions,
-                        browseContext.flatNodeContributions,
-                        browseContext.tooltipContributions
+                try {
+                    VisualsContribution.load(g, visualsContributionResource,
+                            browseContext.labelContributions,
+                            browseContext.imageContributions,
+                            browseContext.checkedStateContributions,
+                            browseContext.labelDecorationContributions,
+                            browseContext.imageDecorationContributions,
+                            browseContext.modifierContributions,
+                            browseContext.sorterContributions,
+                            browseContext.flatNodeContributions,
+                            browseContext.tooltipContributions
                         );
+                } catch (DatabaseException e) {
+                    LOGGER.error("Failed to load visuals contribution " + NameUtils.getSafeName(g, visualsContributionResource), e);
+                }
             }
         }
         //browseContext.visualize();