]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/prioritystack/IPriorityStack.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / prioritystack / IPriorityStack.java
diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/prioritystack/IPriorityStack.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/prioritystack/IPriorityStack.java
new file mode 100644 (file)
index 0000000..ec29ca3
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/*\r
+ *\r
+ * @author Toni Kalajainen\r
+ */\r
+package org.simantics.utils.datastructures.prioritystack;\r
+\r
+import org.simantics.utils.threads.IThreadWorkQueue;\r
+\r
+\r
+/**\r
+ * Stack of interactor layers\r
+ * @param <E> type of stack items\r
+ */\r
+public interface IPriorityStack<E> {\r
+       \r
+       /**\r
+        * Put an item to the stack \r
+        * to the top of the stack.\r
+        * @param item\r
+        * @param priority \r
+        */\r
+       void add(E item, int priority);\r
+\r
+       /**\r
+        * Get priority of an item.\r
+        * Priority affects the event handing, hint overriding and to the paint order of \r
+        * the interactor.\r
+        * \r
+        * @param item the item\r
+        * @return priority of the interactor or <code>null</code> if item does not exist \r
+        */\r
+       Integer getPriority(E item);\r
+       \r
+       /**\r
+        * Remove item\r
+        * @param item\r
+        * @return true if was found and removed\r
+        */\r
+       boolean remove(E item); \r
+\r
+       /**\r
+        * Checks whether an item is in the stack\r
+        * @param item\r
+        * @return true if stack contains the specified item\r
+        */\r
+       boolean contains(E item);\r
+\r
+    /**\r
+     * Get all items by class. All items assignable to the specified class are\r
+     * returned.\r
+     * \r
+     * @param <R>\r
+     * @param clazz\r
+     * @return all items assignable to the specified class\r
+     */\r
+       <R extends E> R[] getItemsByClass(Class<R> clazz);\r
+\r
+    /**\r
+     * Get a single item by class. (Convenience method)\r
+     * \r
+     * @param <R>\r
+     * @param clazz\r
+     * @return a single item of the specified class\r
+     * @throws RuntimeException if single item was not found or if multiple\r
+     *         matching items were found\r
+     */\r
+       <R extends E> R getSingleItem(Class<R> clazz);\r
+       \r
+       /**\r
+        * Get a snapshot of all the items\r
+        * @return ordered list of items. The highest priority item is the last element.\r
+        */\r
+       E[] toArray();\r
+       \r
+       /**\r
+        * add listener\r
+        * @param thread\r
+        * @param listener\r
+        */\r
+       void addStackListener(IThreadWorkQueue thread, IPriorityStackListener<E> listener);\r
+       \r
+       /**\r
+        * remove listener\r
+        * @param thread\r
+        * @param listener\r
+        */\r
+       void removeStackListener(IThreadWorkQueue thread, IPriorityStackListener<E> listener);\r
+\r
+       /**\r
+        * add listener\r
+        * @param listener\r
+        */\r
+       void addStackListener(IPriorityStackListener<E> listener);\r
+       \r
+       /**\r
+        * remove listener\r
+        * @param listener\r
+        */\r
+       void removeStackListener(IPriorityStackListener<E> listener);\r
+       \r
+}\r