1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.wizards.dialogfields;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Label;
20 * Dialog field describing a separator.
22 public class Separator extends DialogField {
24 private Label fSeparator;
32 * @param style of the separator. See <code>Label</code> for possible
35 public Separator(int style) {
40 // ------- layout helpers
43 * Creates the separator and fills it in a MGridLayout.
44 * @param height The heigth of the separator
46 public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
47 assertEnoughColumns(nColumns);
49 Control separator= getSeparator(parent);
50 separator.setLayoutData(gridDataForSeperator(nColumns, height));
52 return new Control[] { separator };
56 * @see DialogField#doFillIntoGrid
58 public Control[] doFillIntoGrid(Composite parent, int nColumns) {
59 return doFillIntoGrid(parent, nColumns, 4);
63 * @see DialogField#getNumberOfControls
65 public int getNumberOfControls() {
69 protected static GridData gridDataForSeperator(int span, int height) {
70 GridData gd= new GridData();
71 gd.horizontalAlignment= GridData.FILL;
72 gd.verticalAlignment= GridData.BEGINNING;
73 gd.heightHint= height;
74 gd.horizontalSpan= span;
78 // ------- ui creation
81 * Creates or returns the created separator.
82 * @param parent The parent composite or <code>null</code> if the widget has
83 * already been created.
85 public Control getSeparator(Composite parent) {
86 if (fSeparator == null) {
87 assertCompositeNotNull(parent);
88 fSeparator= new Label(parent, fStyle);