1 11 package org.eclipse.pde.internal.ui.editor; 12 13 import org.eclipse.jface.viewers.IStructuredSelection; 14 import org.eclipse.jface.viewers.TreeViewer; 15 import org.eclipse.pde.internal.ui.parts.StructuredViewerPart; 16 import org.eclipse.pde.internal.ui.parts.TreePart; 17 import org.eclipse.swt.layout.GridLayout; 18 import org.eclipse.swt.widgets.Button; 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.ui.forms.widgets.FormToolkit; 21 22 public abstract class TreeSection extends StructuredViewerSection { 23 24 protected boolean fHandleDefaultButton = true; 25 26 class PartAdapter extends TreePart { 27 public PartAdapter(String [] buttonLabels) { 28 super(buttonLabels); 29 } 30 public void selectionChanged(IStructuredSelection selection) { 31 getManagedForm().fireSelectionChanged(TreeSection.this, selection); 32 TreeSection.this.selectionChanged(selection); 33 } 34 public void handleDoubleClick(IStructuredSelection selection) { 35 TreeSection.this.handleDoubleClick(selection); 36 } 37 public void buttonSelected(Button button, int index) { 38 TreeSection.this.buttonSelected(index); 39 if (fHandleDefaultButton) 40 button.getShell().setDefaultButton(null); 41 } 42 protected void createButtons(Composite parent, FormToolkit toolkit) { 43 super.createButtons(parent, toolkit); 44 enableButtons(); 45 if(parent.getData("filtered") != null) { GridLayout layout = (GridLayout) fButtonContainer.getLayout(); 47 layout.marginHeight = 28; 48 } 49 } 50 51 protected TreeViewer createTreeViewer(Composite parent, int style) { 52 return TreeSection.this.createTreeViewer(parent, style); 53 } 54 55 } 56 60 public TreeSection(PDEFormPage formPage, Composite parent, int style, String [] buttonLabels) { 61 super(formPage, parent, style, buttonLabels); 62 } 63 64 protected StructuredViewerPart createViewerPart(String [] buttonLabels) { 65 return new PartAdapter(buttonLabels); 66 } 67 68 protected TreePart getTreePart() { 69 return (TreePart) fViewerPart; 70 } 71 72 protected TreeViewer createTreeViewer(Composite parent, int style) { 73 return new TreeViewer(parent, style); 74 } 75 76 protected void selectionChanged(IStructuredSelection selection) {} 77 protected void handleDoubleClick(IStructuredSelection selection) {} 78 protected void enableButtons() {} 79 } 80 | Popular Tags |