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 *******************************************************************************/
14 * @author Toni Kalajainen
16 package org.simantics.utils.datastructures.hints;
18 import org.simantics.utils.datastructures.hints.IHintContext.Key;
19 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
21 public class HintStackTest {
23 public static final Key KEY = new KeyOf(Double.class);
28 public static void main(String[] args) {
29 IHintStack stack = new HintStack();
30 stack.addHintListener(new IHintListener() {
32 public void hintChanged(IHintObservable sender, Key key,
33 Object oldValue, Object newValue) {
34 System.out.println("Hint changed: "+key+"="+newValue+" (was "+oldValue+")");
38 public void hintRemoved(IHintObservable sender, Key key,
40 System.out.println("Hint removed: "+key+" (was "+oldValue+")");
42 IHintContext c1 = new HintContext();
43 IHintContext c2 = new HintContext();
49 stack.addHintContext(c1, 0);
51 stack.addHintContext(c2, 1);
53 // underlying removed, do not do anything
54 stack.removeHintContext(c1);
56 // add over prev value, override
57 stack.addHintContext(c1, 2);
59 // should not do anything, is overridden
62 // changed. overrides c2
65 // removed. c2's value 3 becomes effective