]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/HintTrackerTest.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / hints / HintTrackerTest.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.datastructures.hints;
13
14 import org.simantics.utils.datastructures.hints.IHintContext.Key;
15
16 /**
17  * @author Tuukka Lehtonen
18  */
19 public class HintTrackerTest extends HintStack {
20
21     public static void main(String[] args) {
22         IHintContext ctx1 = new HintContext();
23         IHintContext ctx2 = new HintContext();
24
25         Key key1 = new IHintContext.KeyOf(Object.class);
26         Key key2 = new IHintContext.KeyOf(Object.class);
27
28         final HintTracker t1 = new HintTracker();
29         final HintTracker t2 = new HintTracker();
30
31         t1.addKeyHintListener(key1, new HintListenerAdapter() {
32             @Override
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);
36             }
37         });
38         t2.addKeyHintListener(key2, new HintListenerAdapter() {
39             @Override
40             public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
41                 System.out.println("set view input to: " + newValue);
42             }
43         });
44         t1.track(ctx1);
45         
46         ctx1.setHint(key1, ctx2);
47         ctx2.setHint(key2, new Object());
48     }
49
50 }