1 11 package org.eclipse.pde.internal.ui.correction; 12 13 import org.eclipse.pde.internal.core.TargetPlatformHelper; 14 import org.eclipse.pde.internal.core.ibundle.IBundle; 15 import org.eclipse.pde.internal.core.ibundle.IManifestHeader; 16 import org.eclipse.pde.internal.core.text.bundle.Bundle; 17 import org.eclipse.pde.internal.core.text.bundle.BundleModel; 18 import org.eclipse.pde.internal.core.text.bundle.BundleSymbolicNameHeader; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.osgi.framework.Constants; 21 22 public class AddSingletonToSymbolicName extends AbstractManifestMarkerResolution { 23 24 private boolean fisDirective; 25 26 public AddSingletonToSymbolicName(int type, boolean directive) { 27 super(type); 28 fisDirective = directive; 29 } 30 31 public String getDescription() { 32 if (fisDirective) 33 return PDEUIMessages.AddSingleon_dir_desc; 34 return PDEUIMessages.AddSingleon_att_desc; 35 } 36 37 public String getLabel() { 38 if (fisDirective) 39 return PDEUIMessages.AddSingleon_dir_label; 40 return PDEUIMessages.AddSingleon_att_label; 41 } 42 43 protected void createChange(BundleModel model) { 44 IBundle bundle = model.getBundle(); 45 if (bundle instanceof Bundle) { 46 Bundle bun = (Bundle)bundle; 47 IManifestHeader header = bun.getManifestHeader(Constants.BUNDLE_SYMBOLICNAME); 48 if (header instanceof BundleSymbolicNameHeader) { 49 if (fisDirective && TargetPlatformHelper.getTargetVersion() >= 3.1) 50 bundle.setHeader(Constants.BUNDLE_MANIFESTVERSION, "2"); else if (!fisDirective && TargetPlatformHelper.getTargetVersion() < 3.1) 52 bundle.setHeader(Constants.BUNDLE_MANIFESTVERSION, null); 53 ((BundleSymbolicNameHeader)header).setSingleton(true); 54 } 55 } 56 } 57 } 58 | Popular Tags |