KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > freemarker > eclipse > actions > ExpandBranchAction


1 package freemarker.eclipse.actions;
2
3 import org.eclipse.jface.action.Action;
4 import org.eclipse.jface.viewers.AbstractTreeViewer;
5 import org.eclipse.jface.viewers.ISelection;
6 import org.eclipse.jface.viewers.IStructuredSelection;
7
8 /**
9  * @version $Id:$
10  * @author <a HREF="mailto:stephan@chaquotay.net">Stephan Mueller</a>
11  */

12 public class ExpandBranchAction extends Action {
13     
14     private AbstractTreeViewer fViewer;
15
16     public ExpandBranchAction(AbstractTreeViewer aViewer) {
17         fViewer = aViewer;
18         setText("Expand");
19     }
20
21     /**
22      * @see org.eclipse.jface.action.IAction#run()
23      */

24     public void run() {
25         ISelection selection = fViewer.getSelection();
26         if (!selection.isEmpty()) {
27             fViewer.expandToLevel(((IStructuredSelection)selection).getFirstElement(),AbstractTreeViewer.ALL_LEVELS);
28         }
29     }
30
31 }
32
Popular Tags