1 package org.simantics.diagram.profile.view;
3 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
4 import org.simantics.databoard.Bindings;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.diagram.stubs.DiagramResource;
9 import org.simantics.layer0.Layer0;
10 import org.simantics.utils.strings.StringUtils;
12 public class SelectedProfile extends ReadFactoryImpl<Resource, String> {
15 public String perform(ReadGraph graph, Resource runtimeDiagram) throws DatabaseException {
16 Layer0 L0 = Layer0.getInstance(graph);
17 DiagramResource DIA = DiagramResource.getInstance(graph);
18 Resource profile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
19 if(profile == null) return null;
20 String name = graph.getPossibleRelatedValue(profile, L0.HasName, Bindings.STRING);
21 return StringUtils.safeString(name);