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