1 11 12 package org.eclipse.pde.internal.core.bundle; 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.pde.core.plugin.IPluginImport; 16 import org.eclipse.pde.internal.core.ICoreConstants; 17 import org.eclipse.pde.internal.core.ibundle.IBundle; 18 import org.eclipse.pde.internal.core.ibundle.IBundlePlugin; 19 import org.eclipse.pde.internal.core.ibundle.IManifestHeader; 20 import org.eclipse.pde.internal.core.text.bundle.BundleActivatorHeader; 21 import org.osgi.framework.Constants; 22 23 public class BundlePlugin extends BundlePluginBase implements IBundlePlugin { 24 25 private static final long serialVersionUID = 1L; 26 31 public String getClassName() { 32 return getValue(getClassHeader(), false); 33 } 34 35 40 public void setClassName(String className) throws CoreException { 41 IBundle bundle = getBundle(); 42 if (bundle != null) { 43 String old = getClassName(); 44 String classHeader = getClassHeader(); 45 IManifestHeader header = bundle.getManifestHeader(classHeader); 46 if (header instanceof BundleActivatorHeader) 47 ((BundleActivatorHeader)header).setClassName(className); 48 else 49 bundle.setHeader(getClassHeader(), className); 50 model.fireModelObjectChanged(this, P_CLASS_NAME, old, className); 51 } 52 } 53 54 private String getClassHeader() { 55 IPluginImport[] imports = getImports(); 56 for (int i = 0; i < imports.length; i++) { 57 if ("org.eclipse.core.runtime.compatibility".equals(imports[i].getId())) return ICoreConstants.PLUGIN_CLASS; 59 } 60 return Constants.BUNDLE_ACTIVATOR; 61 } 62 63 public boolean hasExtensibleAPI() { 64 return "true".equals(getValue(ICoreConstants.EXTENSIBLE_API, false)); } 66 67 } 68 | Popular Tags |