问题
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