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
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui;
\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
20 * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>
\r
22 public class ExplorerState {
\r
25 * Default value for empty {@link #topNodePathChildIndex}.
\r
27 private static final int[] NO_CHILD_INDEXES = {};
\r
30 * Empty default value for ExplorerState.
\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
38 * An empty array of no top node path is set.
\r
39 * @see NodeContext#NONE
\r
41 public final NodeContext[] topNodePath;
\r
44 * Tells the child index of each node in {@link #topNodePath}.
\r
45 * Must be the same size as {@link #topNodePath}.
\r
47 public final int[] topNodePathChildIndex;
\r
50 * All the expanded nodes in the explorer. Never <code>null</code>.
\r
52 public final Collection<NodeContext> expandedNodes;
\r
55 * Widths of columns.
\r
57 public final Map<String, Integer> columnWidths;
\r
60 * @param topNodePath
\r
61 * @param topNodePathChildIndex
\r
62 * @param expandedNodes
\r
63 * @param columnWidths
\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
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