--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 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
+ * Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.browsing.ui;\r
+\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>\r
+ */\r
+public class ExplorerState {\r
+\r
+ /**\r
+ * Default value for empty {@link #topNodePathChildIndex}.\r
+ */\r
+ private static final int[] NO_CHILD_INDEXES = {};\r
+\r
+ /**\r
+ * Empty default value for ExplorerState.\r
+ */\r
+ public static final ExplorerState EMPTY = new ExplorerState(\r
+ NodeContext.NONE, NO_CHILD_INDEXES,\r
+ Collections.<NodeContext> emptyList(),\r
+ Collections.<String, Integer> emptyMap());\r
+\r
+ /**\r
+ * An empty array of no top node path is set.\r
+ * @see NodeContext#NONE\r
+ */\r
+ public final NodeContext[] topNodePath;\r
+\r
+ /**\r
+ * Tells the child index of each node in {@link #topNodePath}. \r
+ * Must be the same size as {@link #topNodePath}.\r
+ */\r
+ public final int[] topNodePathChildIndex;\r
+\r
+ /**\r
+ * All the expanded nodes in the explorer. Never <code>null</code>.\r
+ */\r
+ public final Collection<NodeContext> expandedNodes;\r
+\r
+ /**\r
+ * Widths of columns.\r
+ */\r
+ public final Map<String, Integer> columnWidths;\r
+\r
+ /**\r
+ * @param topNodePath\r
+ * @param topNodePathChildIndex\r
+ * @param expandedNodes\r
+ * @param columnWidths \r
+ */\r
+ public ExplorerState(NodeContext[] topNodePath, int[] topNodePathChildIndex, Collection<NodeContext> expandedNodes, Map<String, Integer> columnWidths) {\r
+ if (expandedNodes == null)\r
+ throw new IllegalArgumentException("null expanded nodes");\r
+ this.topNodePath = topNodePath;\r
+ this.topNodePathChildIndex = topNodePathChildIndex;\r
+ this.expandedNodes = expandedNodes;\r
+ this.columnWidths = columnWidths;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return getClass().getSimpleName() + "[topNodePath="\r
+ + Arrays.toString(topNodePath) + ", topNodePathChildIndex="\r
+ + Arrays.toString(topNodePathChildIndex) + ", expandedNodes="\r
+ + expandedNodes + ", " + columnWidths + "]";\r
+ }\r
+\r
+}\r