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