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;
34 * of the separator. See <code>Label</code> for possible
37 public Separator(int style) {
42 // ------- layout helpers
45 * Creates the separator and fills it in a MGridLayout.
48 * The heigth of the separator
50 public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
51 assertEnoughColumns(nColumns);
53 Control separator = getSeparator(parent);
54 separator.setLayoutData(gridDataForSeperator(nColumns, height));
56 return new Control[] { separator };
60 * @see DialogField#doFillIntoGrid
62 public Control[] doFillIntoGrid(Composite parent, int nColumns) {
63 return doFillIntoGrid(parent, nColumns, 4);
67 * @see DialogField#getNumberOfControls
69 public int getNumberOfControls() {
73 protected static GridData gridDataForSeperator(int span, int height) {
74 GridData gd = new GridData();
75 gd.horizontalAlignment = GridData.FILL;
76 gd.verticalAlignment = GridData.BEGINNING;
77 gd.heightHint = height;
78 gd.horizontalSpan = span;
82 // ------- ui creation
85 * Creates or returns the created separator.
88 * The parent composite or <code>null</code> if the widget has
89 * already been created.
91 public Control getSeparator(Composite parent) {
92 if (fSeparator == null) {
93 assertCompositeNotNull(parent);
94 fSeparator = new Label(parent, fStyle);