X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2FExplorerState.java;fp=bundles%2Forg.simantics.browsing.ui%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2FExplorerState.java;h=ea513a0bc73faf2a927780ab34975d09f1b63f41;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/ExplorerState.java b/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/ExplorerState.java new file mode 100644 index 000000000..ea513a0bc --- /dev/null +++ b/bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/ExplorerState.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2013 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.browsing.ui; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * @author Tuukka Lehtonen + */ +public class ExplorerState { + + /** + * Default value for empty {@link #topNodePathChildIndex}. + */ + private static final int[] NO_CHILD_INDEXES = {}; + + /** + * Empty default value for ExplorerState. + */ + public static final ExplorerState EMPTY = new ExplorerState( + NodeContext.NONE, NO_CHILD_INDEXES, + Collections. emptyList(), + Collections. emptyMap()); + + /** + * An empty array of no top node path is set. + * @see NodeContext#NONE + */ + public final NodeContext[] topNodePath; + + /** + * Tells the child index of each node in {@link #topNodePath}. + * Must be the same size as {@link #topNodePath}. + */ + public final int[] topNodePathChildIndex; + + /** + * All the expanded nodes in the explorer. Never null. + */ + public final Collection expandedNodes; + + /** + * Widths of columns. + */ + public final Map columnWidths; + + /** + * @param topNodePath + * @param topNodePathChildIndex + * @param expandedNodes + * @param columnWidths + */ + public ExplorerState(NodeContext[] topNodePath, int[] topNodePathChildIndex, Collection expandedNodes, Map columnWidths) { + if (expandedNodes == null) + throw new IllegalArgumentException("null expanded nodes"); + this.topNodePath = topNodePath; + this.topNodePathChildIndex = topNodePathChildIndex; + this.expandedNodes = expandedNodes; + this.columnWidths = columnWidths; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[topNodePath=" + + Arrays.toString(topNodePath) + ", topNodePathChildIndex=" + + Arrays.toString(topNodePathChildIndex) + ", expandedNodes=" + + expandedNodes + ", " + columnWidths + "]"; + } + +}