/******************************************************************************* * Copyright (c) 2014 Dirk Fauth and others. * 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: * Dirk Fauth - initial API and implementation *******************************************************************************/ package org.simantics.browsing.ui.nattable.override; import org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler; import org.eclipse.nebula.widgets.nattable.tree.TreeLayer; import org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandToLevelCommand; /** * Command handler for the TreeExpandLevelCommand. *

* Will search over the whole tree structure in the associated TreeLayer to * identify expandable nodes and expand them one after the other. * * @see TreeLayer * @see TreeExpandToLevelCommand * */ public class TreeExpandToLevelCommandHandler extends AbstractLayerCommandHandler { /** * The TreeLayer to which this command handler is connected. */ private final TreeLayer2 treeLayer; /** * * @param treeLayer * The TreeLayer to which this command handler should be * connected. */ public TreeExpandToLevelCommandHandler(TreeLayer2 treeLayer) { this.treeLayer = treeLayer; } @Override public boolean doCommand(TreeExpandToLevelCommand command) { if (command.getParentIndex() == null) { this.treeLayer.expandAllToLevel(command.getLevel()); } else { this.treeLayer.expandTreeRowToLevel(command.getParentIndex(), command.getLevel()); } return true; } @Override public Class getCommandClass() { return TreeExpandToLevelCommand.class; } }