final IHotlink hotlinkDoc = (IHotlink) doc;
final List<HotlinkDescriptor> descriptors = hotlinkDoc.getDescriptors();
if (descriptors.size() > 1) {
final ListDialog dialog = new ListDialog(openButton.getShell());
dialog.setTitle(Messages.DocumentView_openActionDialogTitle);
dialog.setMessage(Messages.DocumentView_openActionDialogMessage);
dialog.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
return DocUtils.getLabelAndDescDisplay(descriptor.getLabel(),
descriptor.getDescription());
}
});
dialog.setContentProvider(new ArrayContentProvider());
dialog.setInput(descriptors.toArray());
dialog.setInitialElementSelections(Collections.singletonList(descriptors.get(0)));
if (Dialog.OK == dialog.open()) {
final Object[] results = dialog.getResult();
if (results != null && results.length > 0) {
final HotlinkDescriptor descriptor = (HotlinkDescriptor) results[0];
openAction(hotlinkDoc, descriptor);
}
}