KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > ui > templates > BlankField


1 /*******************************************************************************
2  * Copyright (c) 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.ui.templates;
12
13 import org.eclipse.swt.layout.GridData;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Label;
16
17 /**
18  * This template option can be used to create blank space on the
19  * template section wizard page.
20  *
21  * @since 3.2
22  */

23 public class BlankField extends TemplateOption {
24
25     private final static int DEFAULT_HEIGHT = 20;
26     private final static String JavaDoc OPTION_NAME = "blankField"; //$NON-NLS-1$
27
private static int NUM_CREATED = 0;
28     
29     private static String JavaDoc getUniqueName() {
30         return OPTION_NAME + Integer.toString(NUM_CREATED++);
31     }
32     
33     private Label fblankLabel;
34     private int fheight;
35     
36     /**
37      * The default constructor.
38      *
39      * @param section
40      * the parent section
41      */

42     public BlankField(BaseOptionTemplateSection section) {
43         super(section, getUniqueName(), ""); //$NON-NLS-1$
44
fheight = DEFAULT_HEIGHT;
45     }
46     
47     /**
48      * Overloaded constructor to specify the height of the blank field.
49      *
50      * @param section
51      * the parent section
52      * @param height
53      * specifies the height of the blank field in pixels
54      */

55     public BlankField(BaseOptionTemplateSection section, int height) {
56         super(section, getUniqueName(), ""); //$NON-NLS-1$
57
fheight = height;
58     }
59
60     /**
61      * Creates a blank field using a label widget.
62      *
63      * @param parent
64      * parent composite of the blank label
65      * @param span
66      * the number of columns that the widget should span
67      */

68     public void createControl(Composite parent, int span) {
69         fblankLabel = createLabel(parent,span);
70         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
71         gd.heightHint = fheight;
72         gd.horizontalSpan = span;
73         fblankLabel.setLayoutData(gd);
74     }
75
76 }
77
Popular Tags