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.graph;
\r
14 import org.simantics.databoard.Bindings;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.diagram.elements.MonitorClass;
\r
17 import org.simantics.diagram.synchronization.IModificationQueue;
\r
18 import org.simantics.diagram.synchronization.ISynchronizationContext;
\r
19 import org.simantics.utils.datastructures.hints.IHintContext.Key;
\r
20 import org.simantics.utils.datastructures.hints.IHintObservable;
\r
23 * @author Tuukka Lehtonen
\r
25 public class MonitorSynchronizer extends ResourceSynchronizer {
\r
27 public static final MonitorSynchronizer INSTANCE = new MonitorSynchronizer();
\r
29 private static final Key[] SYNCHRONIZED_HINTS = {
\r
30 MonitorClass.KEY_DIRECTION,
\r
34 public Key[] getSynchronizedHints() {
\r
35 return SYNCHRONIZED_HINTS;
\r
39 public boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue) {
\r
40 if (MonitorClass.KEY_DIRECTION.equals(key)) {
\r
41 BasicResources br = context.get(GraphSynchronizationHints.BASIC_RESOURCES);
\r
42 Double dir = (Double) newValue;
\r
43 queue.offer(new PropertyModification(object, br.DIA.HasDirection, br.L0.Double, dir, Bindings.DOUBLE), null);
\r