-package org.simantics.scenegraph.profile.impl;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.procedure.single.SingleSetSyncListener;\r
-import org.simantics.db.common.utils.Logger;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.scenegraph.profile.ProfileEntry;\r
-import org.simantics.scenegraph.profile.common.ProfileObserver;\r
-import org.simantics.utils.datastructures.disposable.IDisposable;\r
-\r
-public class ProfileActivationListener extends SingleSetSyncListener<ProfileEntry> {\r
-\r
- final Resource runtime;\r
- final ProfileObserver observer;\r
- final IDisposable disposable;\r
- final Set<ProfileEntry> active = new HashSet<ProfileEntry>();\r
- \r
- public ProfileActivationListener(Resource runtime, ProfileObserver observer, IDisposable disposable) {\r
- this.runtime = runtime;\r
- this.observer = observer;\r
- this.disposable = disposable;\r
- }\r
- \r
- @Override\r
- public boolean start(ReadGraph graph) throws DatabaseException {\r
- \r
- if (observer == null || observer.isDisposed())\r
- return false;\r
- if (runtime == null)\r
- return false;\r
-\r
- return true;\r
- \r
- }\r
-\r
- @Override\r
- public void add(ReadGraph graph, ProfileEntry item) throws DatabaseException {\r
- observer.update();\r
- item.activate(graph, runtime, observer);\r
- active.add(item);\r
- if (DebugPolicy.DEBUG_PROFILE_STYLE_ACTIVATION)\r
- System.out.println("ACTIVATED PROFILE ENTRY: " + item);\r
- }\r
-\r
- @Override\r
- public void remove(ReadGraph graph, ProfileEntry item) throws DatabaseException {\r
- observer.update();\r
- active.remove(item);\r
- if (DebugPolicy.DEBUG_PROFILE_STYLE_ACTIVATION)\r
- System.out.println("DE-ACTIVATING PROFILE ENTRY: " + item);\r
- item.deactivate(runtime, observer);\r
- }\r
-\r
- @Override\r
- public void finished(ReadGraph graph) throws DatabaseException {\r
-// observer.update();\r
- }\r
-\r
- @Override\r
- public void exception(ReadGraph graph, Throwable t) {\r
- Logger.defaultLogError(t);\r
- }\r
-\r
- @Override\r
- public boolean isDisposed() {\r
- return disposable.isDisposed();\r
- }\r
- \r
- public void cleanup() {\r
- if(!active.isEmpty()) {\r
- for(ProfileEntry entry : active) entry.deactivate(runtime, observer);\r
- active.clear();\r
- }\r
- }\r
-\r
+package org.simantics.scenegraph.profile.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.single.SingleSetSyncListener;
+import org.simantics.db.common.utils.Logger;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.scenegraph.profile.ProfileEntry;
+import org.simantics.scenegraph.profile.common.ProfileObserver;
+import org.simantics.utils.datastructures.disposable.IDisposable;
+
+public class ProfileActivationListener extends SingleSetSyncListener<ProfileEntry> {
+
+ final Resource runtime;
+ final ProfileObserver observer;
+ final IDisposable disposable;
+ final Set<ProfileEntry> active = new HashSet<ProfileEntry>();
+
+ public ProfileActivationListener(Resource runtime, ProfileObserver observer, IDisposable disposable) {
+ this.runtime = runtime;
+ this.observer = observer;
+ this.disposable = disposable;
+ }
+
+ @Override
+ public boolean start(ReadGraph graph) throws DatabaseException {
+
+ if (observer == null || observer.isDisposed())
+ return false;
+ if (runtime == null)
+ return false;
+
+ return true;
+
+ }
+
+ @Override
+ public void add(ReadGraph graph, ProfileEntry item) throws DatabaseException {
+ observer.update();
+ item.activate(graph, runtime, observer);
+ active.add(item);
+ if (DebugPolicy.DEBUG_PROFILE_STYLE_ACTIVATION)
+ System.out.println("ACTIVATED PROFILE ENTRY: " + item);
+ }
+
+ @Override
+ public void remove(ReadGraph graph, ProfileEntry item) throws DatabaseException {
+ observer.update();
+ active.remove(item);
+ if (DebugPolicy.DEBUG_PROFILE_STYLE_ACTIVATION)
+ System.out.println("DE-ACTIVATING PROFILE ENTRY: " + item);
+ item.deactivate(runtime, observer);
+ }
+
+ @Override
+ public void finished(ReadGraph graph) throws DatabaseException {
+// observer.update();
+ }
+
+ @Override
+ public void exception(ReadGraph graph, Throwable t) {
+ Logger.defaultLogError(t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return disposable.isDisposed();
+ }
+
+ public void cleanup() {
+ if(!active.isEmpty()) {
+ for(ProfileEntry entry : active) entry.deactivate(runtime, observer);
+ active.clear();
+ }
+ }
+
}
\ No newline at end of file