X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fsynchronization%2FCompositeHintSynchronizer.java;h=361cdc32278396a4cf7c8f8a3ca22f8c8c3913a3;hb=006602e856bbc3e222789cfe00a923b863e3e91b;hp=4d63a16ff868d6d2b79d643803b9049c4ac539de;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeHintSynchronizer.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeHintSynchronizer.java index 4d63a16ff..361cdc322 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeHintSynchronizer.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeHintSynchronizer.java @@ -1,79 +1,79 @@ -/******************************************************************************* - * 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.diagram.synchronization; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.simantics.utils.datastructures.hints.IHintObservable; -import org.simantics.utils.datastructures.hints.IHintContext.Key; - -/** - * Synchronizer that is composed of several other synchronizers. It will consult - * the composed synchronizers in the order in which they were specified. Should - * a composed synchronizer report that it has handled the synchronization, i.e. - * returns true, the consultation will end there. - * - * @author Marko Luukkainen - * @author Tuukka Lehtonen - */ -public class CompositeHintSynchronizer implements IHintSynchronizer { - - private final List synchronizers = new ArrayList(); - - public CompositeHintSynchronizer() { - } - - public CompositeHintSynchronizer(IHintSynchronizer... synchronizers) { - for (IHintSynchronizer s : synchronizers) - this.synchronizers.add(s); - } - - public CompositeHintSynchronizer(Collection synchronizers) { - this.synchronizers.addAll(synchronizers); - } - - public CompositeHintSynchronizer add(IHintSynchronizer s) { - synchronizers.add(s); - return this; - } - - @Override - public int synchronize(ISynchronizationContext context, IHintObservable observable) { - int count = 0; - for (IHintSynchronizer synchronizer : synchronizers) { - count += synchronizer.synchronize(context, observable); - } - return count; - } - - @Override - public boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue, - Object newValue) { - for (IHintSynchronizer s : synchronizers) { - if (s.hintChanged(context, sender, key, oldValue, newValue)) - return true; - } - return false; - } - - @Override - public boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) { - for (IHintSynchronizer s : synchronizers) { - if (s.hintRemoved(context, sender, key, oldValue)) - return true; - } - 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.diagram.synchronization; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.simantics.utils.datastructures.hints.IHintObservable; +import org.simantics.utils.datastructures.hints.IHintContext.Key; + +/** + * Synchronizer that is composed of several other synchronizers. It will consult + * the composed synchronizers in the order in which they were specified. Should + * a composed synchronizer report that it has handled the synchronization, i.e. + * returns true, the consultation will end there. + * + * @author Marko Luukkainen + * @author Tuukka Lehtonen + */ +public class CompositeHintSynchronizer implements IHintSynchronizer { + + private final List synchronizers = new ArrayList(); + + public CompositeHintSynchronizer() { + } + + public CompositeHintSynchronizer(IHintSynchronizer... synchronizers) { + for (IHintSynchronizer s : synchronizers) + this.synchronizers.add(s); + } + + public CompositeHintSynchronizer(Collection synchronizers) { + this.synchronizers.addAll(synchronizers); + } + + public CompositeHintSynchronizer add(IHintSynchronizer s) { + synchronizers.add(s); + return this; + } + + @Override + public int synchronize(ISynchronizationContext context, IHintObservable observable) { + int count = 0; + for (IHintSynchronizer synchronizer : synchronizers) { + count += synchronizer.synchronize(context, observable); + } + return count; + } + + @Override + public boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue, + Object newValue) { + for (IHintSynchronizer s : synchronizers) { + if (s.hintChanged(context, sender, key, oldValue, newValue)) + return true; + } + return false; + } + + @Override + public boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) { + for (IHintSynchronizer s : synchronizers) { + if (s.hintRemoved(context, sender, key, oldValue)) + return true; + } + return false; + } + +}