Source:
private void addListeners() { chkTimeFrom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dtFromDate.setEnabled(chkTimeFrom.getSelection()); dtFromTime.setEnabled(chkTimeFrom.getSelection()); viewModel.setInitialFromDateTime(dtFromTime, dtFromDate); viewModel.setInitialToDateTime(dtToTime, dtToDate); } }); chkTimeTo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dtToDate.setEnabled(chkTimeTo.getSelection()); dtToTime.setEnabled(chkTimeTo.getSelection()); viewModel.setInitialFromDateTime(dtFromTime, dtFromDate); viewModel.setInitialToDateTime(dtToTime, dtToDate); } }); chkNumberFrom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { spinnerFromNumber.setEnabled(chkNumberFrom.getSelection()); } }); chkNumberTo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { spinnerToNumber.setEnabled(chkNumberTo.getSelection()); } }); cmbFilterType.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DISPLAY.asyncExec(() -> { stackSearch.topControl = cmpFilters.get(cmbFilterType.getSelectionIndex()); cmpSearch.layout(); viewModel.clearMessage(); int index = cmbFilterType.getSelectionIndex(); if (index == runNumberIndex) { viewModel.setFromNumber(spinnerFromNumber.getSelection()); viewModel.setToNumber(spinnerToNumber.getSelection()); } else if ((index == startTimeIndex) && (dtToTime != null)) { viewModel.setToTime(dtToTime); viewModel.setFromTime(dtFromTime); viewModel.setToDate(dtToDate); viewModel.setFromDate(dtFromDate); } }); } }); }

Target:
private void addListeners() { chkTimeFrom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dtFromDate.setEnabled(chkTimeFrom.getSelection()); dtFromTime.setEnabled(chkTimeFrom.getSelection()); viewModel.setInitialFromDateTime(dtFromTime.getDateTime(), dtFromDate.getDateTime()); viewModel.setInitialToDateTime(dtToTime.getDateTime(), dtToDate.getDateTime()); } }); chkTimeTo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { dtToDate.setEnabled(chkTimeTo.getSelection()); dtToTime.setEnabled(chkTimeTo.getSelection()); viewModel.setInitialFromDateTime(dtFromTime.getDateTime(), dtFromDate.getDateTime()); viewModel.setInitialToDateTime(dtToTime.getDateTime(), dtToDate.getDateTime()); } }); chkNumberFrom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { spinnerFromNumber.setEnabled(chkNumberFrom.getSelection()); } }); chkNumberTo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { spinnerToNumber.setEnabled(chkNumberTo.getSelection()); } }); cmbFilterType.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DISPLAY.asyncExec(() -> { stackSearch.topControl = cmpFilters.get(cmbFilterType.getSelectionIndex()); cmpSearch.layout(); viewModel.clearMessage(); int index = cmbFilterType.getSelectionIndex(); if (index == runNumberIndex) { viewModel.setFromNumber(spinnerFromNumber.getSelection()); viewModel.setToNumber(spinnerToNumber.getSelection()); } else if ((index == startTimeIndex) && (dtToTime != null)) { viewModel.setToTime(dtToTime.getDateTime()); viewModel.setFromTime(dtFromTime.getDateTime()); viewModel.setToDate(dtToDate.getDateTime()); viewModel.setFromDate(dtFromDate.getDateTime()); } }); } }); }