X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fdiagram%2Fparticipant%2FElementHeartbeater.java;h=a45f63d29f2b9d854d3e2c0fddacb7531d74ee73;hb=414dd6f06a51268cbbf7bc8c1b1ae0a1e3d71f89;hp=fb60d664cc7e91e267528fc6d4f15b66ef58e1f0;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementHeartbeater.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementHeartbeater.java index fb60d664c..a45f63d29 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementHeartbeater.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementHeartbeater.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.diagram.participant; - -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency; -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.Heartbeat; -import org.simantics.g2d.participant.TimeParticipant; -import org.simantics.scenegraph.g2d.events.TimeEvent; -import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler; - -/** - * This participant sends time events to Heartbeat element handlers. - * - * @See {@link Heartbeat} - * @author Toni Kalajainen - */ -public class ElementHeartbeater extends AbstractDiagramParticipant { - - @Dependency TimeParticipant time; - - @Override - public void addedToContext(ICanvasContext ctx) { - super.addedToContext(ctx); - time.registerForEvents(getClass()); - } - - @Override - public void removedFromContext(ICanvasContext ctx) { - time.unregisterForEvents(getClass()); - super.removedFromContext(ctx); - } - - @EventHandler(priority = 0) - public boolean handleHeartbeat(TimeEvent te) { - IDiagram d = diagram; - if (d==null) return false; - for (IElement e : d.getSnapshot()) - { - for (Heartbeat hb : e.getElementClass().getItemsByClass(Heartbeat.class)) - hb.heartbeat(e, te.time, te.interval, getContext()); - } - return false; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.diagram.participant; + +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency; +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.Heartbeat; +import org.simantics.g2d.participant.TimeParticipant; +import org.simantics.scenegraph.g2d.events.TimeEvent; +import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler; + +/** + * This participant sends time events to Heartbeat element handlers. + * + * @See {@link Heartbeat} + * @author Toni Kalajainen + */ +public class ElementHeartbeater extends AbstractDiagramParticipant { + + @Dependency TimeParticipant time; + + @Override + public void addedToContext(ICanvasContext ctx) { + super.addedToContext(ctx); + time.registerForEvents(getClass()); + } + + @Override + public void removedFromContext(ICanvasContext ctx) { + time.unregisterForEvents(getClass()); + super.removedFromContext(ctx); + } + + @EventHandler(priority = 0) + public boolean handleHeartbeat(TimeEvent te) { + IDiagram d = diagram; + if (d==null) return false; + for (IElement e : d.getSnapshot()) + { + for (Heartbeat hb : e.getElementClass().getItemsByClass(Heartbeat.class)) + hb.heartbeat(e, te.time, te.interval, getContext()); + } + return false; + } + +}