ElementListSelectionDialog has no elements

你离开我真会死。 提交于 2020-01-01 06:13:34

问题


I'm trying to use a ElementListSelectionDialog. I've followed the example code but for whatever reason the dialog show but with no options

My Code:

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();
}

The resulting dialog:

I originally used an array of classes but since it would not work I substituted for a list of trivial strings although as I understand it by using the LabelProvider class I should be able to use any object and it will be displayed by it's toString() representation.


回答1:


This type of dialog works normally under Workbench UI. To run this dialog correctly you should use the sample code

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


来源:https://stackoverflow.com/questions/12126311/elementlistselectiondialog-has-no-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!