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
14 * @author Toni Kalajainen
\r
16 package org.simantics.utils.datastructures.prioritystack;
\r
18 import org.simantics.utils.threads.IThreadWorkQueue;
\r
22 * Stack of interactor layers
\r
23 * @param <E> type of stack items
\r
25 public interface IPriorityStack<E> {
\r
28 * Put an item to the stack
\r
29 * to the top of the stack.
\r
33 void add(E item, int priority);
\r
36 * Get priority of an item.
\r
37 * Priority affects the event handing, hint overriding and to the paint order of
\r
40 * @param item the item
\r
41 * @return priority of the interactor or <code>null</code> if item does not exist
\r
43 Integer getPriority(E item);
\r
48 * @return true if was found and removed
\r
50 boolean remove(E item);
\r
53 * Checks whether an item is in the stack
\r
55 * @return true if stack contains the specified item
\r
57 boolean contains(E item);
\r
60 * Get all items by class. All items assignable to the specified class are
\r
65 * @return all items assignable to the specified class
\r
67 <R extends E> R[] getItemsByClass(Class<R> clazz);
\r
70 * Get a single item by class. (Convenience method)
\r
74 * @return a single item of the specified class
\r
75 * @throws RuntimeException if single item was not found or if multiple
\r
76 * matching items were found
\r
78 <R extends E> R getSingleItem(Class<R> clazz);
\r
81 * Get a snapshot of all the items
\r
82 * @return ordered list of items. The highest priority item is the last element.
\r
91 void addStackListener(IThreadWorkQueue thread, IPriorityStackListener<E> listener);
\r
98 void removeStackListener(IThreadWorkQueue thread, IPriorityStackListener<E> listener);
\r
104 void addStackListener(IPriorityStackListener<E> listener);
\r
110 void removeStackListener(IPriorityStackListener<E> listener);
\r