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.utils.datastructures.hints;
\r
14 import org.simantics.utils.datastructures.hints.IHintContext.Key;
\r
17 * @author Tuukka Lehtonen
\r
19 public class HintTrackerTest extends HintStack {
\r
21 public static void main(String[] args) {
\r
22 IHintContext ctx1 = new HintContext();
\r
23 IHintContext ctx2 = new HintContext();
\r
25 Key key1 = new IHintContext.KeyOf(Object.class);
\r
26 Key key2 = new IHintContext.KeyOf(Object.class);
\r
28 final HintTracker t1 = new HintTracker();
\r
29 final HintTracker t2 = new HintTracker();
\r
31 t1.addKeyHintListener(key1, new HintListenerAdapter() {
\r
33 public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
\r
34 System.out.println("secondary tracked hint context changed: " + newValue);
\r
35 t2.track((IHintContext) newValue);
\r
38 t2.addKeyHintListener(key2, new HintListenerAdapter() {
\r
40 public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
\r
41 System.out.println("set view input to: " + newValue);
\r
46 ctx1.setHint(key1, ctx2);
\r
47 ctx2.setHint(key2, new Object());
\r