Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 82311 Details for
Bug 185477
[API] Allow client to add arbitrary headers to a manifest.mf generated by Template Wizard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to support generic manifest header updates for PDE templates
patch-185447-template-solution.txt (text/plain), 4.78 KB, created by
Les Jones
on 2007-11-07 05:05:29 EST
(
hide
)
Description:
Patch to support generic manifest header updates for PDE templates
Filename:
MIME Type:
Creator:
Les Jones
Created:
2007-11-07 05:05:29 EST
Size:
4.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/ui/templates/AbstractTemplateSection.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/ui/templates/AbstractTemplateSection.java,v >retrieving revision 1.38 >diff -u -r1.38 AbstractTemplateSection.java >--- src/org/eclipse/pde/ui/templates/AbstractTemplateSection.java 8 Jun 2007 16:35:13 -0000 1.38 >+++ src/org/eclipse/pde/ui/templates/AbstractTemplateSection.java 7 Nov 2007 09:55:20 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.pde.ui.templates; >+ > import java.io.ByteArrayInputStream; > import java.io.File; > import java.io.FileInputStream; >@@ -48,7 +49,10 @@ > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.core.plugin.IPluginReference; > import org.eclipse.pde.internal.core.TargetPlatformHelper; >+import org.eclipse.pde.internal.core.ibundle.IBundle; >+import org.eclipse.pde.internal.core.ibundle.IBundleModel; > import org.eclipse.pde.internal.core.ibundle.IBundlePluginBase; >+import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; > import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.pde.internal.ui.wizards.templates.ControlStack; > import org.eclipse.pde.internal.ui.wizards.templates.PluginReference; >@@ -97,7 +101,7 @@ > */ > public static final String KEY_PLUGIN_NAME = "pluginName"; //$NON-NLS-1$ > /** >- * The key for the package name that will be created by this teamplate >+ * The key for the package name that will be created by this template > * (value="packageName"). > */ > public static final String KEY_PACKAGE_NAME = "packageName"; //$NON-NLS-1$ >@@ -744,4 +748,102 @@ > return TargetPlatformHelper.getTargetVersion(); > } > >+ /** >+ * Sets a header within the plug-in's underlying manifest header, if it has >+ * one. It the plug-in doesn't have a manifest, this method does nothing. >+ * It's expected that this method will only be called by sub-classes during >+ * execution of the template (i.e. during the sub-class's >+ * <samp>updateModel(...)</samp> method). <p/> For example: >+ * <dl> >+ * <dd><samp>setManifestHeader(Constants.BUNDLE_LOCALIZATION, >+ * "plugin")</samp></dd> >+ * </dl> >+ * >+ * @see org.osgi.framework.Constants >+ * >+ * @param name >+ * The name of the header to set >+ * @param value >+ * The value of the header >+ */ >+ protected void setManifestHeader(String name, String value) { >+ >+ IBundle bundle = getBundleFromModel(); >+ >+ if (bundle != null) { >+ >+ bundle.setHeader(name, value); >+ } >+ } >+ >+ /** >+ * Gets a header from within the plug-in's underlying manifest header, if it >+ * has one. If the plug-in doesn't have a manifest, this method returns >+ * <samp>null</samp>. It's expected that this method will only be called by >+ * sub-classes during execution of the template (i.e. during the sub-class's >+ * <samp>updateModel(...)</samp> method). >+ * >+ * @param name >+ * The name of the header to fetch >+ * @return The value of the manifest header, if available, otherwise >+ * <samp>null</samp> >+ */ >+ protected String getManifestHeader(String name) { >+ >+ IBundle bundle = getBundleFromModel(); >+ >+ String value = null; >+ if (bundle != null) { >+ value = bundle.getHeader(name); >+ } >+ >+ return value; >+ } >+ >+ /** >+ * Determines whether this plug-in has a manifest on which to set/get >+ * headers. This method will return <samp>false</samp> if the plug-in >+ * doesn't have a manifest (e.g. it's a v3.0 plug-in) or if the method is >+ * called before the model has been set on the template. >+ * >+ * It's expected that this method will only be called by sub-classes during >+ * execution of the template (i.e. during the sub-class's >+ * <samp>updateModel(...)</samp> method). >+ * >+ * @return <sampl>true</samp> if the plug-in has a manifest, <samp>false</samp> >+ * otherwise >+ */ >+ protected boolean hasBundleManifest() { >+ >+ IBundle bundle = getBundleFromModel(); >+ >+ // essentially, do we have a bundle? >+ return (bundle != null); >+ } >+ >+ /** >+ * Try to get hold of the underlying bundle for the model, if applicable. >+ * >+ * @return The bundle instance, or null if not a bundle or if the model >+ * isn't available. >+ */ >+ private IBundle getBundleFromModel() { >+ >+ // Do early exit checks >+ if (model == null || !(model instanceof IBundlePluginModelBase)) { >+ return null; >+ } >+ >+ IBundlePluginModelBase bundlePModel = (IBundlePluginModelBase) model; >+ IBundleModel bundleModel = bundlePModel.getBundleModel(); >+ >+ IBundle bundle = null; >+ >+ if (bundleModel != null) { >+ >+ bundle = bundleModel.getBundle(); >+ } >+ >+ return bundle; >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 185477
:
82209
|
82210
| 82311