X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FDisplayPropertyVariableAdapter.java;h=6c05005b2fba18ebb300810f7dbb6aa2a9278551;hb=d2eef7b7d919a2463438dd0f8106f55fa245a9f2;hp=a0e30e994e6058957af239686b4b223b4b6d023c;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/DisplayPropertyVariableAdapter.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/DisplayPropertyVariableAdapter.java index a0e30e994..6c05005b2 100644 --- a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/DisplayPropertyVariableAdapter.java +++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/DisplayPropertyVariableAdapter.java @@ -1,35 +1,35 @@ -package org.simantics.selectionview; - -import org.simantics.databoard.Datatypes; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.adaption.SimpleContextualAdapter; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.ConstantValueStandardGraphPropertyVariable; -import org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; - -public class DisplayPropertyVariableAdapter extends SimpleContextualAdapter { - - public String getDisplayProperty(ReadGraph graph, Variable property) throws DatabaseException { - Resource predicate = property.getPossiblePredicateResource(graph); - if(predicate == null) return property.getName(graph); - return Variables.getVariable(graph, graph.getURI(predicate)).getLabel(graph); -// Variable predicate = property.getPossiblePropertyValue(graph, Variables.PREDICATE); -// if(predicate == null) return property.getName(graph); -// else return predicate.getPropertyValue(graph, Variables.LABEL); - } - - @Override - public Variable adapt(ReadGraph graph, Resource source, ModelledVariablePropertyDescriptor context) throws DatabaseException { - - String value = getDisplayProperty(graph, context.getVariable()); - return new ConstantValueStandardGraphPropertyVariable(graph, context.getVariable(), - context.getSubject(), - SelectionViewResources.getInstance(graph).HasDisplayProperty, - value != null ? value : "", Datatypes.STRING); - - } - -} +package org.simantics.selectionview; + +import org.simantics.databoard.Datatypes; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.adaption.SimpleContextualAdapter; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.ConstantValueStandardGraphPropertyVariable; +import org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; + +public class DisplayPropertyVariableAdapter extends SimpleContextualAdapter { + + public String getDisplayProperty(ReadGraph graph, Variable property) throws DatabaseException { + Resource predicate = property.getPossiblePredicateResource(graph); + if(predicate == null) return property.getName(graph); + return Variables.getVariable(graph, graph.getURI(predicate)).getLabel(graph); +// Variable predicate = property.getPossiblePropertyValue(graph, Variables.PREDICATE); +// if(predicate == null) return property.getName(graph); +// else return predicate.getPropertyValue(graph, Variables.LABEL); + } + + @Override + public Variable adapt(ReadGraph graph, Resource source, ModelledVariablePropertyDescriptor context) throws DatabaseException { + + String value = getDisplayProperty(graph, context.getVariable()); + return new ConstantValueStandardGraphPropertyVariable(graph, context.getVariable(), + context.getSubject(), + SelectionViewResources.getInstance(graph).HasDisplayProperty, + value != null ? value : "", Datatypes.STRING); + + } + +}