]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/ExplorerState.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui / src / org / simantics / browsing / ui / ExplorerState.java
1 /*******************************************************************************\r
2  * Copyright (c) 2013 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  *     Semantum Oy - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.browsing.ui;\r
13 \r
14 import java.util.Arrays;\r
15 import java.util.Collection;\r
16 import java.util.Collections;\r
17 import java.util.Map;\r
18 \r
19 /**\r
20  * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>\r
21  */\r
22 public class ExplorerState {\r
23 \r
24         /**\r
25          * Default value for empty {@link #topNodePathChildIndex}.\r
26          */\r
27         private static final int[] NO_CHILD_INDEXES = {};\r
28 \r
29         /**\r
30          * Empty default value for ExplorerState.\r
31          */\r
32         public static final ExplorerState EMPTY = new ExplorerState(\r
33                         NodeContext.NONE, NO_CHILD_INDEXES,\r
34                         Collections.<NodeContext> emptyList(),\r
35                         Collections.<String, Integer> emptyMap());\r
36 \r
37         /**\r
38          * An empty array of no top node path is set.\r
39          * @see NodeContext#NONE\r
40          */\r
41         public final NodeContext[] topNodePath;\r
42 \r
43         /**\r
44          * Tells the child index of each node in {@link #topNodePath}. \r
45          * Must be the same size as {@link #topNodePath}.\r
46          */\r
47         public final int[] topNodePathChildIndex;\r
48 \r
49         /**\r
50          * All the expanded nodes in the explorer. Never <code>null</code>.\r
51          */\r
52         public final Collection<NodeContext> expandedNodes;\r
53 \r
54         /**\r
55          * Widths of columns.\r
56          */\r
57         public final Map<String, Integer> columnWidths;\r
58 \r
59         /**\r
60          * @param topNodePath\r
61          * @param topNodePathChildIndex\r
62          * @param expandedNodes\r
63          * @param columnWidths \r
64          */\r
65         public ExplorerState(NodeContext[] topNodePath, int[] topNodePathChildIndex, Collection<NodeContext> expandedNodes, Map<String, Integer> columnWidths) {\r
66                 if (expandedNodes == null)\r
67                         throw new IllegalArgumentException("null expanded nodes");\r
68                 this.topNodePath = topNodePath;\r
69                 this.topNodePathChildIndex = topNodePathChildIndex;\r
70                 this.expandedNodes = expandedNodes;\r
71                 this.columnWidths = columnWidths;\r
72         }\r
73 \r
74         @Override\r
75         public String toString() {\r
76                 return getClass().getSimpleName() + "[topNodePath="\r
77                                 + Arrays.toString(topNodePath) + ", topNodePathChildIndex="\r
78                                 + Arrays.toString(topNodePathChildIndex) + ", expandedNodes="\r
79                                 + expandedNodes + ", " + columnWidths + "]";\r
80         }\r
81 \r
82 }\r