Search code examples
eclipseeclipse-plugineclipse-pde

How to populate CheckedTreeSelectionDialog


I'm writing a test to learn how to use CheckedTreeSelectionDialog. This is the code.

CheckedTreeSelectionDialog dialog = 
new CheckedTreeSelectionDialog(shell, new LabelProvider(), new TreeContentProvider() );

 dialog.setTitle("Tree Selection");
 dialog.setMessage("Select the elements from the tree:");

 ElementTree et = new ElementTree();

 et.createElement(new Path("element_1"), "element_1");

 dialog.setInput(dt);

 dialog.open();

But I get the exception:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NoClassDefFoundError: org/eclipse/pde/internal/ui/elements/TreeContentProvider)

I really appreciate any hint!

Thanks!


Solution

  • You can't use the class org.eclipse.pde.internal.ui.elements.TreeContentProvider because it's only available for Eclipse PDE (the classes that are in a package 'internal' are not intended to be used by client).

    Instead you should create your own TreeContentProvider, implementing the interface org.eclipse.jface.viewers.ITreeContentProvider, as you would do for a TreeViewer. A tutorial is here.