1 /*******************************************************************************
2 * Copyright (c) 2014 Dirk Fauth and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Dirk Fauth <dirk.fauth@ggooglemail.com> - initial API and implementation
10 *******************************************************************************/
11 package org.simantics.browsing.ui.nattable.override;
13 import org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler;
14 import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
15 import org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandToLevelCommand;
18 * Command handler for the TreeExpandLevelCommand.
20 * Will search over the whole tree structure in the associated TreeLayer to
21 * identify expandable nodes and expand them one after the other.
24 * @see TreeExpandToLevelCommand
27 public class TreeExpandToLevelCommandHandler extends AbstractLayerCommandHandler<TreeExpandToLevelCommand> {
30 * The TreeLayer to which this command handler is connected.
32 private final TreeLayer2 treeLayer;
37 * The TreeLayer to which this command handler should be
40 public TreeExpandToLevelCommandHandler(TreeLayer2 treeLayer) {
41 this.treeLayer = treeLayer;
45 public boolean doCommand(TreeExpandToLevelCommand command) {
46 if (command.getParentIndex() == null) {
47 this.treeLayer.expandAllToLevel(command.getLevel());
50 this.treeLayer.expandTreeRowToLevel(command.getParentIndex(), command.getLevel());
56 public Class<TreeExpandToLevelCommand> getCommandClass() {
57 return TreeExpandToLevelCommand.class;