此问题类似于ElementListSelectionDialog has no elements,但建议的解决方案无效。我已按照vogella教程从http://www.vogella.com/tutorials/EclipseDialogs/article.html创建ElementListSelectionDialog,出现了对话框,但列表中未显示任何内容。我的代码是
@Execute
public void execute(Shell shell) {
ElementListSelectionDialog elementListSelectionDialog = new ElementListSelectionDialog(shell, new LabelProvider());
elementListSelectionDialog.setMultipleSelection(true);
elementListSelectionDialog.setIgnoreCase(true);
elementListSelectionDialog.setAllowDuplicates(true);
elementListSelectionDialog.setMessage("Select the CUSIP to Fix");
elementListSelectionDialog.setTitle("Incorrect Yield Fixer");
String[] elements = {"Ashish","Tyagi"};
logger.debug("calling setElements {}",Arrays.toString(elements));
elementListSelectionDialog.setElements(elements);
if(elementListSelectionDialog.open() == SWT.OK) {
String[] controlLocation = (String[]) elementListSelectionDialog.getResult();
logger.info("controlLocation is {}",Arrays.toString(controlLocation));
}
}
如果有人有任何建议,请告诉我。
输出为: