X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.nattable%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fnattable%2Foverride%2FTreeCollapseAllCommandHandler.java;fp=bundles%2Forg.simantics.browsing.ui.nattable%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fnattable%2Foverride%2FTreeCollapseAllCommandHandler.java;h=3060f5525753bb84b9c3df0c7096a4602035c520;hp=0000000000000000000000000000000000000000;hb=96bb7ef9cbe42d82eb58306d8f9b62392cc29ba8;hpb=ae5bb63c5c88f6569518fed2a24df86fbd0570ff diff --git a/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/override/TreeCollapseAllCommandHandler.java b/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/override/TreeCollapseAllCommandHandler.java new file mode 100644 index 000000000..3060f5525 --- /dev/null +++ b/bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/override/TreeCollapseAllCommandHandler.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2013 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.ILayerCommandHandler; +import org.eclipse.nebula.widgets.nattable.layer.ILayer; +import org.eclipse.nebula.widgets.nattable.tree.TreeLayer; +import org.eclipse.nebula.widgets.nattable.tree.command.TreeCollapseAllCommand; + +/** + * Command handler for the TreeCollapseAllCommand. + *

+ * Will search over the whole tree structure in the associated TreeLayer to + * identify collapsible nodes and collapse them one after the other. + * + * @author Dirk Fauth + * + * @see TreeLayer + * @see TreeCollapseAllCommand + */ +public class TreeCollapseAllCommandHandler implements + ILayerCommandHandler { + + /** + * 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 TreeCollapseAllCommandHandler(TreeLayer2 treeLayer) { + this.treeLayer = treeLayer; + } + + @Override + public boolean doCommand(ILayer targetLayer, TreeCollapseAllCommand command) { + this.treeLayer.collapseAll(); + return true; + } + + @Override + public Class getCommandClass() { + return TreeCollapseAllCommand.class; + } + +}