1 11 12 package org.eclipse.core.internal.dependencies; 13 14 import java.util.Collection ; 15 import java.util.Collections ; 16 17 20 public class SelectionVisitor implements IElementSetVisitor { 21 private int order; 22 private ISelectionPolicy selectionPolicy; 23 24 public SelectionVisitor(int order, ISelectionPolicy selectionPolicy) { 25 this.order = order; 26 this.selectionPolicy = selectionPolicy; 27 } 28 29 public final Collection getAncestors(ElementSet elementSet) { 30 return elementSet.getRequiring(); 31 } 32 33 public final Collection getDescendants(ElementSet elementSet) { 34 return elementSet.getRequired(); 35 } 36 37 public int getOrder() { 38 return order; 39 } 40 41 public void update(ElementSet elementSet) { 42 43 if (elementSet.getSatisfied().isEmpty()) { 45 elementSet.setSelected(Collections.EMPTY_SET); 46 return; 47 } 48 if (elementSet.allowsConcurrency()) { 50 elementSet.setSelected(this.selectionPolicy.selectMultiple(elementSet)); 51 return; 52 } 53 Element selected = this.selectionPolicy.selectSingle(elementSet); 55 elementSet.setSelected(selected == null ? Collections.EMPTY_SET : Collections.singleton(selected)); 56 } 57 58 } | Popular Tags |