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