0

Env: Java SE 6

I am working on an Eclipse RCP application. How do I create TreeItems with tri-state checkbox. Like the Eclipse IDE update package interface. I use SWT TreeItem class now, which only provides API, setChecked(bool), for true/false states.

enter image description here

Stan
  • 37,207
  • 50
  • 124
  • 185
  • One more question, where could be the setGrayed code located? I looked into InstallWizard.class, SelectableIUsPage.class, CheckboxTableViewer.class but found nothing related. My intention was to find out how they handle the partial selection and update the parent node with setGrayed. – Stan Jun 03 '15 at 09:51

1 Answers1

3

The filled in check box is known as 'grayed'.

With CheckboxTreeViewer use the setGrayed, setGrayChecked, setGrayedElements methods to set grayed items.

With TreeItem use the setGrayed method.

It is up to you to code the logic for determining when a node should be grayed.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • @grep-449, does Swing framework provide APIs to handle the tri-state checkbox? Or I would need to traverse the sibling nodes and setGrayed for the parent node myself? It seems there should be something there taking care of this task. – Stan Jun 03 '15 at 11:00
  • This is SWT not Swing. Eclipse does not use Swing. – greg-449 Jun 03 '15 at 15:19
  • OK, I got it wrong. But the question is the same - do I need to do the plumbing work to check isAllSiblingsChecked, then setParentGrayed myself? – Stan Jun 03 '15 at 16:06
  • I don't know of any standard code to handle the gray state. – greg-449 Jun 03 '15 at 16:46