1) Reintroduced PHPPerspectiveFactory (was lost with refactoring).
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / internal / ui / wizards / dialogfields / Separator.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.wizards.dialogfields;
12
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;
18
19 /**
20  * Dialog field describing a separator.
21  */
22 public class Separator extends DialogField {
23
24         private Label fSeparator;
25
26         private int fStyle;
27
28         public Separator() {
29                 this(SWT.NONE);
30         }
31
32         /**
33          * @param style
34          *            of the separator. See <code>Label</code> for possible
35          *            styles.
36          */
37         public Separator(int style) {
38                 super();
39                 fStyle = style;
40         }
41
42         // ------- layout helpers
43
44         /**
45          * Creates the separator and fills it in a MGridLayout.
46          * 
47          * @param height
48          *            The heigth of the separator
49          */
50         public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
51                 assertEnoughColumns(nColumns);
52
53                 Control separator = getSeparator(parent);
54                 separator.setLayoutData(gridDataForSeperator(nColumns, height));
55
56                 return new Control[] { separator };
57         }
58
59         /*
60          * @see DialogField#doFillIntoGrid
61          */
62         public Control[] doFillIntoGrid(Composite parent, int nColumns) {
63                 return doFillIntoGrid(parent, nColumns, 4);
64         }
65
66         /*
67          * @see DialogField#getNumberOfControls
68          */
69         public int getNumberOfControls() {
70                 return 1;
71         }
72
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;
79                 return gd;
80         }
81
82         // ------- ui creation
83
84         /**
85          * Creates or returns the created separator.
86          * 
87          * @param parent
88          *            The parent composite or <code>null</code> if the widget has
89          *            already been created.
90          */
91         public Control getSeparator(Composite parent) {
92                 if (fSeparator == null) {
93                         assertCompositeNotNull(parent);
94                         fSeparator = new Label(parent, fStyle);
95                 }
96                 return fSeparator;
97         }
98
99 }