Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d0a448dee7b91d47d2e90c80c0ad1a3bc2094de3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*******************************************************************************
 * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.ui.trees;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.interfaces.ImageConsts;
import org.eclipse.tcf.te.ui.nls.Messages;

/**
 * The action to collapse all the expanded branches in the tree control.
 */
public class CollapseAllAction extends Action {
	// The tree control whose expanded branches are to be collapsed.
	private AbstractTreeControl treeControl;

	/**
	 * Create an instance for the specified tree control.
	 * 
	 * @param treeControl The tree control to be collapsed.
	 */
	public CollapseAllAction(AbstractTreeControl treeControl) {
		super(null, AS_PUSH_BUTTON);
		this.treeControl = treeControl;
		this.setToolTipText(Messages.CollapseAllAction_Tooltip);
		ImageDescriptor image = UIPlugin.getImageDescriptor(ImageConsts.VIEWER_COLLAPSE_ALL);
		setImageDescriptor(image);
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.jface.action.Action#run()
	 */
	@Override
	public void run() {
		TreeViewer viewer = (TreeViewer) treeControl.getViewer();
		viewer.collapseAll();
	}
}

Back to the top