KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > TreeSection


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor;
12
13 import org.eclipse.jface.viewers.IStructuredSelection;
14 import org.eclipse.jface.viewers.TreeViewer;
15 import org.eclipse.pde.internal.ui.parts.StructuredViewerPart;
16 import org.eclipse.pde.internal.ui.parts.TreePart;
17 import org.eclipse.swt.layout.GridLayout;
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 abstract class TreeSection extends StructuredViewerSection {
23     
24     protected boolean fHandleDefaultButton = true;
25     
26     class PartAdapter extends TreePart {
27         public PartAdapter(String JavaDoc[] buttonLabels) {
28             super(buttonLabels);
29         }
30         public void selectionChanged(IStructuredSelection selection) {
31             getManagedForm().fireSelectionChanged(TreeSection.this, selection);
32             TreeSection.this.selectionChanged(selection);
33         }
34         public void handleDoubleClick(IStructuredSelection selection) {
35             TreeSection.this.handleDoubleClick(selection);
36         }
37         public void buttonSelected(Button button, int index) {
38             TreeSection.this.buttonSelected(index);
39             if (fHandleDefaultButton)
40                 button.getShell().setDefaultButton(null);
41         }
42         protected void createButtons(Composite parent, FormToolkit toolkit) {
43             super.createButtons(parent, toolkit);
44             enableButtons();
45             if(parent.getData("filtered") != null) { //$NON-NLS-1$
46
GridLayout layout = (GridLayout) fButtonContainer.getLayout();
47                 layout.marginHeight = 28;
48             }
49         }
50
51         protected TreeViewer createTreeViewer(Composite parent, int style) {
52             return TreeSection.this.createTreeViewer(parent, style);
53         }
54
55     }
56     /**
57      * Constructor for TableSection.
58      * @param formPage
59      */

60     public TreeSection(PDEFormPage formPage, Composite parent, int style, String JavaDoc[] buttonLabels) {
61         super(formPage, parent, style, buttonLabels);
62     }
63
64     protected StructuredViewerPart createViewerPart(String JavaDoc[] buttonLabels) {
65         return new PartAdapter(buttonLabels);
66     }
67
68     protected TreePart getTreePart() {
69         return (TreePart) fViewerPart;
70     }
71
72     protected TreeViewer createTreeViewer(Composite parent, int style) {
73         return new TreeViewer(parent, style);
74     }
75
76     protected void selectionChanged(IStructuredSelection selection) {}
77     protected void handleDoubleClick(IStructuredSelection selection) {}
78     protected void enableButtons() {}
79 }
80
Popular Tags