1 11 package org.eclipse.jdt.internal.ui.wizards.dialogfields; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.swt.widgets.Control; 16 import org.eclipse.swt.widgets.Label; 17 18 import org.eclipse.swt.layout.GridData; 19 20 23 public class Separator extends DialogField { 24 25 private Label fSeparator; 26 private int fStyle; 27 28 public Separator() { 29 this(SWT.NONE); 30 } 31 32 36 public Separator(int style) { 37 super(); 38 fStyle= style; 39 } 40 41 43 47 public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) { 48 assertEnoughColumns(nColumns); 49 50 Control separator= getSeparator(parent); 51 separator.setLayoutData(gridDataForSeperator(nColumns, height)); 52 53 return new Control[] { separator }; 54 } 55 56 59 public Control[] doFillIntoGrid(Composite parent, int nColumns) { 60 return doFillIntoGrid(parent, nColumns, 4); 61 } 62 63 66 public int getNumberOfControls() { 67 return 1; 68 } 69 70 protected static GridData gridDataForSeperator(int span, int height) { 71 GridData gd= new GridData(); 72 gd.horizontalAlignment= GridData.FILL; 73 gd.verticalAlignment= GridData.BEGINNING; 74 gd.heightHint= height; 75 gd.horizontalSpan= span; 76 return gd; 77 } 78 79 81 86 public Control getSeparator(Composite parent) { 87 if (fSeparator == null) { 88 assertCompositeNotNull(parent); 89 fSeparator= new Label(parent, fStyle); 90 } 91 return fSeparator; 92 } 93 94 } 95 | Popular Tags |