1 11 package org.eclipse.pde.internal.ui.parts; 12 13 import org.eclipse.jface.viewers.DoubleClickEvent; 14 import org.eclipse.jface.viewers.IDoubleClickListener; 15 import org.eclipse.jface.viewers.ISelectionChangedListener; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.jface.viewers.SelectionChangedEvent; 18 import org.eclipse.jface.viewers.StructuredViewer; 19 import org.eclipse.jface.viewers.TreeViewer; 20 import org.eclipse.swt.SWT; 21 import org.eclipse.swt.widgets.Button; 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.ui.forms.widgets.FormToolkit; 24 25 public class TreePart extends StructuredViewerPart { 26 27 31 public TreePart(String [] buttonLabels) { 32 super(buttonLabels); 33 } 34 35 protected TreeViewer createTreeViewer(Composite parent, int style) { 36 return new TreeViewer(parent, style); 37 } 38 39 42 protected StructuredViewer createStructuredViewer(Composite parent, int style, FormToolkit toolkit) { 43 style |= SWT.H_SCROLL | SWT.V_SCROLL; 44 if (toolkit == null) 45 style |= SWT.BORDER; 46 else 47 style |= toolkit.getBorderStyle(); 48 TreeViewer treeViewer = createTreeViewer(parent, style); 49 treeViewer.addSelectionChangedListener(new ISelectionChangedListener () { 50 public void selectionChanged(SelectionChangedEvent e) { 51 TreePart.this.selectionChanged((IStructuredSelection)e.getSelection()); 52 } 53 }); 54 treeViewer.addDoubleClickListener(new IDoubleClickListener() { 55 public void doubleClick(DoubleClickEvent e) { 56 TreePart.this.handleDoubleClick((IStructuredSelection)e.getSelection()); 57 } 58 }); 59 return treeViewer; 60 } 61 62 public TreeViewer getTreeViewer() { 63 return (TreeViewer)getViewer(); 64 } 65 68 protected void buttonSelected(Button button, int index) { 69 } 70 71 protected void selectionChanged(IStructuredSelection selection) { 72 } 73 protected void handleDoubleClick(IStructuredSelection selection) { 74 } 75 } 76 | Popular Tags |