X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FVariablePropertyCategoryRule.java;fp=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FVariablePropertyCategoryRule.java;h=de2d2b57d3eb71f61a50290de1df4d2a24abc265;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=307c2e750f452c7348b13bb7a6bb93609013cb9e;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyCategoryRule.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyCategoryRule.java index 307c2e750..de2d2b57d 100644 --- a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyCategoryRule.java +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/VariablePropertyCategoryRule.java @@ -1,75 +1,75 @@ -package org.simantics.selectionview; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; - -import org.simantics.browsing.ui.model.children.ChildRule; -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.modeling.ModelingResources; - -public class VariablePropertyCategoryRule implements ChildRule { - - final private ArrayList requiredProperties = new ArrayList(); - final Resource rule; - - public VariablePropertyCategoryRule(ReadGraph graph, Resource rule) throws DatabaseException { - - ModelingResources MOD = ModelingResources.getInstance(graph); - for(Resource r : graph.getObjects(rule, MOD.ModelingBrowseContext_VariablePropertyRule_RequireProperty)) { - String name = graph.getValue(r, Bindings.STRING); - requiredProperties.add(name); - } - - this.rule = rule; - - } - - @Override - public boolean isCompatible(Class contentType) { - return contentType.equals(Variable.class); - } - - @Override - public Collection getChildren(ReadGraph graph, Object parent) throws DatabaseException { - - HashSet result = new HashSet(); - - props: for(Variable property : ((Variable)parent).getProperties(graph)) { - - for(String req : requiredProperties) { - if(property.getPossibleProperty(graph, req) == null) continue props; - } - - Variable info = property.getPossibleProperty(graph, SelectionVariables.PROPERTY_INFO); - if(info != null) { - - Variable special = SelectionViewUtils.getSpecialCategory(graph, rule, info); - if(special != null) info = special; - - Boolean hidden = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_HIDDEN, Bindings.BOOLEAN); - if(hidden != null && hidden) continue; - String name = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_NAME, Bindings.STRING); - if(name == null) continue; - String sortName = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_SORTING_NAME, Bindings.STRING); - result.add(new CategoryNodeImpl(name, sortName)); - - } - - } - - return result; - - } - - @Override - public Collection getParents(ReadGraph graph, Object child) - throws DatabaseException { - return null; - } - -} +package org.simantics.selectionview; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; + +import org.simantics.browsing.ui.model.children.ChildRule; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.modeling.ModelingResources; + +public class VariablePropertyCategoryRule implements ChildRule { + + final private ArrayList requiredProperties = new ArrayList(); + final Resource rule; + + public VariablePropertyCategoryRule(ReadGraph graph, Resource rule) throws DatabaseException { + + ModelingResources MOD = ModelingResources.getInstance(graph); + for(Resource r : graph.getObjects(rule, MOD.ModelingBrowseContext_VariablePropertyRule_RequireProperty)) { + String name = graph.getValue(r, Bindings.STRING); + requiredProperties.add(name); + } + + this.rule = rule; + + } + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Variable.class); + } + + @Override + public Collection getChildren(ReadGraph graph, Object parent) throws DatabaseException { + + HashSet result = new HashSet(); + + props: for(Variable property : ((Variable)parent).getProperties(graph)) { + + for(String req : requiredProperties) { + if(property.getPossibleProperty(graph, req) == null) continue props; + } + + Variable info = property.getPossibleProperty(graph, SelectionVariables.PROPERTY_INFO); + if(info != null) { + + Variable special = SelectionViewUtils.getSpecialCategory(graph, rule, info); + if(special != null) info = special; + + Boolean hidden = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_HIDDEN, Bindings.BOOLEAN); + if(hidden != null && hidden) continue; + String name = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_NAME, Bindings.STRING); + if(name == null) continue; + String sortName = info.getPossiblePropertyValue(graph, SelectionVariables.CATEGORY_SORTING_NAME, Bindings.STRING); + result.add(new CategoryNodeImpl(name, sortName)); + + } + + } + + return result; + + } + + @Override + public Collection getParents(ReadGraph graph, Object child) + throws DatabaseException { + return null; + } + +}