]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/override/TreeExpandAllCommandHandler.java
Sync git svn branch with SVN repository r33144.
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / override / TreeExpandAllCommandHandler.java
1 /*******************************************************************************
2  * Copyright (c) 2013 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
7  *
8  * Contributors:
9  *    Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation
10  *******************************************************************************/
11 package org.simantics.browsing.ui.nattable.override;
12
13 import org.eclipse.nebula.widgets.nattable.command.ILayerCommandHandler;
14 import org.eclipse.nebula.widgets.nattable.layer.ILayer;
15 import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
16 import org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandAllCommand;
17
18 /**
19  * Command handler for the TreeExpandAllCommand.
20  * <p>
21  * Will search over the whole tree structure in the associated TreeLayer to
22  * identify expandable nodes and expand them one after the other.
23  *
24  * @author Dirk Fauth
25  *
26  * @see TreeLayer
27  * @see TreeExpandAllCommand
28  *
29  */
30 public class TreeExpandAllCommandHandler implements
31         ILayerCommandHandler<TreeExpandAllCommand> {
32
33     /**
34      * The TreeLayer to which this command handler is connected.
35      */
36     private final TreeLayer2 treeLayer;
37
38     /**
39      *
40      * @param treeLayer
41      *            The TreeLayer to which this command handler should be
42      *            connected.
43      */
44     public TreeExpandAllCommandHandler(TreeLayer2 treeLayer) {
45         this.treeLayer = treeLayer;
46     }
47
48     @Override
49     public boolean doCommand(ILayer targetLayer, TreeExpandAllCommand command) {
50         this.treeLayer.expandAll();
51         return true;
52     }
53
54     @Override
55     public Class<TreeExpandAllCommand> getCommandClass() {
56         return TreeExpandAllCommand.class;
57     }
58
59 }