public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; Object obj = sel.getFirstElement(); if (obj instanceof ICElement) { if (obj instanceof ICContainer || obj instanceof ICProject) { fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource(); } else { obj = ((ICElement) obj).getResource(); if (obj != null) { fContainer = ((IResource) obj).getParent(); } } } else if (obj instanceof IResource) { if (obj instanceof IContainer) { fContainer = (IContainer) obj; } else { fContainer = ((IResource) obj).getParent(); } } else { fContainer = null; } if (fContainer != null && AutotoolsPlugin.hasTargetBuilder(fContainer.getProject())) { enabled = true; } } action.setEnabled(enabled); }