private List filterOnlyAdaptableContributors(List contributors) { List adaptableContributors = null; for (Iterator it = contributors.iterator(); it.hasNext(); ) { IObjectContributor c = (IObjectContributor) it.next(); if (c.canAdapt()) { if (adaptableContributors == null) { adaptableContributors = new ArrayList(); } adaptableContributors.add(c); } } return adaptableContributors == null ? Collections.EMPTY_LIST : adaptableContributors; }
/** * Return whether the given contributor is applicable to all elements in the list. * * @param list the selection * @param contributor the contributor * @return whether it is applicable */ public boolean isApplicableTo(List list, IObjectContributor contributor) { Iterator elements = list.iterator(); while (elements.hasNext()) { if (contributor.isApplicableTo(elements.next()) == false) { return false; } } return true; }
/** * Return whether the given contributor is applicable to all elements in the selection. * * @param selection the selection * @param contributor the contributor * @return whether it is applicable */ public boolean isApplicableTo(IStructuredSelection selection, IObjectContributor contributor) { Iterator elements = selection.iterator(); while (elements.hasNext()) { if (contributor.isApplicableTo(elements.next()) == false) { return false; } } return true; }