1 11 package org.eclipse.pde.internal.ui.correction; 12 13 import org.eclipse.osgi.util.NLS; 14 import org.eclipse.pde.internal.core.text.bundle.Bundle; 15 import org.eclipse.pde.internal.core.text.bundle.BundleModel; 16 import org.eclipse.pde.internal.core.text.bundle.RequireBundleHeader; 17 import org.eclipse.pde.internal.core.text.bundle.RequireBundleObject; 18 import org.eclipse.pde.internal.ui.PDEUIMessages; 19 import org.osgi.framework.Constants; 20 21 public class OptionalRequireBundleResolution extends 22 AbstractManifestMarkerResolution { 23 24 private String fBundleId; 25 26 public OptionalRequireBundleResolution(int type, String bundleId) { 27 super(type); 28 fBundleId = bundleId; 29 } 30 31 protected void createChange(BundleModel model) { 32 Bundle bundle = (Bundle)model.getBundle(); 33 RequireBundleHeader header = (RequireBundleHeader)bundle.getManifestHeader(Constants.REQUIRE_BUNDLE); 34 if (header != null) { 35 RequireBundleObject[] required = header.getRequiredBundles(); 36 for (int i = 0; i < required.length; i++) { 37 if (fBundleId.equals(required[i].getId())) 38 required[i].setOptional(true); 39 } 40 } 41 } 42 43 public String getDescription() { 44 return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_description, fBundleId); 45 } 46 47 public String getLabel() { 48 return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_label, fBundleId); 49 } 50 51 } 52 | Popular Tags |