KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > parts > SharedPart


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.parts;
12 import org.eclipse.swt.SWT;
13 import org.eclipse.swt.layout.GridData;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Label;
16 import org.eclipse.ui.forms.widgets.FormToolkit;
17
18
19 public abstract class SharedPart {
20     private boolean enabled = true;
21
22     public void setEnabled(boolean enabled) {
23         if (enabled != this.enabled) {
24             this.enabled = enabled;
25             updateEnabledState();
26         }
27     }
28
29     public abstract void createControl(
30         Composite parent,
31         int style,
32         int span,
33         FormToolkit toolkit);
34
35     public boolean isEnabled() {
36         return enabled;
37     }
38
39     protected void updateEnabledState() {
40     }
41
42     protected Composite createComposite(
43         Composite parent,
44         FormToolkit toolkit) {
45         if (toolkit == null)
46             return new Composite(parent, SWT.NULL);
47         return toolkit.createComposite(parent);
48     }
49     protected Label createEmptySpace(
50         Composite parent,
51         int span,
52         FormToolkit toolkit) {
53         Label label;
54         if (toolkit != null) {
55             label = toolkit.createLabel(parent, null);
56         } else {
57             label = new Label(parent, SWT.NULL);
58         }
59         GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
60         gd.horizontalSpan= span;
61         gd.widthHint= 0;
62         gd.heightHint= 0;
63         label.setLayoutData(gd);
64         return label;
65     }
66 }
67
Popular Tags