DIA.ExpressionStyle <T DIA.Style
DIA.SCLTextGridStyle <T DIA.Style
- >-- DIA.SCLTextGridStyle.function ==> "Variable -> <ReadGraph> String" <R L0.HasProperty : L0.TotalFunction
+ >-- DIA.SCLTextGridStyle.texts ==> "Variable -> <ReadGraph> (String,String,String)" <R L0.HasProperty : L0.TotalFunction
DIA.SCLTextStyle <T DIA.Style
DIA.BasicExpressionTextStyle <T DIA.Style
// TODO: this .pgraph shouldn't be here, but in a separate "UI" ontology
BC.Entry : VP.ResourceNodeType
- VP.HasContentType "org.simantics.diagram.profile.view.ResourcePair"
+ VP.HasContentType "org.simantics.diagram.profile.view.ProfileTuple"
VP.HasBundle "org.simantics.diagram.profile"
BC.EntryLabelRule : VP.LabelRule
BC.EntryImageRule : VP.ImageRule
import org.simantics.db.layer0.adapter.Instances;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.service.VirtualGraphSupport;
-import org.simantics.diagram.profile.view.ResourcePair;
+import org.simantics.diagram.profile.view.ProfileTuple;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
final Resource runtimeDiagram = (Resource)explorer.getRoot().getConstant(BuiltinKeys.INPUT);
final boolean checked = item.getChecked();
NodeContext context = (NodeContext)item.getData();
- final ResourcePair entry = (ResourcePair)context.getConstant(BuiltinKeys.INPUT);
+ final ProfileTuple entry = (ProfileTuple)context.getConstant(BuiltinKeys.INPUT);
try {
VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
DiagramResource DIA = DiagramResource.getInstance(graph);
Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
- processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getSecond(), checked);
+ processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getEntry(), checked);
}
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.scenegraph.profile.ProfileUtils;
-public class DirectProfileEntries extends UnaryRead<ResourcePair, List<ResourcePair>> {
+public class DirectProfileEntries extends UnaryRead<ProfileTuple, List<ProfileTuple>> {
- public DirectProfileEntries(ResourcePair resource) {
- super(resource);
+ public DirectProfileEntries(ProfileTuple tuple) {
+ super(tuple);
}
@Override
- public List<ResourcePair> perform(ReadGraph graph) throws DatabaseException {
+ public List<ProfileTuple> perform(ReadGraph graph) throws DatabaseException {
DiagramResource dr = DiagramResource.getInstance(graph);
- ArrayList<ResourcePair> entries = new ArrayList<ResourcePair>();
- Resource list = graph.getPossibleObject(parameter.getSecond(), dr.HasEntries);
+ List<ProfileTuple> entries = new ArrayList<>();
+ Resource list = graph.getPossibleObject(parameter.getEntry(), dr.HasEntries);
if(list == null) return entries;
for(Resource entry : ProfileUtils.getProfileChildrenFromEntries(graph, list)) {
- entries.add(new ResourcePair(parameter.getFirst(), entry));
+ entries.add(new ProfileTuple(parameter.getBaseProfile(), entry, parameter.getRuntimeDiagram()));
}
return entries;
}
import org.simantics.db.ReadGraph;
import org.simantics.db.exception.DatabaseException;
-public class EntryLabeler extends LabelerContributor<ResourcePair> {
+public class EntryLabeler extends LabelerContributor<ProfileTuple> {
@Override
- public String getLabel(ReadGraph graph, ResourcePair entry) throws DatabaseException {
- return graph.adapt(entry.getSecond(), String.class);
+ public String getLabel(ReadGraph graph, ProfileTuple entry) throws DatabaseException {
+ return graph.adapt(entry.getEntry(), String.class);
}
}
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.scenegraph.profile.ProfileUtils;
import org.simantics.scenegraph.profile.request.ProfileActiveEntryResources;
import org.simantics.scenegraph.profile.request.ProfileEntryResources;
-import org.simantics.simulation.ontology.SimulationResource;
public class ProfileCheckContributor implements CheckedStateRule {
@Override
public boolean isCompatible(Class<?> contentType) {
- return contentType.equals(ResourcePair.class);
+ return contentType.equals(ProfileTuple.class);
}
@Override
public CheckedState getCheckedState(ReadGraph graph, Object parent)
throws DatabaseException {
- ResourcePair entry = (ResourcePair)parent;
- Resource activeProfile = entry.getFirst();
+ ProfileTuple tuple = (ProfileTuple)parent;
+ Resource activeProfile = tuple.getBaseProfile();
+ Resource entry = tuple.getEntry();
DiagramResource DIA = DiagramResource.getInstance(graph);
- SimulationResource SIMU = SimulationResource.getInstance(graph);
- if(graph.isInstanceOf(entry.getSecond(), DIA.Profile)) {
- Resource list = graph.getPossibleObject(entry.getSecond(), DIA.HasEntries);
+ if(graph.isInstanceOf(entry, DIA.Profile)) {
+ Resource list = graph.getPossibleObject(entry, DIA.HasEntries);
Collection<Resource> activeEntries = graph.syncRequest( new ProfileActiveEntryResources(activeProfile, list) );
if (activeEntries.isEmpty()) {
return CheckedState.NOT_CHECKED;
Collection<Resource> entries = graph.syncRequest( new ProfileEntryResources(activeProfile, list) );
return entries.equals(activeEntries) ? CheckedState.CHECKED : CheckedState.GRAYED;
}
-
- } else if(graph.isInstanceOf(entry.getSecond(), DIA.ProfileEntry)) {
- if(graph.hasStatement(activeProfile, SIMU.IsActive, entry.getSecond())) return CheckedState.CHECKED;
}
+ if(ProfileUtils.isActive(graph, tuple.getRuntimeDiagram(), activeProfile, entry)) return CheckedState.CHECKED;
+
return CheckedState.NOT_CHECKED;
}
import org.simantics.browsing.ui.model.children.ChildRule;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
-import org.simantics.db.common.utils.ListUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.scenegraph.profile.ProfileUtils;
@Override
public boolean isCompatible(Class<?> contentType) {
- return contentType.equals(ResourcePair.class);
+ return contentType.equals(ProfileTuple.class);
}
@Override
public Collection<?> getChildren(ReadGraph graph, Object parent)
throws DatabaseException {
-
- ResourcePair entry = (ResourcePair)parent;
- ArrayList<ResourcePair> entries = new ArrayList<ResourcePair>();
- DiagramResource DIA = DiagramResource.getInstance(graph);
- Resource children = graph.getPossibleObject(entry.getSecond(), DIA.HasEntries);
- if(children == null) return Collections.emptyList();
- else {
- for(Resource entry2 : ProfileUtils.getProfileChildrenFromEntries(graph, children)) entries.add(new ResourcePair(entry.getFirst(), entry2));
- return entries;
- }
- }
+ ProfileTuple entry = (ProfileTuple) parent;
+ ArrayList<ProfileTuple> entries = new ArrayList<>();
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ Resource children = graph.getPossibleObject(entry.getEntry(), DIA.HasEntries);
+ if (children != null) {
+ for (Resource entry2 : ProfileUtils.getProfileChildrenFromEntries(graph, children))
+ entries.add(new ProfileTuple(entry.getBaseProfile(), entry2, entry.getRuntimeDiagram()));
+ return entries;
+ }
+ return Collections.emptyList();
+ }
@Override
public Collection<?> getParents(ReadGraph graph, Object child)
throws DatabaseException {
- return new ArrayList<Resource>();
+ return Collections.emptyList();
}
}
public class ProfileEntrySelectionListener implements Listener {
- public void processRecursively(WriteGraph graph, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException {
+ public void processRecursively(WriteGraph graph, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException {
+ DiagramResource DIA = DiagramResource.getInstance(graph);
- DiagramResource DIA = DiagramResource.getInstance(graph);
-
- if(graph.isInstanceOf(entry, DIA.Profile)) {
-
- for(Resource child : ProfileUtils.getProfileChildren(graph, entry)) {
- processRecursively(graph, runtimeProfile, child, checked);
- }
-
- } else if(graph.isInstanceOf(entry, DIA.ProfileEntry)) {
-
- if(checked) {
+ if (graph.isInstanceOf(entry, DIA.Profile)) {
+ for (Resource child : ProfileUtils.getProfileChildren(graph, entry)) {
+ processRecursively(graph, runtimeProfile, child, checked);
+ }
+ } else if (graph.isInstanceOf(entry, DIA.ProfileEntry)) {
+ if (checked) {
graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry);
} else {
graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry);
}
+ }
+ }
- }
-
- }
-
@Override
public void handleEvent (Event event) {
-
if(event.detail == SWT.CHECK) {
-
final TreeItem item = (TreeItem)event.item;
Tree tree = item.getParent();
GraphExplorer explorer = (GraphExplorer)tree.getData(GraphExplorer.KEY_GRAPH_EXPLORER);
final Resource runtimeDiagram = (Resource)explorer.getRoot().getConstant(BuiltinKeys.INPUT);
final boolean checked = item.getChecked();
NodeContext context = (NodeContext)item.getData();
- final ResourcePair entry = (ResourcePair)context.getConstant(BuiltinKeys.INPUT);
+ final ProfileTuple entry = (ProfileTuple)context.getConstant(BuiltinKeys.INPUT);
try {
-
VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
Simantics.getSession().syncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) {
@Override
public void perform(WriteGraph graph) throws DatabaseException {
-
- DiagramResource DIA = DiagramResource.getInstance(graph);
- Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
- processRecursively(graph, runtimeProfile, entry.getSecond(), checked);
-
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
+ processRecursively(graph, runtimeProfile, entry.getEntry(), checked);
}
});
public Collection<?> process(Object selection, ReadGraph g) {
try {
Resource object = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, Resource.class);
- ResourcePair object2 = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, ResourcePair.class);
+ ProfileTuple object2 = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, ProfileTuple.class);
return processInternal(g, object, object2, selection);
return Collections.emptyList();
}
- private Collection<?> processInternal(ReadGraph g, Resource object, ResourcePair pair, Object selection) throws DatabaseException {
+ private Collection<?> processInternal(ReadGraph g, Resource object, ProfileTuple pair, Object selection) throws DatabaseException {
Collection<Object> inputs = new ArrayList<Object>();
return result;
}
- private void parseResourceInput(ReadGraph g, Resource part, ResourcePair pair, Collection<Object> inputs) throws DatabaseException {
+ private void parseResourceInput(ReadGraph g, Resource part, ProfileTuple pair, Collection<Object> inputs) throws DatabaseException {
getGroups(g, part, pair, inputs);
}
- void getGroups(ReadGraph g, Resource r, ResourcePair p, Collection<Object> result) throws DatabaseException {
+ void getGroups(ReadGraph g, Resource r, ProfileTuple p, Collection<Object> result) throws DatabaseException {
DiagramResource dr = DiagramResource.getInstance(g);
if (r != null && g.isInstanceOf(r, dr.SCLGroup)) {
result.add(new SCLInput(r, 1, "SCL Group"));
if (r != null && g.isInstanceOf(r, dr.SCLTextStyle)) {
result.add(new SCLInput(r, 2, "SCL Text Style"));
}
- if (p != null && g.isInstanceOf(p.getSecond(), dr.GroupStyleProfileEntry)) {
- Resource group = g.getPossibleObject(p.getSecond(), dr.ProfileEntry_HasGroup);
+ if (p != null && g.isInstanceOf(p.getEntry(), dr.GroupStyleProfileEntry)) {
+ Resource group = g.getPossibleObject(p.getEntry(), dr.ProfileEntry_HasGroup);
if (group != null && g.isInstanceOf(group, dr.SCLGroup)) {
result.add(new SCLInput(group, 1, "SCL Group"));
}
- Resource style = g.getPossibleObject(p.getSecond(), dr.ProfileEntry_HasStyle);
+ Resource style = g.getPossibleObject(p.getEntry(), dr.ProfileEntry_HasStyle);
if (style != null && g.isInstanceOf(style, dr.SCLTextStyle)) {
result.add(new SCLInput(style, 2, "SCL Text Style"));
}
--- /dev/null
+package org.simantics.diagram.profile.view;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.simantics.db.Resource;
+import org.simantics.utils.datastructures.map.Tuple;
+
+public class ProfileTuple extends Tuple implements IAdaptable {
+
+ ProfileTuple(Resource baseProfile, Resource entry, Resource runtimeDiagram) {
+ super(baseProfile, entry, runtimeDiagram);
+ }
+
+ public Resource getBaseProfile() { return (Resource) getField(0); }
+ public Resource getEntry() { return (Resource) getField(1); }
+ public Resource getRuntimeDiagram() { return (Resource) getField(2); }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ if (adapter == Resource.class) {
+ return (T) getEntry();
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
public void run(Resource runtimeDiagram) {
ISelection selection = getParameter(DiagramResource.URIs.ProfilesView_SelectedEntries);
- final List<ResourcePair> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ResourcePair.class);
+ final List<ProfileTuple> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ProfileTuple.class);
if(selectedEntries != null && !selectedEntries.isEmpty()) {
- System.err.println("RemoveEntriesAction has " + selection + " for " + runtimeDiagram);
try {
Simantics.getSession().syncRequest(new WriteRequest() {
public void perform(WriteGraph graph) throws DatabaseException {
DiagramResource DIA = DiagramResource.getInstance(graph);
- for(ResourcePair entry : selectedEntries) {
- Resource list = graph.getPossibleObject(entry.getFirst(), DIA.HasEntries);
- OrderedSetUtils.remove(graph, list, entry.getSecond());
+ for(ProfileTuple entry : selectedEntries) {
+ Resource list = graph.getPossibleObject(entry.getBaseProfile(), DIA.HasEntries);
+ OrderedSetUtils.remove(graph, list, entry.getEntry());
}
}
+++ /dev/null
-package org.simantics.diagram.profile.view;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.simantics.db.Resource;
-import org.simantics.utils.datastructures.map.Tuple;
-
-public class ResourcePair extends Tuple implements IAdaptable{
- ResourcePair(Resource first, Resource second) { super(first ,second); }
- public Resource getFirst() { return (Resource) getField(0); }
- public Resource getSecond() { return (Resource) getField(1); }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == Resource.class) {
- return getSecond();
- }
- return null;
- }
-
-
-}
\ No newline at end of file
@Override
public boolean isCompatible(Class<?> contentType) {
- return contentType.equals(ResourcePair.class);
+ return contentType.equals(ProfileTuple.class);
}
@Override
public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
- ImageDescriptorProvider provider = graph.getPossibleAdapter(((ResourcePair)content).getSecond(), ImageDescriptorProvider.class);
+ ImageDescriptorProvider provider = graph.getPossibleAdapter(((ProfileTuple)content).getEntry(), ImageDescriptorProvider.class);
return provider != null ? Collections.singletonMap(ColumnKeys.SINGLE, provider.get()) : null;
}
@Override
public boolean isCompatible(Class<?> contentType) {
- return contentType.equals(ResourcePair.class);
+ return contentType.equals(ProfileTuple.class);
}
@Override
public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
return Collections.singletonMap(ColumnKeys.SINGLE,
- NameUtils.getSafeLabel(graph, ((ResourcePair)content).getSecond())
+ NameUtils.getSafeLabel(graph, ((ProfileTuple)content).getEntry())
);
}
}
DiagramResource dr = DiagramResource.getInstance(graph);
Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, dr.RuntimeDiagram_HasRuntimeProfile);
if(runtimeProfile == null) return Collections.emptyList();
- return graph.syncRequest(new DirectProfileEntries(new ResourcePair(runtimeProfile, runtimeProfile)));
+ return graph.syncRequest(new DirectProfileEntries(new ProfileTuple(runtimeProfile, runtimeProfile, runtimeDiagram)));
}
<type
uri="http://www.simantics.org/Diagram-0.0/SCLTextGridStyle"
class="org.simantics.diagram.profile.SCLTextGridStyle">
+ <graph />
<this />
</type>
</target>
package org.simantics.diagram.profile;
+import java.awt.Font;
import java.awt.geom.AffineTransform;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Locale;
import org.simantics.Simantics;
-import org.simantics.common.format.Formatter;
import org.simantics.databoard.Bindings;
import org.simantics.datatypes.literal.Vec2d;
import org.simantics.db.ReadGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
+import org.simantics.diagram.G2DUtils;
import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.diagram.stubs.G2DResource;
import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
import org.simantics.modeling.ModelingResources;
import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.tuple.Tuple3;
import org.simantics.utils.datastructures.Pair;
/**
public class SCLTextGridStyle extends TextGridStyle {
final Resource style;
+ final Font font;
- public SCLTextGridStyle(Resource style) {
+ public SCLTextGridStyle(ReadGraph graph, Resource style) throws DatabaseException {
this.style = style;
+ G2DResource G2D = G2DResource.getInstance(graph);
+ Resource fontR = graph.getPossibleObject(style, G2D.HasFont);
+ if(fontR != null) {
+ font = G2DUtils.getFont(graph, fontR);
+ } else {
+ font = null;
+ }
+
+ }
+
+ @Override
+ protected Font getFont() {
+ if(font != null) return font;
+ return super.getFont();
}
@Override
return null;
Variable styleVariable = Variables.getVariable(graph, style);
- Function1<Variable,String> function = styleVariable.getPossiblePropertyValue(graph, "function");
- String result = Simantics.applySCLRead(graph, function, moduleVariable);
-
+ Function1<Variable,Tuple3> function = styleVariable.getPossiblePropertyValue(graph, DIA.SCLTextGridStyle_texts);
+ Tuple3 result = Simantics.applySCLRead(graph, function, moduleVariable);
+
AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, element);
Vec2d offset = DiagramGraphUtil.getOffset(graph, element);
boolean enabled = !DiagramGraphUtil.getProfileMonitorsHidden(graph, element);
boolean up = DiagramGraphUtil.getProfileMonitorsUp(graph, element);
double spacing = DiagramGraphUtil.getProfileMonitorSpacing(graph, element);
- return new MonitorTextGridResult(rowId(), result, "", "", enabled, up, spacing, null, null, ElementTranslation.function(element), transform, offset);
+ return new MonitorTextGridResult(rowId(), (String)result.c0, (String)result.c1, (String)result.c2, enabled, up, spacing, null, null, ElementTranslation.function(element), transform, offset);
}
String name = graph.getPossibleRelatedValue(config, getPropertyRelation(graph,element), Bindings.STRING);
return name;
}
-
+
public AffineTransform getTransform(INode node, AffineTransform parentTransform, Rectangle2D elementBounds, int location, boolean up) {
return getTransform(parentTransform, elementBounds, location, up);
}
at.scale(0.15, 0.15);
return at;
-
+
}
protected String rowId() {
String value2 = result != null ? result.getText2() : null;
String value3 = result != null ? result.getText3() : null;
-
+
double spacing = result.getSpacing();
final Function1<String, String> modifier = result != null ? result.getModifier() : null;
node.setCache(1, row, result);
boolean isConnection = _node instanceof ConnectionNode;
-
+
Rectangle2D elementBounds = isConnection ? EMPTY_BOUNDS : NodeUtil.getLocalElementBounds(_node);
if(elementBounds == null) {
new Exception("Cannot get local element bounds for node " + _node.toString()).printStackTrace();
Vec2d offset = result.getOffset();
Point2D[] cellOffsets = getCellOffsets();
-
+
AffineTransform at1 = new AffineTransform(at);
at1.translate(cellOffsets[0].getX(),cellOffsets[0].getY());
AffineTransform at2 = new AffineTransform(at);
at2.translate(cellOffsets[1].getX()+spacing,cellOffsets[1].getY());
AffineTransform at3 = new AffineTransform(at);
at3.translate(cellOffsets[2].getX()+spacing,cellOffsets[2].getY());
-
+
at1.translate(offset.x, offset.y);
at2.translate(offset.x, offset.y);
at3.translate(offset.x, offset.y);
node.setHorizontalAlignment(2, row, (byte) getAlignment(2).ordinal());
node.setHorizontalAlignment(3, row, (byte) getAlignment(3).ordinal());
}
-
+
Alignment[] verticalAlignments = result.getVerticalAlignments();
if(verticalAlignments != null) {
node.setVerticalAlignment(1, row, (byte) verticalAlignments[0].ordinal());
node.setZIndex(3000);
org.simantics.common.color.Color color = result.getColor();
- java.awt.Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+ Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+ Color bgColor = getBackgroundColor();
+ Font font = getFont();
- setTextNodeData(node, 1, row, value, FONT, awtColor, BACKGROUND_COLOR);
- setTextNodeData(node, 2, row, value2, result.getPending(), FONT, awtColor, BACKGROUND_COLOR);
- setTextNodeData(node, 3, row, value3, FONT, awtColor, BACKGROUND_COLOR);
+ setTextNodeData(node, 1, row, value, font, awtColor, bgColor);
+ setTextNodeData(node, 2, row, value2, result.getPending(), font, awtColor, bgColor);
+ setTextNodeData(node, 3, row, value3, font, awtColor, bgColor);
node.setEditable(1, row, false);
node.setForceEventListening(2, row, true);
node.setInputValidator(2, row, validator);
node.setTranslator(translator);
-
+
node.setRVI(2, row, rvi);
postProcessNode(node, row);
node.setPending(x, y, pending);
}
+ protected Font getFont() {
+ return FONT;
+ }
+
+ protected Color getBackgroundColor() {
+ return BACKGROUND_COLOR;
+ }
+
protected Alignment getAlignment(int column) {
switch(column) {
case 1: return Alignment.TRAILING;
G2D.IsVisible <R L0.HasProperty : L0.FunctionalRelation
--> L0.Boolean
+
+G2D.fontProperty : L0.Template
+ @template %subject %predicate %family %size %style
+ %subject
+ %predicate _ : G2D.Font
+ G2D.HasFontFamily %family
+ G2D.HasFontSize %size
+ G2D.HasFontStyle %style
+
+G2D.font : L0.Template
+ @template %subject %family %size %style
+ %subject : G2D.Font
+ G2D.HasFontFamily %family
+ G2D.HasFontSize %size
+ G2D.HasFontStyle %style
+
+
\ No newline at end of file
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
-import org.simantics.scenegraph.profile.request.ProfileActiveEntryResources;
+import org.simantics.simulation.ontology.SimulationResource;
public class ProfileUtils {
if(profile.equals(ref)) return state;
}
return null;
-
+
}
-
+
public static Resource claimProfileActivationState(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(graph);
DiagramResource DIA = DiagramResource.getInstance(graph);
graph.claim(indexRoot, L0.ConsistsOf, state);
return state;
}
-
-
+
+ public static boolean isActive(ReadGraph graph, Resource runtimeDiagram, Resource profile, Resource entry) throws DatabaseException {
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ SimulationResource SIMU = SimulationResource.getInstance(graph);
+ if(graph.isInstanceOf(entry, DIA.ProfileEntry)) {
+ if(graph.isImmutable(profile)) {
+ Resource state = getPossibleProfileActivationState(graph, runtimeDiagram, profile);
+ if(state != null && graph.hasStatement(state, SIMU.IsActive, entry)) return true;
+ } else {
+ if(graph.hasStatement(profile, SIMU.IsActive, entry)) return true;
+ }
+ }
+ return false;
+ }
+
}