]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/override/TreeCollapseAllCommandHandler.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 / TreeCollapseAllCommandHandler.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.TreeCollapseAllCommand;
17
18 /**
19  * Command handler for the TreeCollapseAllCommand.
20  * <p>
21  * Will search over the whole tree structure in the associated TreeLayer to
22  * identify collapsible nodes and collapse them one after the other.
23  *
24  * @author Dirk Fauth
25  *
26  * @see TreeLayer
27  * @see TreeCollapseAllCommand
28  */
29 public class TreeCollapseAllCommandHandler implements
30         ILayerCommandHandler<TreeCollapseAllCommand> {
31
32     /**
33      * The TreeLayer to which this command handler is connected.
34      */
35     private final TreeLayer2 treeLayer;
36
37     /**
38      *
39      * @param treeLayer
40      *            The TreeLayer to which this command handler should be
41      *            connected.
42      */
43     public TreeCollapseAllCommandHandler(TreeLayer2 treeLayer) {
44         this.treeLayer = treeLayer;
45     }
46
47     @Override
48     public boolean doCommand(ILayer targetLayer, TreeCollapseAllCommand command) {
49         this.treeLayer.collapseAll();
50         return true;
51     }
52
53     @Override
54     public Class<TreeCollapseAllCommand> getCommandClass() {
55         return TreeCollapseAllCommand.class;
56     }
57
58 }