ElementListSelectionDialog没有元素

我正在尝试使用ElementListSelectionDialog 。 我遵循了示例代码,但无论出于何种原因,对话框显示但没有选项

我的代码:

ElementListSelectionDialog dialog = new ElementListSelectionDialog(shlSpriteCreator, new LabelProvider()); dialog.setMultipleSelection(false); dialog.setIgnoreCase(true); dialog.setAllowDuplicates(true); dialog.setMessage("Select an AI"); dialog.setTitle("What AI to use?"); dialog.setElements(new String[]{"HELLO","GOODBYE"}); if (dialog.open() == Window.OK) { aiControllerLocation = (String) dialog.getFirstResult(); } 

生成的对话框:

对话框没有可供选择的选项

我最初使用了一个类数组,但由于它不起作用,我替换了一个简单的字符串列表,虽然我理解它使用LabelProvider类我应该能够使用任何对象,它将显示它的toString()表示。

这种类型的对话框在Workbench UI下正常工作。 要正确运行此对话框,您应该使用示例代码

 ElementListSelectionDialog dialog = new ElementListSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), new LabelProvider());