1 11 package org.eclipse.update.internal.operations; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.update.configuration.*; 17 import org.eclipse.update.core.*; 18 import org.eclipse.update.operations.*; 19 20 public class JobRoot { 21 private IInstallFeatureOperation job; 22 private FeatureHierarchyElement[] elements; 23 24 public JobRoot(IInstallFeatureOperation job) { 25 this.job = job; 26 } 27 28 public IInstallFeatureOperation getJob() { 29 return job; 30 } 31 32 public FeatureHierarchyElement[] getElements() { 33 if (elements == null) 34 computeElements(); 35 return elements; 36 } 37 38 46 public IFeature[] getUnconfiguredOptionalFeatures( 47 IInstallConfiguration config, 48 IConfiguredSite targetSite) { 49 50 ArrayList unconfiguredOptionalFeatures = new ArrayList (); 51 getUnconfiguredOptionalFeatures(unconfiguredOptionalFeatures, config, targetSite, getElements(), UpdateUtils.isPatch(job.getFeature())); 52 IFeature[] unconfiguredOptionalFeaturesArray = 53 new IFeature[unconfiguredOptionalFeatures.size()]; 54 unconfiguredOptionalFeatures.toArray(unconfiguredOptionalFeaturesArray); 55 return unconfiguredOptionalFeaturesArray; 56 } 57 58 private void getUnconfiguredOptionalFeatures( 59 ArrayList unconfiguredOptionalFeatures, 60 IInstallConfiguration config, 61 IConfiguredSite targetSite, 62 FeatureHierarchyElement[] optionalElements, 63 boolean isPatch) { 64 for (int i = 0; i < optionalElements.length; i++) { 65 FeatureHierarchyElement[] children = 66 optionalElements[i].getChildren(true, isPatch, config); 67 getUnconfiguredOptionalFeatures( 68 unconfiguredOptionalFeatures, 69 config, 70 targetSite, 71 children, 72 isPatch); 73 if (!optionalElements[i].isEnabled(config)) { 74 unconfiguredOptionalFeatures.add(optionalElements[i].getFeature()); 75 } 76 } 77 } 78 79 private void computeElements() { 80 try { 81 IFeature oldFeature = job.getOldFeature(); 82 IFeature newFeature = job.getFeature(); 83 ArrayList list = new ArrayList (); 84 boolean patch = UpdateUtils.isPatch(newFeature); 85 FeatureHierarchyElement.computeElements( 86 oldFeature, 87 newFeature, 88 oldFeature != null, 89 patch, 90 SiteManager.getLocalSite().getCurrentConfiguration(), 91 list); 92 elements = new FeatureHierarchyElement[list.size()]; 93 list.toArray(elements); 94 for (int i = 0; i < elements.length; i++) { 95 elements[i].setRoot(this); 96 } 97 } catch (CoreException e) { 98 UpdateUtils.logException(e); 99 } 100 } 101 } 102 | Popular Tags |