>-- %relation
sclAttribute = COMPONENTS.sclAttribute : L0.Template
- @template %subject %relation %command
+ @template %subject %relation %command %valueType
%subject
>-- %relation
L0.Asserts _ : L0.Assertion
L0.HasPredicate %relation
L0.HasObject _ : DOC.SCLValue
- L0.HasValueType "String"
+ L0.HasValueType %valueType
L0.SCLValue.expression %command
L0.default false
L0.HasValueType %valueType
DOC.SCLValue <T L0.SCLValue
+ @L0.scl L0.SCLValueType.validator """\self -> compileDocumentSCLValueExpression self""" "Variable -> <ReadGraph> String"
@L0.assert L0.ConvertsToValueWith
DOC.Functions.sclValue : L0.ExternalValue
@attribute PROPERTIES.session FUNCTIONS.session
@attribute PROPERTIES.state FUNCTIONS.state
@attribute PROPERTIES.icstate FUNCTIONS.icstate
- @sclAttribute PROPERTIES.commands "commandList self"
+ @sclAttribute PROPERTIES.commands "commandList self" "[Command]"
COMPONENTS.PrimitiveComponent <T COMPONENTS.Component
@L0.assert PROPERTIES.primitiveProperties
_ : L0.Value
L0.domainProperties FUNCTIONS.primitiveProperties
-
COMPONENTS.ParentlessComponent <T COMPONENTS.PrimitiveComponent /* Component without a parent, e.g. Root, DialogBox */
COMPONENTS.CommandEvent <T COMPONENTS.Event
@connectionPoint RELATIONS.data1
- @sclAttribute PROPERTIES.dataDefinitions "dataDefinitions self"
- @sclAttribute PROPERTIES.SCLFunction "emptyOnClick ()"
+ @sclAttribute PROPERTIES.dataDefinitions "dataDefinitions self" "[DataDefinition]"
+ @sclAttribute PROPERTIES.SCLFunction "emptyOnClick ()" "String"
DOC.commandEvent : L0.Template
@template %instance %expression %valueType
L0.RequiresValueType "Boolean"
PROPERTIES.commands
- @defAttribute L0.String
- L0.RequiresValueType "String"
+ @defAttribute L0.Value
+ L0.RequiresValueType "[Command]"
L0.HasLabel "Commands"
PROPERTIES.dataDefinitions
- @defAttribute L0.String
- L0.RequiresValueType "String"
+ @defAttribute L0.Value
+ L0.RequiresValueType "[DataDefinition]"
L0.HasLabel "Data Definitions"
PROPERTIES.SCLFunction : PROPERTIES.ParameterType
stateVariable :: Variable -> <ReadGraph> Variable
+ compileDocumentSCLValueExpression :: Variable -> <ReadGraph> String
+
propertyValueCached :: Serializable a => Typeable a => Variable -> String -> <ReadGraph> a
propertyValueCached var prop = propertyValueCached_ var prop binding
import org.simantics.db.layer0.request.VariableProperty;
import org.simantics.db.layer0.request.VariableRead;
import org.simantics.db.layer0.request.VariableValueWithBinding;
+import org.simantics.db.layer0.scl.SCLDatabaseException;
import org.simantics.db.layer0.variable.ConstantPropertyVariable;
import org.simantics.db.layer0.variable.ProxyChildVariable;
import org.simantics.db.layer0.variable.ProxySessionRequest;
import org.simantics.modeling.services.ComponentNamingStrategy;
import org.simantics.operation.Layer0X;
import org.simantics.project.IProject;
+import org.simantics.scl.compiler.module.repository.ImportFailureException;
import org.simantics.scl.compiler.types.TCon;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.structural2.variables.Connection;
import org.simantics.structural2.variables.StandardProceduralChildVariable;
import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.THashMap;
public class Functions {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Functions.class);
+
private static class PrimitivePropertyStatementsProcedure implements AsyncProcedure<DirectStatements> {
public DirectStatements result;
return graph.syncRequest(new PathExistsRequest(context));
}
+ public static String compileDocumentSCLValueExpression(ReadGraph graph, Variable context) {
+ try {
+ ServerSCLValueRequest.compile(graph, context);
+ return "";
+ } catch (Exception e) {
+ return resolveIssueMessage(e);
+ }
+ }
+
+ private static String resolveIssueMessage(Exception e) {
+ if (e instanceof ImportFailureException)
+ return "";
+ if (e.getCause() != null && e.getCause() instanceof ImportFailureException)
+ return "";
+ if (e instanceof SCLDatabaseException) {
+ SCLDatabaseException ee = (SCLDatabaseException) e;
+ return ee.getMessage();
+ }
+ if (LOGGER.isDebugEnabled())
+ LOGGER.debug("", e);
+ return e.getMessage();
+ }
+
}
\ No newline at end of file
SCLContext sclContext = SCLContext.getCurrent();
Object oldGraph = sclContext.get("graph");
try {
- Function1<Variable,Object> exp = graph.syncRequest(new ServerSCLValueRequest(graph, context),
- TransientCacheListener.<Function1<Variable,Object>>instance());
+ Function1<Variable,Object> exp = compile(graph, context);
sclContext.put("graph", graph);
return exp.apply(context);
} catch (DatabaseException e) {
sclContext.put("graph", oldGraph);
}
}
+
+ public static Function1<Variable, Object> compile(ReadGraph graph, Variable context) throws DatabaseException {
+ return graph.syncRequest(new ServerSCLValueRequest(graph, context), TransientCacheListener.<Function1<Variable,Object>>instance());
+ }
@Override
protected String getExpressionText(ReadGraph graph)