private void traverse(Menu menu, IJavaElement element, String offset, int offsetCount, ISelection selection)
throws JavaModelException
{
if (element instanceof IType || element instanceof IMethod)
{
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
//menuItem.setText(offset + labelProvider.getText(element));
menuItem.setText(labelProvider.getText(element));
menuItem.setImage(labelProvider.getImage(element));
menuItem.setData(element);
// If the selection is completely contained in a method, then select that method.
// If we run across another method for which the same is true, select that method
// and de-select the old one.
if (element instanceof ISourceReference)
{
if (selectionContainedInElement((ISourceReference)element, selection))
{
if (selectedMenuItem != null)
selectedMenuItem.setSelection(false);
menuItem.setSelection(true);
selectedMenuItem = menuItem;
}
}
menuItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
}
public void widgetSelected(SelectionEvent event) {
selectElement((IJavaElement)event.widget.getData());