X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph.profile%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fprofile%2Fimpl%2FProfileActivationListener.java;h=57f5a43036bb6214d0af07f764872b4ae6f9eeab;hb=refs%2Fchanges%2F38%2F238%2F2;hp=d43e8db741323f81f486eab8d83501aabf36b9bb;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/impl/ProfileActivationListener.java b/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/impl/ProfileActivationListener.java index d43e8db74..57f5a4303 100644 --- a/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/impl/ProfileActivationListener.java +++ b/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/impl/ProfileActivationListener.java @@ -1,80 +1,80 @@ -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 { - - final Resource runtime; - final ProfileObserver observer; - final IDisposable disposable; - final Set active = new HashSet(); - - 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(); - } - } - +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 { + + final Resource runtime; + final ProfileObserver observer; + final IDisposable disposable; + final Set active = new HashSet(); + + 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