+ public static void trackOntologicalRequirements() {
+ Session session = Simantics.getSession();
+ GraphChangeListenerSupport changeListenerSupport = session.getService(GraphChangeListenerSupport.class);
+ changeListenerSupport.addMetadataListener( OntologicalRequirementListener.getInstance() );
+ }
+
+ public static void untrackOntologicalRequirements() {
+ Session session = Simantics.getSession();
+ GraphChangeListenerSupport changeListenerSupport = session.getService(GraphChangeListenerSupport.class);
+ changeListenerSupport.removeMetadataListener( OntologicalRequirementListener.getInstance() );
+ }
+
+ public static class OntologicalRequirementListener extends GenericChangeListener<DependencyChangesRequest, DependencyChanges> {
+
+ private static OntologicalRequirementListener INSTANCE;
+
+ public static OntologicalRequirementListener getInstance() {
+ if(INSTANCE == null) {
+ INSTANCE = new OntologicalRequirementListener();
+ }
+ return INSTANCE;
+ }
+
+ private OntologicalRequirementListener() {
+ }
+
+ private OntologicalRequirementTracker changeInformationUpdater = new OntologicalRequirementTracker();
+
+ @Override
+ public boolean preEventRequest() {
+ return !Indexing.isDependenciesIndexingDisabled();
+ }
+
+ @Override
+ public void onEvent(ReadGraph graph, MetadataI metadata, DependencyChanges event) throws DatabaseException {
+ changeInformationUpdater.update(graph, metadata, event);
+ }
+
+ }
+