1 11 package org.eclipse.pde.internal.ui.view; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.action.IMenuManager; 15 import org.eclipse.jface.action.IStatusLineManager; 16 import org.eclipse.jface.action.IToolBarManager; 17 import org.eclipse.jface.viewers.ITreeContentProvider; 18 import org.eclipse.jface.viewers.StructuredViewer; 19 import org.eclipse.jface.viewers.TreeViewer; 20 import org.eclipse.pde.internal.ui.PDEPluginImages; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 import org.eclipse.pde.internal.ui.wizards.ListUtil; 23 import org.eclipse.swt.SWT; 24 import org.eclipse.swt.events.DisposeEvent; 25 import org.eclipse.swt.events.DisposeListener; 26 import org.eclipse.swt.widgets.Composite; 27 28 public class DependenciesViewTreePage extends DependenciesViewPage { 29 class CollapseAllAction extends Action { 30 public CollapseAllAction() { 31 super(); 32 setText(PDEUIMessages.DependenciesViewTreePage_CollapseAllAction_label); 33 setDescription(PDEUIMessages.DependenciesViewTreePage_CollapseAllAction_description); 34 setToolTipText(PDEUIMessages.DependenciesViewTreePage_CollapseAllAction_tooltip); 35 setImageDescriptor(PDEPluginImages.DESC_COLLAPSE_ALL); 36 setDisabledImageDescriptor(PDEPluginImages.DESC_COLLAPSE_ALL); 37 } 38 39 44 public void run() { 45 super.run(); 46 fTreeViewer.collapseAll(); 47 } 48 } 49 50 ITreeContentProvider fContentProvider; 51 52 TreeViewer fTreeViewer; 53 54 public DependenciesViewTreePage(DependenciesView view, 55 ITreeContentProvider contentProvider) { 56 super(view); 57 fContentProvider = contentProvider; 58 } 59 60 65 protected StructuredViewer createViewer(Composite parent) { 66 fTreeViewer = new TreeViewer(parent, SWT.MULTI | SWT.V_SCROLL 67 | SWT.H_SCROLL); 68 fTreeViewer.setContentProvider(fContentProvider); 69 final DependenciesLabelProvider labelProvider = new DependenciesLabelProvider( 70 true); 71 fTreeViewer.setLabelProvider(labelProvider); 72 fTreeViewer.getControl().addDisposeListener(new DisposeListener() { 73 public void widgetDisposed(DisposeEvent e) { 74 labelProvider.dispose(); 75 } 76 }); 77 fTreeViewer.setSorter(ListUtil.PLUGIN_SORTER); 78 fTreeViewer.setAutoExpandLevel(2); 79 80 return fTreeViewer; 81 } 82 83 90 public void makeContributions(IMenuManager menuManager, 91 IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { 92 super.makeContributions(menuManager, toolBarManager, statusLineManager); 93 if (toolBarManager.find(DependenciesView.TREE_ACTION_GROUP) != null) 94 toolBarManager.prependToGroup(DependenciesView.TREE_ACTION_GROUP, 95 new CollapseAllAction()); 96 else 97 toolBarManager.add(new CollapseAllAction()); 98 } 99 } 100 | Popular Tags |