private Group createMasterDetails(final Composite parent) { final Group result = UIControlsFactory.createGroup( parent, "Master/Details that hides Mandatory-/Error-Markers on New"); // $NON-NLS-1$ final FillLayout layout = new FillLayout(SWT.HORIZONTAL); layout.marginHeight = 20; layout.marginWidth = 20; result.setLayout(layout); final MasterDetailsComposite mdComposite = new MasterDetailsComposite(result, SWT.NONE, SWT.BOTTOM); final Composite details = mdComposite.getDetails(); final GridLayout layout2 = new GridLayout(2, false); details.setLayout(layout2); UIControlsFactory.createLabel(details, "First Name:"); // $NON-NLS-1$ final Text txtFirst = UIControlsFactory.createText(details, SWT.BORDER, "first"); // $NON-NLS-1$ txtFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); UIControlsFactory.createLabel(details, "Last Name:"); // $NON-NLS-1$ final Text txtLast = UIControlsFactory.createText(details, SWT.BORDER, "last"); // $NON-NLS-1$ txtLast.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); UIControlsFactory.createLabel(details, "Gender:"); // $NON-NLS-1$ final ChoiceComposite ccGender = new ChoiceComposite(details, SWT.NONE, false); ccGender.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); ccGender.setOrientation(SWT.HORIZONTAL); mdComposite.addUIControl(ccGender, "gender"); // $NON-NLS-1$ UIControlsFactory.createLabel(details, "Pets:"); // $NON-NLS-1$ final ChoiceComposite ccPets = new ChoiceComposite(details, SWT.NONE, true); ccPets.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); ccPets.setOrientation(SWT.HORIZONTAL); mdComposite.addUIControl(ccPets, "pets"); // $NON-NLS-1$ final Label lblNote = UIControlsFactory.createLabel( details, "Note: a global marker is still shown if there are less than 5 entries!", SWT.CENTER); //$NON-NLS-1$ GridDataFactory.fillDefaults().span(2, 1).applyTo(lblNote); this.addUIControl(mdComposite, "master"); // $NON-NLS-1$ return result; }
@Override protected void createDetails(final Composite parent) { GridLayoutFactory.fillDefaults() .numColumns(2) .margins(20, 20) .spacing(10, 10) .equalWidth(false) .applyTo(parent); final GridDataFactory hFill = GridDataFactory.fillDefaults().grab(true, false); UIControlsFactory.createLabel(parent, "Last Name:"); // $NON-NLS-1$ final Text txtLast = UIControlsFactory.createText(parent); hFill.applyTo(txtLast); addUIControl(txtLast, "txtLast"); // $NON-NLS-1$ UIControlsFactory.createLabel(parent, "First Name:"); // $NON-NLS-1$ final Text txtFirst = UIControlsFactory.createText(parent); hFill.applyTo(txtFirst); addUIControl(txtFirst, "txtFirst"); // $NON-NLS-1$ }