01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.parts;
11:
12: import org.eclipse.jface.viewers.DoubleClickEvent;
13: import org.eclipse.jface.viewers.IDoubleClickListener;
14: import org.eclipse.jface.viewers.ISelectionChangedListener;
15: import org.eclipse.jface.viewers.IStructuredSelection;
16: import org.eclipse.jface.viewers.SelectionChangedEvent;
17: import org.eclipse.jface.viewers.StructuredViewer;
18: import org.eclipse.jface.viewers.TableViewer;
19: import org.eclipse.swt.SWT;
20: import org.eclipse.swt.widgets.Button;
21: import org.eclipse.swt.widgets.Composite;
22: import org.eclipse.ui.forms.widgets.FormToolkit;
23:
24: public class TablePart extends StructuredViewerPart {
25:
26: /**
27: * Constructor for TablePart.
28: * @param buttonLabels
29: */
30: public TablePart(String[] buttonLabels) {
31: super (buttonLabels);
32: }
33:
34: /*
35: * @see StructuredViewerPart#createStructuredViewer(Composite, FormWidgetFactory)
36: */
37: protected StructuredViewer createStructuredViewer(Composite parent,
38: 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
46: .addSelectionChangedListener(new ISelectionChangedListener() {
47: public void selectionChanged(SelectionChangedEvent e) {
48: TablePart.this
49: .selectionChanged((IStructuredSelection) e
50: .getSelection());
51: }
52: });
53: tableViewer.addDoubleClickListener(new IDoubleClickListener() {
54: public void doubleClick(DoubleClickEvent e) {
55: TablePart.this
56: .handleDoubleClick((IStructuredSelection) e
57: .getSelection());
58: }
59: });
60: return tableViewer;
61: }
62:
63: public TableViewer getTableViewer() {
64: return (TableViewer) getViewer();
65: }
66:
67: /*
68: * @see SharedPartWithButtons#buttonSelected(int)
69: */
70: protected void buttonSelected(Button button, int index) {
71: }
72:
73: protected void selectionChanged(IStructuredSelection selection) {
74: }
75:
76: protected void handleDoubleClick(IStructuredSelection selection) {
77: }
78: }
|