@MOD.connection SYSDYN.IsHeadOf
SYSDYN.HasValveOrientation <R L0.HasProperty : L0.FunctionalRelation
- L0.HasRange L0.Boolean
+ L0.HasRange SYSDYN.Orientation
SYSDYN.Orientation <T L0.Entity
SYSDYN.Horizontal <T SYSDYN.Orientation
SYSDYN.Vertical <T SYSDYN.Orientation
+SYSDYN.HasTextLocation <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange SYSDYN.Location
+
+SYSDYN.Location <T L0.Entity
+SYSDYN.Left <T SYSDYN.Location
+SYSDYN.Right <T SYSDYN.Location
+SYSDYN.Top <T SYSDYN.Location
+SYSDYN.Bottom <T SYSDYN.Location
+SYSDYN.Center <T SYSDYN.Location
+
SYSDYN.ValveSymbol <T DIA.FontProvider <T DIA.ColorProvider
@MOD.defSymbol "Valve" SYSDYN.Valve
@L0.assert SYSDYN.Orientation SYSDYN.Horizontal
+ @L0.optionalProperty SYSDYN.HasTextLocation
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
@L0.orderedSet
public final Resource AvailableSharedFunctionLibraries;\r
public final Resource AvailableVariableIndexes;\r
public final Resource BasicExperiment;\r
+ public final Resource Bottom;\r
public final Resource Browser;\r
public final Resource Built$in_Functions;\r
public final Resource Built$in_Functions_Vensim_Functions;\r
public final Resource Built$in_Functions_interpolateFull;\r
public final Resource Built$in_Functions_xidz;\r
public final Resource Built$in_Functions_zidz;\r
+ public final Resource Center;\r
public final Resource Cloud;\r
public final Resource CloudSymbol;\r
public final Resource Configuration;\r
public final Resource HasStopTime_Inverse;\r
public final Resource HasTail;\r
public final Resource HasTailTerminal;\r
+ public final Resource HasTextLocation;\r
+ public final Resource HasTextLocation_Inverse;\r
public final Resource HasTolerance;\r
public final Resource HasTolerance_Inverse;\r
public final Resource HasUnit;\r
public final Resource IsTailOf;\r
public final Resource IsTailOfTerminal;\r
public final Resource IssueStyle;\r
+ public final Resource Left;\r
+ public final Resource Location;\r
public final Resource LookupExpression;\r
public final Resource ModelBrowser;\r
public final Resource Module;\r
public final Resource ReplacingEnumeration;\r
public final Resource ReplacingEnumeration_Inverse;\r
public final Resource Result;\r
+ public final Resource Right;\r
public final Resource SelectedSharedFunctionLibraries;\r
public final Resource SharedFunctionOntology;\r
public final Resource SharedModuleOntolofgy;\r
public final Resource SysdynModuleLibrary;\r
public final Resource SysdynOperationBrowser;\r
public final Resource SysdynTerminal;\r
+ public final Resource Top;\r
public final Resource UsedVariableIndexes;\r
public final Resource Validations;\r
public final Resource Validations_Dependencies;\r
public static final String AvailableSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/AvailableSharedFunctionLibraries";\r
public static final String AvailableVariableIndexes = "http://www.simantics.org/Sysdyn-1.1/AvailableVariableIndexes";\r
public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.1/BasicExperiment";\r
+ public static final String Bottom = "http://www.simantics.org/Sysdyn-1.1/Bottom";\r
public static final String Browser = "http://www.simantics.org/Sysdyn-1.1/Browser";\r
public static final String Built$in_Functions = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions";\r
public static final String Built$in_Functions_Vensim_Functions = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions";\r
public static final String Built$in_Functions_interpolateFull = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/interpolateFull";\r
public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz";\r
public static final String Built$in_Functions_zidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/zidz";\r
+ public static final String Center = "http://www.simantics.org/Sysdyn-1.1/Center";\r
public static final String Cloud = "http://www.simantics.org/Sysdyn-1.1/Cloud";\r
public static final String CloudSymbol = "http://www.simantics.org/Sysdyn-1.1/CloudSymbol";\r
public static final String Configuration = "http://www.simantics.org/Sysdyn-1.1/Configuration";\r
public static final String HasStopTime_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasStopTime/Inverse";\r
public static final String HasTail = "http://www.simantics.org/Sysdyn-1.1/HasTail";\r
public static final String HasTailTerminal = "http://www.simantics.org/Sysdyn-1.1/HasTailTerminal";\r
+ public static final String HasTextLocation = "http://www.simantics.org/Sysdyn-1.1/HasTextLocation";\r
+ public static final String HasTextLocation_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasTextLocation/Inverse";\r
public static final String HasTolerance = "http://www.simantics.org/Sysdyn-1.1/HasTolerance";\r
public static final String HasTolerance_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasTolerance/Inverse";\r
public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.1/HasUnit";\r
public static final String IsTailOf = "http://www.simantics.org/Sysdyn-1.1/IsTailOf";\r
public static final String IsTailOfTerminal = "http://www.simantics.org/Sysdyn-1.1/IsTailOfTerminal";\r
public static final String IssueStyle = "http://www.simantics.org/Sysdyn-1.1/IssueStyle";\r
+ public static final String Left = "http://www.simantics.org/Sysdyn-1.1/Left";\r
+ public static final String Location = "http://www.simantics.org/Sysdyn-1.1/Location";\r
public static final String LookupExpression = "http://www.simantics.org/Sysdyn-1.1/LookupExpression";\r
public static final String ModelBrowser = "http://www.simantics.org/Sysdyn-1.1/ModelBrowser";\r
public static final String Module = "http://www.simantics.org/Sysdyn-1.1/Module";\r
public static final String ReplacingEnumeration = "http://www.simantics.org/Sysdyn-1.1/ReplacingEnumeration";\r
public static final String ReplacingEnumeration_Inverse = "http://www.simantics.org/Sysdyn-1.1/ReplacingEnumeration/Inverse";\r
public static final String Result = "http://www.simantics.org/Sysdyn-1.1/Result";\r
+ public static final String Right = "http://www.simantics.org/Sysdyn-1.1/Right";\r
public static final String SelectedSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/SelectedSharedFunctionLibraries";\r
public static final String SharedFunctionOntology = "http://www.simantics.org/Sysdyn-1.1/SharedFunctionOntology";\r
public static final String SharedModuleOntolofgy = "http://www.simantics.org/Sysdyn-1.1/SharedModuleOntolofgy";\r
public static final String SysdynModuleLibrary = "http://www.simantics.org/Sysdyn-1.1/SysdynModuleLibrary";\r
public static final String SysdynOperationBrowser = "http://www.simantics.org/Sysdyn-1.1/SysdynOperationBrowser";\r
public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.1/SysdynTerminal";\r
+ public static final String Top = "http://www.simantics.org/Sysdyn-1.1/Top";\r
public static final String UsedVariableIndexes = "http://www.simantics.org/Sysdyn-1.1/UsedVariableIndexes";\r
public static final String Validations = "http://www.simantics.org/Sysdyn-1.1/Validations";\r
public static final String Validations_Dependencies = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies";\r
AvailableSharedFunctionLibraries = getResourceOrNull(graph, URIs.AvailableSharedFunctionLibraries);\r
AvailableVariableIndexes = getResourceOrNull(graph, URIs.AvailableVariableIndexes);\r
BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
+ Bottom = getResourceOrNull(graph, URIs.Bottom);\r
Browser = getResourceOrNull(graph, URIs.Browser);\r
Built$in_Functions = getResourceOrNull(graph, URIs.Built$in_Functions);\r
Built$in_Functions_Vensim_Functions = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions);\r
Built$in_Functions_interpolateFull = getResourceOrNull(graph, URIs.Built$in_Functions_interpolateFull);\r
Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz);\r
Built$in_Functions_zidz = getResourceOrNull(graph, URIs.Built$in_Functions_zidz);\r
+ Center = getResourceOrNull(graph, URIs.Center);\r
Cloud = getResourceOrNull(graph, URIs.Cloud);\r
CloudSymbol = getResourceOrNull(graph, URIs.CloudSymbol);\r
Configuration = getResourceOrNull(graph, URIs.Configuration);\r
HasStopTime_Inverse = getResourceOrNull(graph, URIs.HasStopTime_Inverse);\r
HasTail = getResourceOrNull(graph, URIs.HasTail);\r
HasTailTerminal = getResourceOrNull(graph, URIs.HasTailTerminal);\r
+ HasTextLocation = getResourceOrNull(graph, URIs.HasTextLocation);\r
+ HasTextLocation_Inverse = getResourceOrNull(graph, URIs.HasTextLocation_Inverse);\r
HasTolerance = getResourceOrNull(graph, URIs.HasTolerance);\r
HasTolerance_Inverse = getResourceOrNull(graph, URIs.HasTolerance_Inverse);\r
HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
IsTailOf = getResourceOrNull(graph, URIs.IsTailOf);\r
IsTailOfTerminal = getResourceOrNull(graph, URIs.IsTailOfTerminal);\r
IssueStyle = getResourceOrNull(graph, URIs.IssueStyle);\r
+ Left = getResourceOrNull(graph, URIs.Left);\r
+ Location = getResourceOrNull(graph, URIs.Location);\r
LookupExpression = getResourceOrNull(graph, URIs.LookupExpression);\r
ModelBrowser = getResourceOrNull(graph, URIs.ModelBrowser);\r
Module = getResourceOrNull(graph, URIs.Module);\r
ReplacingEnumeration = getResourceOrNull(graph, URIs.ReplacingEnumeration);\r
ReplacingEnumeration_Inverse = getResourceOrNull(graph, URIs.ReplacingEnumeration_Inverse);\r
Result = getResourceOrNull(graph, URIs.Result);\r
+ Right = getResourceOrNull(graph, URIs.Right);\r
SelectedSharedFunctionLibraries = getResourceOrNull(graph, URIs.SelectedSharedFunctionLibraries);\r
SharedFunctionOntology = getResourceOrNull(graph, URIs.SharedFunctionOntology);\r
SharedModuleOntolofgy = getResourceOrNull(graph, URIs.SharedModuleOntolofgy);\r
SysdynModuleLibrary = getResourceOrNull(graph, URIs.SysdynModuleLibrary);\r
SysdynOperationBrowser = getResourceOrNull(graph, URIs.SysdynOperationBrowser);\r
SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal);\r
+ Top = getResourceOrNull(graph, URIs.Top);\r
UsedVariableIndexes = getResourceOrNull(graph, URIs.UsedVariableIndexes);\r
Validations = getResourceOrNull(graph, URIs.Validations);\r
Validations_Dependencies = getResourceOrNull(graph, URIs.Validations_Dependencies);\r
public class SysdynElementHints {\r
\r
public static final Key KEY_INPUT_REFERENCE = new KeyOf(String.class, "INPUT_REFERENCE");\r
- public static final Key KEY_ORIENTATION = new KeyOf(String.class, "ORIENTATION"); \r
+ public static final Key KEY_ORIENTATION = new KeyOf(String.class, "ORIENTATION"); \r
+ public static final Key KEY_LOCATION = new KeyOf(String.class, "LOCATION"); \r
\r
}\r
else\r
return null;\r
}\r
+ \r
+ public static void setValveTextLocation(IElement e, String location)\r
+ {\r
+ ValveTextLocation v = e.getElementClass().getSingleItem(ValveTextLocation.class);\r
+ if(v != null)\r
+ v.setTextLocation(e, location);\r
+ }\r
+\r
+ public static String getValveTextLocation(IElement e)\r
+ {\r
+ ValveTextLocation v = e.getElementClass().getSingleItem(ValveTextLocation.class);\r
+ if(v != null)\r
+ return v.getTextLocation(e);\r
+ else\r
+ return null;\r
+ }\r
\r
}\r
ValveSceneGraph.INSTANCE,\r
BoundsOutline.INSTANCE,\r
Orientation.INSTANCE,\r
+ ValveTextLocation.INSTANCE,\r
new WholeElementTerminals(terminals)\r
).setId(ValveFactory.class.getSimpleName());\r
}\r
orientationText = "Horizontal";\r
} \r
SysdynElementUtils.setOrientation(e, orientationText);\r
- \r
+\r
+ Resource location = graph.getPossibleObject(element, sr.HasTextLocation);\r
+ String locationText;\r
+ if(location == null || sr.Bottom.equals(location)) {\r
+ locationText = "Bottom";\r
+ } else if(sr.Top.equals(location)) {\r
+ locationText = "Top";\r
+ } else if(sr.Left.equals(location)) {\r
+ locationText = "Left";\r
+ } else {\r
+ locationText = "Right";\r
+ }\r
+ SysdynElementUtils.setValveTextLocation(e, locationText); \r
+ \r
}\r
\r
/**\r
if(at != null) {\r
node.setTransform(at);\r
\r
- // Use affinetransform to move the name of the valve below the valve symbol\r
TextNode name = (TextNode) e.getHint(SG_NODE);\r
if(name != null) {\r
+ \r
AffineTransform at2 = (AffineTransform) at.clone();\r
- at2.translate(0, VALVE_SIZE + 3.0);\r
+ Alignment alignment = null;\r
+ \r
+ String location = e.getHint(SysdynElementHints.KEY_LOCATION);\r
+ if(location != null) {\r
+ if(location.equals("Bottom")) {\r
+ at2.translate(0, VALVE_SIZE + 3.0);\r
+ } else if(location.equals("Top")) {\r
+ at2.translate(0, -VALVE_SIZE - 1);\r
+ } else if(location.equals("Left")) {\r
+ at2.translate(0, 0);\r
+ alignment = Alignment.TRAILING;\r
+ } else {\r
+ at2.translate(VALVE_SIZE + 1, 0);\r
+ alignment = Alignment.LEADING;\r
+ }\r
+ }\r
+ \r
name.setTransform(at2);\r
+ if(alignment != null)\r
+ name.setHorizontalAlignment((byte) alignment.ordinal());\r
}\r
}\r
\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.ElementHandler;\r
+\r
+public class ValveTextLocation implements ElementHandler {\r
+\r
+ private static final long serialVersionUID = 7123851901569461658L;\r
+ \r
+ public static final ValveTextLocation INSTANCE = new ValveTextLocation();\r
+ \r
+ public String getTextLocation(IElement e) {\r
+ return e.getHint(SysdynElementHints.KEY_LOCATION);\r
+ }\r
+\r
+ \r
+ public void setTextLocation(IElement e, String location) {\r
+ if (location != null)\r
+ e.setHint(SysdynElementHints.KEY_LOCATION, location);\r
+ else\r
+ e.removeHint(SysdynElementHints.KEY_LOCATION);\r
+ }\r
+\r
+}\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.properties.widgets.ValveOrientationGroup;\r
+import org.simantics.sysdyn.ui.properties.widgets.ValveTextLocationGroup;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
\r
rangeStep.setInputValidator(new DoubleValidator());\r
GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget());\r
\r
- \r
- new ValveOrientationGroup(composite, context, support, SWT.NONE);\r
+ Composite valveComposite = new Composite(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().applyTo(valveComposite);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(3,3).applyTo(valveComposite);\r
+ new ValveOrientationGroup(valveComposite, context, support, SWT.NONE);\r
+ new ValveTextLocationGroup(valveComposite, context, support, SWT.NONE);\r
\r
}\r
\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.datastructures.Quad;\r
\r
public class ValveOrientationGroup extends WidgetImpl {\r
\r
\r
horizontal = new Button(group, support, SWT.RADIO);\r
horizontal.setText("Horizontal");\r
- horizontal.setSelectionFactory(new OrientationSelectionFactory(SysdynResource.URIs.Horizontal, true));\r
+ horizontal.setSelectionFactory(new OrientationSelectionFactory(horizontal, SysdynResource.URIs.Horizontal, true));\r
horizontal.addSelectionListener(new OrientationSelectionListener(context, SysdynResource.URIs.Horizontal));\r
\r
vertical = new Button(group, support, SWT.RADIO);\r
vertical.setText("Vertical");\r
- vertical.setSelectionFactory(new OrientationSelectionFactory(SysdynResource.URIs.Vertical));\r
+ vertical.setSelectionFactory(new OrientationSelectionFactory(vertical, SysdynResource.URIs.Vertical));\r
vertical.addSelectionListener(new OrientationSelectionListener(context, SysdynResource.URIs.Vertical));\r
}\r
\r
\r
boolean defaultSelected;\r
String uri;\r
+ Button button;\r
\r
- public OrientationSelectionFactory(String uri) {\r
- this(uri, false);\r
+ public OrientationSelectionFactory(Button button, String uri) {\r
+ this(button, uri, false);\r
}\r
\r
- public OrientationSelectionFactory(String uri, boolean defaultSelected) {\r
+ public OrientationSelectionFactory(Button button, String uri, boolean defaultSelected) {\r
this.uri = uri;\r
this.defaultSelected = defaultSelected;\r
+ this.button = button;\r
}\r
\r
public Object getIdentity(Object inputContents) {\r
- return new Triple<Object, Object, Class<?>>(uri, defaultSelected, getClass());\r
+ return new Quad<Object, Object, Object, Class<?>>(button, uri, defaultSelected, getClass());\r
}\r
\r
@Override\r
if(graph.hasStatement(symbol, sr.HasValveOrientation))\r
graph.deny(symbol, sr.HasValveOrientation);\r
graph.claim(symbol, sr.HasValveOrientation, graph.getResource(uri));\r
+ \r
+ if(graph.hasStatement(symbol, sr.HasTextLocation))\r
+ graph.deny(symbol, sr.HasTextLocation);\r
+ if(sr.Vertical.equals(graph.getResource(uri)))\r
+ graph.claim(symbol, sr.HasTextLocation, sr.Right);\r
+ \r
}\r
\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.WidgetImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.Quad;\r
+\r
+public class ValveTextLocationGroup extends WidgetImpl {\r
+\r
+ Group group;\r
+ Button top, bottom, left, right;\r
+ \r
+ public ValveTextLocationGroup(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
+ super(support);\r
+ \r
+ group = new Group(parent, SWT.NONE);\r
+ group.setText("Text location");\r
+ GridDataFactory.fillDefaults().applyTo(group);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(group);\r
+ \r
+ top = new Button(group, support, SWT.RADIO);\r
+ top.setText("Top");\r
+ top.setSelectionFactory(new LocationSelectionFactory(top, SysdynResource.URIs.Top));\r
+ top.addSelectionListener(new LocationSelectionListener(context, SysdynResource.URIs.Top));\r
+ \r
+ bottom = new Button(group, support, SWT.RADIO);\r
+ bottom.setText("Bottom");\r
+ bottom.setSelectionFactory(new LocationSelectionFactory(bottom, SysdynResource.URIs.Bottom, true));\r
+ bottom.addSelectionListener(new LocationSelectionListener(context, SysdynResource.URIs.Bottom));\r
+ \r
+ left = new Button(group, support, SWT.RADIO);\r
+ left.setText("Left");\r
+ left.setSelectionFactory(new LocationSelectionFactory(left, SysdynResource.URIs.Left));\r
+ left.addSelectionListener(new LocationSelectionListener(context, SysdynResource.URIs.Left));\r
+ \r
+ right = new Button(group, support, SWT.RADIO);\r
+ right.setText("Right");\r
+ right.setSelectionFactory(new LocationSelectionFactory(right, SysdynResource.URIs.Right));\r
+ right.addSelectionListener(new LocationSelectionListener(context, SysdynResource.URIs.Right));\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public Control getControl() {\r
+ return this.group;\r
+ }\r
+ \r
+ \r
+ private class LocationSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
+ \r
+ boolean defaultSelected;\r
+ String uri;\r
+ Button button;\r
+ \r
+ public LocationSelectionFactory(Button button, String uri) {\r
+ this(button, uri, false);\r
+ }\r
+\r
+ public LocationSelectionFactory(Button button, String uri, boolean defaultSelected) {\r
+ this.uri = uri;\r
+ this.defaultSelected = defaultSelected;\r
+ this.button = button;\r
+ }\r
+ \r
+ public Object getIdentity(Object inputContents) {\r
+ return new Quad<Object, Object, Object, Class<?>>(button, uri, defaultSelected, getClass());\r
+ }\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph, Resource valve) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ if(!graph.isInstanceOf(valve, sr.Valve))\r
+ return Boolean.FALSE;\r
+ \r
+ Resource symbol = graph.getPossibleObject(valve, mr.ComponentToElement);\r
+ if(symbol == null)\r
+ return Boolean.FALSE;\r
+ \r
+ Resource location = graph.getPossibleObject(symbol, sr.HasTextLocation);\r
+ \r
+ if(location == null)\r
+ return defaultSelected;\r
+ \r
+ return location.equals(graph.getResource(uri));\r
+ }\r
+ \r
+ }\r
+ \r
+ \r
+ private class LocationSelectionListener extends SelectionListenerImpl<Resource> {\r
+ \r
+ String uri;\r
+ \r
+ public LocationSelectionListener(ISessionContext context, String uri) {\r
+ super(context);\r
+ this.uri = uri;\r
+ }\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource valve) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ if(!graph.isInstanceOf(valve, sr.Valve))\r
+ return;\r
+ \r
+ Resource symbol = graph.getPossibleObject(valve, mr.ComponentToElement);\r
+ if(symbol == null)\r
+ return;\r
+ \r
+ if(graph.hasStatement(symbol, sr.HasTextLocation))\r
+ graph.deny(symbol, sr.HasTextLocation);\r
+ graph.claim(symbol, sr.HasTextLocation, graph.getResource(uri));\r
+ }\r
+ \r
+ }\r
+\r
+}\r