/** * Validates the current selection and updates the status line * accordingly. * @return boolean <code>true</code> if the current selection is * valid. */ protected boolean validateCurrentSelection() { Assert.isNotNull(fFilteredList); IStatus status; Object[] elements = getSelectedElements(); if (elements.length > 0) { if (fValidator != null) { status = fValidator.validate(elements); } else { status = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, "", //$NON-NLS-1$ null); } } else { if (fFilteredList.isEmpty()) { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, fEmptyListMessage, null); } else { status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, fEmptySelectionMessage, null); } } updateStatus(status); return status.isOK(); }
/** * This method is called when the elements of the backing list are changed * to refresh the standard dialog widgets. * * @since 3.8 */ protected void handleElementsChanged() { boolean enabled = !fFilteredList.isEmpty(); if (fMessage != null && !fMessage.isDisposed()) fMessage.setEnabled(enabled); fFilteredList.setEnabled(enabled); updateOkState(); }
@Override public void create() { BusyIndicator.showWhile(null, () -> { access$superCreate(); Assert.isNotNull(fFilteredList); if (fFilteredList.isEmpty()) { handleEmptyList(); } else { validateCurrentSelection(); fFilterText.selectAll(); fFilterText.setFocus(); } }); }