KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > bundle > BundlePlugin


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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     /*
27      * (non-Javadoc)
28      *
29      * @see org.eclipse.pde.core.plugin.IPlugin#getClassName()
30      */

31     public String JavaDoc 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 JavaDoc className) throws CoreException {
41         IBundle bundle = getBundle();
42         if (bundle != null) {
43             String JavaDoc old = getClassName();
44             String JavaDoc 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 JavaDoc 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()))//$NON-NLS-1$
58
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)); //$NON-NLS-1$
65
}
66     
67 }
68
Popular Tags