I would like to create a list dialog that will only allowed a single selection from a list of options ListSelectionDialog
seems like a good option, but I could not find a way to restrict it to a single option, or change it to radio buttons.
I read the followings, and could not find any indication on how to do so: https://dzone.com/articles/discover-eclipses-jface-dialog
If you write a class derived from ListSelectionDialog
you can call the getViewer()
method to get the CheckboxTableViewer
the dialog uses.
You could then add a check state listener to force a single selection:
CheckboxTableViewer viewer = getViewer();
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
viewer.setCheckedElements(new Object[] { event.getElement() });
}
});
Although I think this might confuse users expecting a checkbox list to support multiple selection.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.