1 12 package org.eclipse.update.core; 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.update.configuration.IConfiguredSite; 20 import org.eclipse.update.core.model.IncludedFeatureReferenceModel; 21 import org.eclipse.update.internal.core.Messages; 22 import org.eclipse.update.internal.core.UpdateCore; 23 24 39 public class IncludedFeatureReference 40 extends IncludedFeatureReferenceModel 41 implements IIncludedFeatureReference { 42 43 48 public IncludedFeatureReference() { 49 super(); 50 } 51 52 58 public IncludedFeatureReference(IIncludedFeatureReference includedFeatureRef) { 59 super((IncludedFeatureReferenceModel) includedFeatureRef); 60 } 61 62 66 public IncludedFeatureReference(IFeatureReference featureReference) { 67 super(featureReference); 68 } 69 70 public IncludedFeatureReference(IncludedFeatureReferenceModel includedFeatureRefModel){ 71 super(includedFeatureRefModel); 72 } 73 74 78 private boolean isDisabled() { 79 IConfiguredSite cSite = getSite().getCurrentConfiguredSite(); 80 if (cSite == null) 81 return false; 82 IFeatureReference[] configured = cSite.getConfiguredFeatures(); 83 for (int i = 0; i < configured.length; i++) { 84 if (this.equals(configured[i])) 85 return false; 86 } 87 return true; 88 } 92 93 97 private boolean isUninstalled() { 98 if (!isDisabled()) 99 return false; 100 IFeatureReference[] installed = getSite().getFeatureReferences(); 101 for (int i = 0; i < installed.length; i++) { 102 if (this.equals(installed[i])) 103 return false; 104 } 105 return true; 108 } 109 110 115 public IFeature getFeature( 116 boolean perfectMatch, 117 IConfiguredSite configuredSite) 118 throws CoreException { 119 return getFeature(null); 120 } 121 122 127 public IFeature getFeature( 128 boolean perfectMatch, 129 IConfiguredSite configuredSite, 130 IProgressMonitor monitor) 131 throws CoreException { 132 return getFeature(monitor); 133 } 134 135 139 public IFeature getFeature() throws CoreException { 140 return getFeature(null); 141 } 142 146 public IFeature getFeature(IProgressMonitor monitor) throws CoreException { 147 if (isUninstalled()) 148 throw new CoreException(new Status(IStatus.ERROR, UpdateCore.getPlugin().getBundle().getSymbolicName(), IStatus.OK, NLS.bind(Messages.IncludedFeatureReference_featureUninstalled, (new String [] { getFeatureIdentifier() })), null)); 149 else 150 return super.getFeature(monitor); 151 } 152 } 153 | Popular Tags |