X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.debug.graphical%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fgraphical%2Fmodel%2FNodeData.java;h=a5b186496d8cfd61c41a6f7349601ea5acd51d26;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=17e6f12ca50ed2857d22d082358b0d8cc4217b76;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/model/NodeData.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/model/NodeData.java index 17e6f12ca..a5b186496 100644 --- a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/model/NodeData.java +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/model/NodeData.java @@ -1,81 +1,81 @@ -package org.simantics.debug.graphical.model; - -import java.util.ArrayList; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.debug.graphical.LabelingPreferences; -import org.simantics.layer0.Layer0; - -public class NodeData { - Resource resource; - String[] labels; - ArrayList statements = new ArrayList(); - - public NodeData(Resource resource) { - this.resource = resource; - } - - public String[] getLabels() { - return labels; - } - - public void updateData(ReadGraph g, LabelingPreferences pref) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(g); - - Resource name = null; - Resource label = null; - ArrayList types = new ArrayList(); - ArrayList tags = new ArrayList(); - - statements.clear(); - for(Statement stat : g.getStatements(resource, L0.IsWeaklyRelatedTo)) { - if(stat.getSubject().equals(resource)) { - Resource predicate = stat.getPredicate(); - if(predicate.equals(L0.InstanceOf)) - types.add(stat.getObject()); - else if(predicate.equals(L0.HasName)) - name = stat.getObject(); - else if(predicate.equals(L0.HasLabel)) - label = stat.getObject(); - else if(resource.equals(stat.getObject())) - tags.add(predicate); - else if(g.isSubrelationOf(predicate, L0.HasNext) || - g.isSubrelationOf(predicate, L0.HasPrevious)) - ; - else - statements.add(stat); - } - } - - { // Compute labels - ArrayList labels = new ArrayList(4); - labels.add("$" + resource.getResourceId()); - if(name != null) - labels.add((String)g.getValue(name, Bindings.STRING)); - if(label != null) - labels.add((String)g.getValue(label, Bindings.STRING)); - for(Resource type : types) - labels.add(": " + NameUtils.getSafeName(g, type)); - for(Resource tag : tags) - labels.add("TAG " + NameUtils.getSafeName(g, tag)); - this.labels = labels.toArray(new String[labels.size()]); - } - } - - public Resource getResource() { - return resource; - } - - public ArrayList getStatements() { - return statements; - } - - public void setStatements(ArrayList statements) { - this.statements = statements; - } -} +package org.simantics.debug.graphical.model; + +import java.util.ArrayList; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Statement; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.debug.graphical.LabelingPreferences; +import org.simantics.layer0.Layer0; + +public class NodeData { + Resource resource; + String[] labels; + ArrayList statements = new ArrayList(); + + public NodeData(Resource resource) { + this.resource = resource; + } + + public String[] getLabels() { + return labels; + } + + public void updateData(ReadGraph g, LabelingPreferences pref) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(g); + + Resource name = null; + Resource label = null; + ArrayList types = new ArrayList(); + ArrayList tags = new ArrayList(); + + statements.clear(); + for(Statement stat : g.getStatements(resource, L0.IsWeaklyRelatedTo)) { + if(stat.getSubject().equals(resource)) { + Resource predicate = stat.getPredicate(); + if(predicate.equals(L0.InstanceOf)) + types.add(stat.getObject()); + else if(predicate.equals(L0.HasName)) + name = stat.getObject(); + else if(predicate.equals(L0.HasLabel)) + label = stat.getObject(); + else if(resource.equals(stat.getObject())) + tags.add(predicate); + else if(g.isSubrelationOf(predicate, L0.HasNext) || + g.isSubrelationOf(predicate, L0.HasPrevious)) + ; + else + statements.add(stat); + } + } + + { // Compute labels + ArrayList labels = new ArrayList(4); + labels.add("$" + resource.getResourceId()); + if(name != null) + labels.add((String)g.getValue(name, Bindings.STRING)); + if(label != null) + labels.add((String)g.getValue(label, Bindings.STRING)); + for(Resource type : types) + labels.add(": " + NameUtils.getSafeName(g, type)); + for(Resource tag : tags) + labels.add("TAG " + NameUtils.getSafeName(g, tag)); + this.labels = labels.toArray(new String[labels.size()]); + } + } + + public Resource getResource() { + return resource; + } + + public ArrayList getStatements() { + return statements; + } + + public void setStatements(ArrayList statements) { + this.statements = statements; + } +}