1 /******************************************************************************* 2 * Copyright (c) 2000, 2018 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.pde.internal.ui.parts; 15 16 import org.eclipse.jface.viewers.*; 17 import org.eclipse.swt.SWT; 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 class TablePart extends StructuredViewerPart { 23 24 /** 25 * Constructor for TablePart. 26 * @param buttonLabels 27 */ TablePart(String[] buttonLabels)28 public TablePart(String[] buttonLabels) { 29 super(buttonLabels); 30 } 31 32 @Override createStructuredViewer(Composite parent, int style, FormToolkit toolkit)33 protected StructuredViewer createStructuredViewer(Composite parent, int style, FormToolkit toolkit) { 34 style |= SWT.H_SCROLL | SWT.V_SCROLL; 35 if (toolkit == null) 36 style |= SWT.BORDER; 37 else 38 style |= toolkit.getBorderStyle(); 39 TableViewer tableViewer = new TableViewer(parent, style); 40 tableViewer.addSelectionChangedListener(e -> TablePart.this.selectionChanged(e.getStructuredSelection())); 41 tableViewer.addDoubleClickListener(e -> TablePart.this.handleDoubleClick((IStructuredSelection) e.getSelection())); 42 return tableViewer; 43 } 44 getTableViewer()45 public TableViewer getTableViewer() { 46 return (TableViewer) getViewer(); 47 } 48 49 @Override buttonSelected(Button button, int index)50 protected void buttonSelected(Button button, int index) { 51 } 52 selectionChanged(IStructuredSelection selection)53 protected void selectionChanged(IStructuredSelection selection) { 54 } 55 handleDoubleClick(IStructuredSelection selection)56 protected void handleDoubleClick(IStructuredSelection selection) { 57 } 58 } 59