import org.simantics.db.common.request.PossibleChild;
import org.simantics.db.common.request.PossibleIndexRoot;
import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.event.ChangeListener;
import org.simantics.db.exception.CancelTransactionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ServiceException;
import org.simantics.db.service.ClusteringSupport;
import org.simantics.db.service.CollectionSupport;
import org.simantics.db.service.DebugSupport;
+import org.simantics.db.service.GraphChangeListenerSupport;
import org.simantics.db.service.ManagementSupport;
import org.simantics.db.service.UndoRedoSupport;
import org.simantics.db.service.XSupport;
}
return false;
}
+
+ public static void addMetadataListener(ChangeListener listener) {
+ SimanticsInternal.getSession().getService(GraphChangeListenerSupport.class).addMetadataListener(listener);
+ }
+
+ public static void removeMetadataListener(ChangeListener listener) {
+ SimanticsInternal.getSession().getService(GraphChangeListenerSupport.class).removeMetadataListener(listener);
+ }
+
}
untrackDependencies :: <Proc> ()
trackOntologicalRequirements :: <Proc> ()
untrackOntologicalRequirements :: <Proc> ()
-
+
+importJava "org.simantics.modeling.scl.SCLDependencyChangeListener" where
+ @JavaName "create"
+ createDependencyChangeListener :: (<Proc> Boolean) -> (MetadataI -> DependencyChanges -> <ReadGraph,Proc> ()) -> ChangeListener
\ No newline at end of file
--- /dev/null
+package org.simantics.modeling.scl;
+
+import org.simantics.Simantics;
+import org.simantics.db.MetadataI;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.common.changeset.GenericChangeListener;
+import org.simantics.db.event.ChangeListener;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.DependenciesRelation.DependencyChangesRequest;
+import org.simantics.db.layer0.genericrelation.DependencyChanges;
+import org.simantics.scl.runtime.function.Function;
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.tuple.Tuple0;
+
+public class SCLDependencyChangeListener extends GenericChangeListener<DependencyChangesRequest, DependencyChanges> {
+
+ private Function1<Tuple0, Boolean> preEventRequest;
+ private Function onEvent;
+
+ public SCLDependencyChangeListener(Function1<Tuple0, Boolean> preEventRequest, Function onEvent) {
+ this.preEventRequest = preEventRequest;
+ this.onEvent = onEvent;
+ }
+
+ @Override
+ public boolean preEventRequest() {
+ return preEventRequest.apply(Tuple0.INSTANCE);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void onEvent(ReadGraph graph, MetadataI metadata, DependencyChanges event) throws DatabaseException {
+ Simantics.applySCLRead(graph, onEvent, metadata, event);
+ }
+
+ public static ChangeListener create(Function1<Tuple0, Boolean> preEventRequest, Function onEvent) {
+ return new SCLDependencyChangeListener(preEventRequest, onEvent);
+ }
+
+}
\ No newline at end of file
possiblePredicateByName :: Resource -> String -> <ReadGraph> Maybe Resource
@JavaName getPossiblePredicateByNameFromType
possiblePredicateByNameFromType :: Resource -> String -> <ReadGraph> Maybe Resource
+
+ addMetadataListener :: ChangeListener -> <Proc> ()
+ removeMetadataListener :: ChangeListener -> <Proc> ()
copyTo :: Resource -> Resource -> <WriteGraph> Resource
copyTo targetContainer source = do
Just c -> possibleChild c name
Nothing -> Nothing
)
- (Just parent) path
\ No newline at end of file
+ (Just parent) path
+
+importJava "org.simantics.db.MetadataI" where
+ data MetadataI
+
+importJava "org.simantics.db.event.ChangeListener" where
+ data ChangeListener
+
+importJava "org.simantics.db.layer0.genericrelation.DependencyChanges" where
+ data DependencyChanges
@SuppressWarnings({ "unchecked", "rawtypes" })
- public static <T> T applySCL(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException {
- SCLContext sclContext = SCLContext.getCurrent();
- Object oldGraph = sclContext.put("graph", graph);
- try {
- T t = (T)((Function)SCLOsgi.MODULE_REPOSITORY.getValue(module, function)).applyArray(args);
- return t;
- } catch (ValueNotFound e) {
- throw new DatabaseException("SCL Value not found: " + e.name);
- } catch (Throwable t) {
- throw new DatabaseException(t);
- } finally {
- sclContext.put("graph", oldGraph);
- }
+ public static <T> T applySCL(String module, String function, Object ... args) throws DatabaseException {
+ try {
+ T t = (T)((Function)SCLOsgi.MODULE_REPOSITORY.getValue(module, function)).applyArray(args);
+ return t;
+ } catch (ValueNotFound e) {
+ throw new DatabaseException("SCL Value not found: " + e.name);
+ } catch (Throwable t) {
+ throw new DatabaseException(t);
+ }
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static <T> T applySCL(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException {
+ SCLContext sclContext = SCLContext.getCurrent();
+ Object oldGraph = sclContext.put("graph", graph);
+ try {
+ return applySCL(module, function, args);
+ } catch (DatabaseException dbe) {
+ throw dbe;
+ } catch (Throwable t) {
+ throw new DatabaseException(t);
+ } finally {
+ sclContext.put("graph", oldGraph);
+ }
}
@SuppressWarnings("unchecked")