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.CheckStateChangedEvent;
13: import org.eclipse.jface.viewers.CheckboxTableViewer;
14: import org.eclipse.jface.viewers.ICheckStateListener;
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.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 CheckboxTablePart extends StructuredViewerPart {
25: public CheckboxTablePart(String[] buttonLabels) {
26: super (buttonLabels);
27: }
28:
29: /*
30: * @see StructuredViewerPart#createStructuredViewer(Composite, FormWidgetFactory)
31: */
32: protected StructuredViewer createStructuredViewer(Composite parent,
33: 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: }
40: CheckboxTableViewer tableViewer = CheckboxTableViewer
41: .newCheckList(parent, style);
42: tableViewer
43: .addSelectionChangedListener(new ISelectionChangedListener() {
44: public void selectionChanged(SelectionChangedEvent e) {
45: CheckboxTablePart.this
46: .selectionChanged((IStructuredSelection) e
47: .getSelection());
48: }
49: });
50: tableViewer.addCheckStateListener(new ICheckStateListener() {
51: public void checkStateChanged(CheckStateChangedEvent event) {
52: elementChecked(event.getElement(), event.getChecked());
53: }
54: });
55: return tableViewer;
56: }
57:
58: public CheckboxTableViewer getTableViewer() {
59: return (CheckboxTableViewer) getViewer();
60: }
61:
62: /*
63: * @see SharedPartWithButtons#buttonSelected(int)
64: */
65: protected void buttonSelected(Button button, int index) {
66: }
67:
68: protected void elementChecked(Object element, boolean checked) {
69: }
70:
71: protected void selectionChanged(IStructuredSelection selection) {
72: }
73: }
|