CIOC
CIOC

Reputation: 1427

Add icons to elements in ElementListSelectionDialog

I have the following code to create a dialog in a RCP Eclipse application using the ElementListSelectionDialog class:

ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());

dialog.setTitle("test");
dialog.setMessage("test");
dialog.setMultipleSelection(false);
dialog.setElements(new String[]{"test1", "test2", "test3"});
dialog.open();

The previous code generates this dialog:

enter image description here

This is fine but I also want to add icons to the elements in the list, similar to how it looks the web.xml editor:

enter image description here

Upvotes: 0

Views: 105

Answers (1)

greg-449
greg-449

Reputation: 111142

You need to extend the LabelProvider you are passing to the ElementListSelectionDialog constructor and override the

public Image getImage(Object element)

method. This will be called for each of the objects you add to the dialog with the setElements method.

Upvotes: 1

Related Questions