1 package com.nightlabs.rcp.composite; 2 3 import org.eclipse.swt.SWT; 4 import org.eclipse.swt.layout.GridData; 5 import org.eclipse.swt.layout.GridLayout; 6 import org.eclipse.swt.widgets.Composite; 7 import org.eclipse.swt.widgets.Label; 8 import org.eclipse.swt.widgets.Text; 9 10 15 public class LabeledTextComposite extends TightWrapperComposite { 16 private Label labelCaption; 17 private Text textControl; 18 19 public LabeledTextComposite( 20 Composite parent, 21 String caption, 22 int style, 23 boolean setLayoutData 24 ) { 25 super(parent, style,false); 26 27 this.setLayout(new GridLayout()); 28 this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 29 30 labelCaption = new Label(this, SWT.NONE); 31 labelCaption.setText(caption); 32 GridData labelCaptionLData = new GridData(); 33 labelCaptionLData.grabExcessHorizontalSpace = true; 34 labelCaptionLData.horizontalAlignment = GridData.FILL; 35 labelCaption.setLayoutData(labelCaptionLData); 36 37 textControl = new Text(this, SWT.BORDER); 38 GridData textControlLData = new GridData(); 39 textControlLData.grabExcessHorizontalSpace = true; 40 textControlLData.horizontalAlignment = GridData.FILL; 41 textControl.setLayoutData(textControlLData); 42 textControl.setText(""); 43 44 this.layout(); 45 } 46 47 public LabeledTextComposite( 48 Composite parent, 49 String caption, 50 int style 51 ) { 52 this(parent, caption, style, false); 53 } 54 55 public Text getTextControl() { 56 return textControl; 57 } 58 59 public Label getCaptionControl() { 60 return labelCaption; 61 } 62 63 } 64 | Popular Tags |