Source:
protected Control createContents(@Nullable Composite parent) { Composite composite = new Composite(parent, SWT.BORDER); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setLayout(new GridLayout(3, false)); Button checkBox = new Button(composite, SWT.CHECK); checkBox.setText(Messages.PreferencePage_CheckboxLabel); checkBox.setToolTipText(Messages.PreferencePage_CheckboxTooltip); checkBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { updateContents(); } }); fUseCustomDirectoryCheckbox = checkBox; IntStream.range(0, 2).forEach(i -> new Label(composite, SWT.NONE)); Text text = new Text(composite, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text.setEditable(false); text.setToolTipText(Messages.PreferencePage_CheckboxTooltip); fCustomDirectoryPath = text; Button browseButton = new Button(composite, SWT.NONE); browseButton.setText(Messages.PreferencePage_ButtonBrowse); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { browseDirectory(checkNotNull(fCustomDirectoryPath), Messages.PreferencePage_BrowseDialogTitle); } }); fBrowseButton = browseButton; Button clearButton = new Button(composite, SWT.NONE); clearButton.setText(Messages.PreferencePage_ButtonClear); clearButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { checkNotNull(fCustomDirectoryPath).setText(""); updateContents(); } }); fClearButton = clearButton; loadCurrentSettings(); return composite; }

Target:
protected Control createContents(@Nullable Composite parent) { Composite composite = new Composite(parent, SWT.BORDER); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setLayout(new GridLayout(3, false)); Button checkBox = new Button(composite, SWT.CHECK); checkBox.setText(Messages.PreferencePage_CheckboxLabel); checkBox.setToolTipText(Messages.PreferencePage_CheckboxTooltip); checkBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { updateContents(); } }); fUseCustomDirectoryCheckbox = checkBox; new Label(composite, SWT.NONE); new Label(composite, SWT.NONE); Text text = new Text(composite, SWT.BORDER); text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text.setEditable(false); text.setToolTipText(Messages.PreferencePage_CheckboxTooltip); fCustomDirectoryPath = text; Button browseButton = new Button(composite, SWT.NONE); browseButton.setText(Messages.PreferencePage_ButtonBrowse); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { browseDirectory(checkNotNull(fCustomDirectoryPath), Messages.PreferencePage_BrowseDialogTitle); } }); fBrowseButton = browseButton; Button clearButton = new Button(composite, SWT.NONE); clearButton.setText(Messages.PreferencePage_ButtonClear); clearButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(@Nullable SelectionEvent e) { checkNotNull(fCustomDirectoryPath).setText(""); updateContents(); } }); fClearButton = clearButton; loadCurrentSettings(); return composite; }