1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.synchronization;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.List;
18 import org.simantics.utils.datastructures.hints.IHintObservable;
19 import org.simantics.utils.datastructures.hints.IHintContext.Key;
22 * Synchronizer that is composed of several other synchronizers. It will consult
23 * the composed synchronizers in the order in which they were specified. Should
24 * a composed synchronizer report that it has handled the synchronization, i.e.
25 * returns <code>true</code>, the consultation will end there.
27 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
28 * @author Tuukka Lehtonen
30 public class CompositeHintSynchronizer implements IHintSynchronizer {
32 private final List<IHintSynchronizer> synchronizers = new ArrayList<IHintSynchronizer>();
34 public CompositeHintSynchronizer() {
37 public CompositeHintSynchronizer(IHintSynchronizer... synchronizers) {
38 for (IHintSynchronizer s : synchronizers)
39 this.synchronizers.add(s);
42 public CompositeHintSynchronizer(Collection<IHintSynchronizer> synchronizers) {
43 this.synchronizers.addAll(synchronizers);
46 public CompositeHintSynchronizer add(IHintSynchronizer s) {
52 public int synchronize(ISynchronizationContext context, IHintObservable observable) {
54 for (IHintSynchronizer synchronizer : synchronizers) {
55 count += synchronizer.synchronize(context, observable);
61 public boolean hintChanged(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue,
63 for (IHintSynchronizer s : synchronizers) {
64 if (s.hintChanged(context, sender, key, oldValue, newValue))
71 public boolean hintRemoved(ISynchronizationContext context, IHintObservable sender, Key key, Object oldValue) {
72 for (IHintSynchronizer s : synchronizers) {
73 if (s.hintRemoved(context, sender, key, oldValue))