IAdaptable element= null; if (o instanceof IType) { element= ((IType)o).getCompilationUnit(); } else if (o instanceof IAdaptable) { element= (IAdaptable)o; } if (element == null)
if (!(o instanceof IAdaptable))
	private void addOpenWithMenu(IMenuManager menu) {		ISelection selection= getContext().getSelection();		if (selection.isEmpty() || !(selection instanceof IStructuredSelection))			return;		IStructuredSelection ss= (IStructuredSelection)selection;		if (ss.size() != 1)			return;		Object o= ss.getFirstElement();		IAdaptable element= null;		if (o instanceof IType) {			element= ((IType)o).getCompilationUnit();		} else if (o instanceof IAdaptable) {			element= (IAdaptable)o;		}		if (element == null)			return;		Object resource= element.getAdapter(IResource.class);		if (!(resource instanceof IFile))			return; 		// Create a menu flyout.		IMenuManager submenu= new MenuManager(ActionMessages.getString("OpenWithMenu.label")); //$NON-NLS-1$		submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));		// Add the submenu.		menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);	}