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.TreeViewer;
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 TreePart extends StructuredViewerPart {
25:
26: /**
27: * Constructor for TreePart.
28: * @param buttonLabels
29: */
30: public TreePart(String[] buttonLabels) {
31: super (buttonLabels);
32: }
33:
34: protected TreeViewer createTreeViewer(Composite parent, int style) {
35: return new TreeViewer(parent, style);
36: }
37:
38: /*
39: * @see StructuredViewerPart#createStructuredViewer(Composite, FormWidgetFactory)
40: */
41: protected StructuredViewer createStructuredViewer(Composite parent,
42: int style, FormToolkit toolkit) {
43: style |= SWT.H_SCROLL | SWT.V_SCROLL;
44: if (toolkit == null)
45: style |= SWT.BORDER;
46: else
47: style |= toolkit.getBorderStyle();
48: TreeViewer treeViewer = createTreeViewer(parent, style);
49: treeViewer
50: .addSelectionChangedListener(new ISelectionChangedListener() {
51: public void selectionChanged(SelectionChangedEvent e) {
52: TreePart.this
53: .selectionChanged((IStructuredSelection) e
54: .getSelection());
55: }
56: });
57: treeViewer.addDoubleClickListener(new IDoubleClickListener() {
58: public void doubleClick(DoubleClickEvent e) {
59: TreePart.this
60: .handleDoubleClick((IStructuredSelection) e
61: .getSelection());
62: }
63: });
64: return treeViewer;
65: }
66:
67: public TreeViewer getTreeViewer() {
68: return (TreeViewer) getViewer();
69: }
70:
71: /*
72: * @see SharedPartWithButtons#buttonSelected(int)
73: */
74: protected void buttonSelected(Button button, int index) {
75: }
76:
77: protected void selectionChanged(IStructuredSelection selection) {
78: }
79:
80: protected void handleDoubleClick(IStructuredSelection selection) {
81: }
82: }
|