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.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: public abstract class SharedPart {
19: private boolean enabled = true;
20:
21: public void setEnabled(boolean enabled) {
22: if (enabled != this .enabled) {
23: this .enabled = enabled;
24: updateEnabledState();
25: }
26: }
27:
28: public abstract void createControl(Composite parent, int style,
29: int span, FormToolkit toolkit);
30:
31: public boolean isEnabled() {
32: return enabled;
33: }
34:
35: protected void updateEnabledState() {
36: }
37:
38: protected Composite createComposite(Composite parent,
39: FormToolkit toolkit) {
40: if (toolkit == null)
41: return new Composite(parent, SWT.NULL);
42: return toolkit.createComposite(parent);
43: }
44:
45: protected Label createEmptySpace(Composite parent, int span,
46: FormToolkit toolkit) {
47: Label label;
48: if (toolkit != null) {
49: label = toolkit.createLabel(parent, null);
50: } else {
51: label = new Label(parent, SWT.NULL);
52: }
53: GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
54: gd.horizontalSpan = span;
55: gd.widthHint = 0;
56: gd.heightHint = 0;
57: label.setLayoutData(gd);
58: return label;
59: }
60: }
|