KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > actions > CollapseAllAction


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.navigator.actions;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.ui.internal.navigator.CommonNavigatorMessages;
16 import org.eclipse.ui.navigator.CommonViewer;
17
18 /**
19  * This action delegate collapses all expanded elements in a Navigator view.
20  *
21  */

22 public class CollapseAllAction extends Action implements IAction {
23
24     private final CommonViewer commonViewer;
25
26     /**
27      * Create the CollapseAll action.
28      *
29      * @param aViewer
30      * The viewer to be collapsed.
31      */

32     public CollapseAllAction(CommonViewer aViewer) {
33         super(CommonNavigatorMessages.CollapseAllActionDelegate_0);
34         setToolTipText(CommonNavigatorMessages.CollapseAllActionDelegate_0);
35         commonViewer = aViewer;
36     }
37
38     public void run() {
39         if (commonViewer != null) {
40             commonViewer.collapseAll();
41         }
42     }
43 }
44
Popular Tags