1 /*******************************************************************************
2 * Copyright (c) 2013 Association for Decentralized Information Management
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
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui;
14 import java.util.Arrays;
15 import java.util.Collection;
16 import java.util.Collections;
20 * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>
22 public class ExplorerState {
25 * Default value for empty {@link #topNodePathChildIndex}.
27 private static final int[] NO_CHILD_INDEXES = {};
30 * Empty default value for ExplorerState.
32 public static final ExplorerState EMPTY = new ExplorerState(
33 NodeContext.NONE, NO_CHILD_INDEXES,
34 Collections.<NodeContext> emptyList(),
35 Collections.<String, Integer> emptyMap());
38 * An empty array of no top node path is set.
39 * @see NodeContext#NONE
41 public final NodeContext[] topNodePath;
44 * Tells the child index of each node in {@link #topNodePath}.
45 * Must be the same size as {@link #topNodePath}.
47 public final int[] topNodePathChildIndex;
50 * All the expanded nodes in the explorer. Never <code>null</code>.
52 public final Collection<NodeContext> expandedNodes;
57 public final Map<String, Integer> columnWidths;
61 * @param topNodePathChildIndex
62 * @param expandedNodes
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;
75 public String toString() {
76 return getClass().getSimpleName() + "[topNodePath="
77 + Arrays.toString(topNodePath) + ", topNodePathChildIndex="
78 + Arrays.toString(topNodePathChildIndex) + ", expandedNodes="
79 + expandedNodes + ", " + columnWidths + "]";