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.TableViewer; 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 TablePart extends StructuredViewerPart { 26 27 31 public TablePart(String [] buttonLabels) { 32 super(buttonLabels); 33 } 34 35 38 protected StructuredViewer createStructuredViewer(Composite parent, int style, FormToolkit toolkit) { 39 style |= SWT.H_SCROLL | SWT.V_SCROLL; 40 if (toolkit == null) 41 style |= SWT.BORDER; 42 else 43 style |= toolkit.getBorderStyle(); 44 TableViewer tableViewer = new TableViewer(parent, style); 45 tableViewer.addSelectionChangedListener(new ISelectionChangedListener () { 46 public void selectionChanged(SelectionChangedEvent e) { 47 TablePart.this.selectionChanged((IStructuredSelection)e.getSelection()); 48 } 49 }); 50 tableViewer.addDoubleClickListener(new IDoubleClickListener() { 51 public void doubleClick(DoubleClickEvent e) { 52 TablePart.this.handleDoubleClick((IStructuredSelection)e.getSelection()); 53 } 54 }); 55 return tableViewer; 56 } 57 58 public TableViewer getTableViewer() { 59 return (TableViewer)getViewer(); 60 } 61 64 protected void buttonSelected(Button button, int index) { 65 } 66 67 protected void selectionChanged(IStructuredSelection selection) { 68 } 69 protected void handleDoubleClick(IStructuredSelection selection) { 70 } 71 } 72 | Popular Tags |