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