KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > properties > tabbed > TabbedPropertySheetWidgetFactory


1 /*******************************************************************************
2  * Copyright (c) 2001, 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.ui.views.properties.tabbed;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.custom.CCombo;
15 import org.eclipse.swt.custom.CLabel;
16 import org.eclipse.swt.custom.CTabFolder;
17 import org.eclipse.swt.custom.CTabItem;
18 import org.eclipse.swt.custom.ScrolledComposite;
19 import org.eclipse.swt.layout.FormLayout;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.swt.widgets.Display;
22 import org.eclipse.swt.widgets.Group;
23 import org.eclipse.swt.widgets.List;
24 import org.eclipse.ui.forms.widgets.FormToolkit;
25
26 /**
27  * A FormToolkit customized for use by tabbed property sheet page.
28  *
29  * @author Anthony Hunter
30  */

31 public class TabbedPropertySheetWidgetFactory
32     extends FormToolkit {
33
34     /**
35      * private constructor.
36      */

37     public TabbedPropertySheetWidgetFactory() {
38         super(Display.getCurrent());
39     }
40
41     /**
42      * Creates the tab folder as a part of the form.
43      *
44      * @param parent
45      * the composite parent.
46      * @param style
47      * the tab folder style.
48      * @return the tab folder
49      */

50     public CTabFolder createTabFolder(Composite parent, int style) {
51         CTabFolder tabFolder = new CTabFolder(parent, style);
52         return tabFolder;
53     }
54
55     /**
56      * Creates the tab item as a part of the tab folder.
57      *
58      * @param tabFolder
59      * the parent.
60      * @param style
61      * the tab folder style.
62      * @return the tab item.
63      */

64     public CTabItem createTabItem(CTabFolder tabFolder, int style) {
65         CTabItem tabItem = new CTabItem(tabFolder, style);
66         return tabItem;
67     }
68
69     /**
70      * Creates the list as a part of the form.
71      *
72      * @param parent
73      * the composite parent.
74      * @param style
75      * the list style.
76      * @return the list.
77      */

78     public List createList(Composite parent, int style) {
79         List list = new org.eclipse.swt.widgets.List(parent, style);
80         return list;
81     }
82
83     public Composite createComposite(Composite parent, int style) {
84         Composite c = super.createComposite(parent, style);
85         paintBordersFor(c);
86         return c;
87     }
88
89     public Composite createComposite(Composite parent) {
90         Composite c = createComposite(parent, SWT.NONE);
91         return c;
92     }
93
94     /**
95      * Creates a plain composite as a part of the form.
96      *
97      * @param parent
98      * the composite parent.
99      * @param style
100      * the composite style.
101      * @return the composite.
102      */

103     public Composite createPlainComposite(Composite parent, int style) {
104         Composite c = super.createComposite(parent, style);
105         c.setBackground(parent.getBackground());
106         paintBordersFor(c);
107         return c;
108     }
109
110     /**
111      * Creates a scrolled composite as a part of the form.
112      *
113      * @param parent
114      * the composite parent.
115      * @param style
116      * the composite style.
117      * @return the composite.
118      */

119     public ScrolledComposite createScrolledComposite(Composite parent, int style) {
120         ScrolledComposite scrolledComposite = new ScrolledComposite(parent,
121             style);
122         return scrolledComposite;
123     }
124
125     /**
126      * Creates a combo box as a part of the form.
127      *
128      * @param parent
129      * the combo box parent.
130      * @param comboStyle
131      * the combo box style.
132      * @return the combo box.
133      */

134     public CCombo createCCombo(Composite parent, int comboStyle) {
135         CCombo combo = new CCombo(parent, comboStyle);
136         adapt(combo, true, false);
137         // Bugzilla 145837 - workaround for no borders on Windows XP
138
if (getBorderStyle() == SWT.BORDER) {
139             combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
140         }
141         return combo;
142     }
143
144     /**
145      * Creates a combo box as a part of the form.
146      *
147      * @param parent
148      * the combo box parent.
149      * @return the combo box.
150      */

151     public CCombo createCCombo(Composite parent) {
152         return createCCombo(parent, SWT.FLAT | SWT.READ_ONLY);
153     }
154
155     /**
156      * Creates a group as a part of the form.
157      *
158      * @param parent
159      * the group parent.
160      * @param text
161      * the group title.
162      * @return the composite.
163      */

164     public Group createGroup(Composite parent, String JavaDoc text) {
165         Group group = new Group(parent, SWT.SHADOW_NONE);
166         group.setText(text);
167         group.setBackground(getColors().getBackground());
168         group.setForeground(getColors().getForeground());
169         return group;
170     }
171
172     /**
173      * Creates a flat form composite as a part of the form.
174      *
175      * @param parent
176      * the composite parent.
177      * @return the composite.
178      */

179     public Composite createFlatFormComposite(Composite parent) {
180         Composite composite = createComposite(parent);
181         FormLayout layout = new FormLayout();
182         layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2;
183         layout.marginHeight = ITabbedPropertyConstants.VSPACE;
184         layout.spacing = ITabbedPropertyConstants.VMARGIN + 1;
185         composite.setLayout(layout);
186         return composite;
187     }
188
189     /**
190      * Creates a label as a part of the form.
191      *
192      * @param parent
193      * the label parent.
194      * @param text
195      * the label text.
196      * @return the label.
197      */

198     public CLabel createCLabel(Composite parent, String JavaDoc text) {
199         return createCLabel(parent, text, SWT.NONE);
200     }
201
202     /**
203      * Creates a label as a part of the form.
204      *
205      * @param parent
206      * the label parent.
207      * @param text
208      * the label text.
209      * @param style
210      * the label style.
211      * @return the label.
212      */

213     public CLabel createCLabel(Composite parent, String JavaDoc text, int style) {
214         final CLabel label = new CLabel(parent, style);
215         label.setBackground(parent.getBackground());
216         label.setText(text);
217         return label;
218     }
219
220     public void dispose() {
221         if (getColors() != null) {
222             super.dispose();
223         }
224     }
225 }
226
Popular Tags