01: /*******************************************************************************
02: * Copyright (c) 2003, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.bundle;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.pde.core.plugin.IPluginImport;
14: import org.eclipse.pde.internal.core.ICoreConstants;
15: import org.eclipse.pde.internal.core.ibundle.IBundle;
16: import org.eclipse.pde.internal.core.ibundle.IBundlePlugin;
17: import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
18: import org.eclipse.pde.internal.core.text.bundle.BundleActivatorHeader;
19: import org.osgi.framework.Constants;
20:
21: public class BundlePlugin extends BundlePluginBase implements
22: IBundlePlugin {
23:
24: private static final long serialVersionUID = 1L;
25:
26: /*
27: * (non-Javadoc)
28: *
29: * @see org.eclipse.pde.core.plugin.IPlugin#getClassName()
30: */
31: public String getClassName() {
32: return getValue(getClassHeader(), false);
33: }
34:
35: /*
36: * (non-Javadoc)
37: *
38: * @see org.eclipse.pde.core.plugin.IPlugin#setClassName(java.lang.String)
39: */
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
46: .getManifestHeader(classHeader);
47: if (header instanceof BundleActivatorHeader)
48: ((BundleActivatorHeader) header)
49: .setClassName(className);
50: else
51: bundle.setHeader(getClassHeader(), className);
52: model.fireModelObjectChanged(this , P_CLASS_NAME, old,
53: className);
54: }
55: }
56:
57: private String getClassHeader() {
58: IPluginImport[] imports = getImports();
59: for (int i = 0; i < imports.length; i++) {
60: if ("org.eclipse.core.runtime.compatibility".equals(imports[i].getId()))//$NON-NLS-1$
61: return ICoreConstants.PLUGIN_CLASS;
62: }
63: return Constants.BUNDLE_ACTIVATOR;
64: }
65:
66: public boolean hasExtensibleAPI() {
67: return "true".equals(getValue(ICoreConstants.EXTENSIBLE_API, false)); //$NON-NLS-1$
68: }
69:
70: }
|