ElementListSelectionDialog has no elements

I am trying to use ElementListSelectionDialog . I followed the code example, but for some reason the dialog is shown, but without parameters

My code is:

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

As a result of the dialogue:

Dialog with no options to select

I originally used an array of classes, but since it did not work, I replaced the list of trivial strings, although, as far as I understand, using a LabelProvider class should be able to use any object, and it will be displayed by it in the toString () view.

+4
source share
1 answer

This type of dialog usually works under the Workbench interface. To run this dialog correctly, you must use the sample code.

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

All Articles