01: /*******************************************************************************
02: * Copyright (c) 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.ui.templates;
11:
12: import org.eclipse.swt.layout.GridData;
13: import org.eclipse.swt.widgets.Composite;
14: import org.eclipse.swt.widgets.Label;
15:
16: /**
17: * This template option can be used to create blank space on the
18: * template section wizard page.
19: *
20: * @since 3.2
21: */
22: public class BlankField extends TemplateOption {
23:
24: private final static int DEFAULT_HEIGHT = 20;
25: private final static String OPTION_NAME = "blankField"; //$NON-NLS-1$
26: private static int NUM_CREATED = 0;
27:
28: private static String getUniqueName() {
29: return OPTION_NAME + Integer.toString(NUM_CREATED++);
30: }
31:
32: private Label fblankLabel;
33: private int fheight;
34:
35: /**
36: * The default constructor.
37: *
38: * @param section
39: * the parent section
40: */
41: public BlankField(BaseOptionTemplateSection section) {
42: super (section, getUniqueName(), ""); //$NON-NLS-1$
43: fheight = DEFAULT_HEIGHT;
44: }
45:
46: /**
47: * Overloaded constructor to specify the height of the blank field.
48: *
49: * @param section
50: * the parent section
51: * @param height
52: * specifies the height of the blank field in pixels
53: */
54: public BlankField(BaseOptionTemplateSection section, int height) {
55: super (section, getUniqueName(), ""); //$NON-NLS-1$
56: fheight = height;
57: }
58:
59: /**
60: * Creates a blank field using a label widget.
61: *
62: * @param parent
63: * parent composite of the blank label
64: * @param span
65: * the number of columns that the widget should span
66: */
67: public void createControl(Composite parent, int span) {
68: fblankLabel = createLabel(parent, span);
69: GridData gd = new GridData(GridData.FILL_HORIZONTAL);
70: gd.heightHint = fheight;
71: gd.horizontalSpan = span;
72: fblankLabel.setLayoutData(gd);
73: }
74:
75: }
|