|
Lines 9-14
Link Here
|
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.pde.ui.templates; |
11 |
package org.eclipse.pde.ui.templates; |
|
|
12 |
|
| 12 |
import java.io.ByteArrayInputStream; |
13 |
import java.io.ByteArrayInputStream; |
| 13 |
import java.io.File; |
14 |
import java.io.File; |
| 14 |
import java.io.FileInputStream; |
15 |
import java.io.FileInputStream; |
|
Lines 48-54
Link Here
|
| 48 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
49 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
| 49 |
import org.eclipse.pde.core.plugin.IPluginReference; |
50 |
import org.eclipse.pde.core.plugin.IPluginReference; |
| 50 |
import org.eclipse.pde.internal.core.TargetPlatformHelper; |
51 |
import org.eclipse.pde.internal.core.TargetPlatformHelper; |
|
|
52 |
import org.eclipse.pde.internal.core.ibundle.IBundle; |
| 53 |
import org.eclipse.pde.internal.core.ibundle.IBundleModel; |
| 51 |
import org.eclipse.pde.internal.core.ibundle.IBundlePluginBase; |
54 |
import org.eclipse.pde.internal.core.ibundle.IBundlePluginBase; |
|
|
55 |
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; |
| 52 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
56 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
| 53 |
import org.eclipse.pde.internal.ui.wizards.templates.ControlStack; |
57 |
import org.eclipse.pde.internal.ui.wizards.templates.ControlStack; |
| 54 |
import org.eclipse.pde.internal.ui.wizards.templates.PluginReference; |
58 |
import org.eclipse.pde.internal.ui.wizards.templates.PluginReference; |
|
Lines 97-103
Link Here
|
| 97 |
*/ |
101 |
*/ |
| 98 |
public static final String KEY_PLUGIN_NAME = "pluginName"; //$NON-NLS-1$ |
102 |
public static final String KEY_PLUGIN_NAME = "pluginName"; //$NON-NLS-1$ |
| 99 |
/** |
103 |
/** |
| 100 |
* The key for the package name that will be created by this teamplate |
104 |
* The key for the package name that will be created by this template |
| 101 |
* (value="packageName"). |
105 |
* (value="packageName"). |
| 102 |
*/ |
106 |
*/ |
| 103 |
public static final String KEY_PACKAGE_NAME = "packageName"; //$NON-NLS-1$ |
107 |
public static final String KEY_PACKAGE_NAME = "packageName"; //$NON-NLS-1$ |
|
Lines 744-747
Link Here
|
| 744 |
return TargetPlatformHelper.getTargetVersion(); |
748 |
return TargetPlatformHelper.getTargetVersion(); |
| 745 |
} |
749 |
} |
| 746 |
|
750 |
|
|
|
751 |
/** |
| 752 |
* Sets a header within the plug-in's underlying manifest header, if it has |
| 753 |
* one. It the plug-in doesn't have a manifest, this method does nothing. |
| 754 |
* It's expected that this method will only be called by sub-classes during |
| 755 |
* execution of the template (i.e. during the sub-class's |
| 756 |
* <samp>updateModel(...)</samp> method). <p/> For example: |
| 757 |
* <dl> |
| 758 |
* <dd><samp>setManifestHeader(Constants.BUNDLE_LOCALIZATION, |
| 759 |
* "plugin")</samp></dd> |
| 760 |
* </dl> |
| 761 |
* |
| 762 |
* @see org.osgi.framework.Constants |
| 763 |
* |
| 764 |
* @param name |
| 765 |
* The name of the header to set |
| 766 |
* @param value |
| 767 |
* The value of the header |
| 768 |
*/ |
| 769 |
protected void setManifestHeader(String name, String value) { |
| 770 |
|
| 771 |
IBundle bundle = getBundleFromModel(); |
| 772 |
|
| 773 |
if (bundle != null) { |
| 774 |
|
| 775 |
bundle.setHeader(name, value); |
| 776 |
} |
| 777 |
} |
| 778 |
|
| 779 |
/** |
| 780 |
* Gets a header from within the plug-in's underlying manifest header, if it |
| 781 |
* has one. If the plug-in doesn't have a manifest, this method returns |
| 782 |
* <samp>null</samp>. It's expected that this method will only be called by |
| 783 |
* sub-classes during execution of the template (i.e. during the sub-class's |
| 784 |
* <samp>updateModel(...)</samp> method). |
| 785 |
* |
| 786 |
* @param name |
| 787 |
* The name of the header to fetch |
| 788 |
* @return The value of the manifest header, if available, otherwise |
| 789 |
* <samp>null</samp> |
| 790 |
*/ |
| 791 |
protected String getManifestHeader(String name) { |
| 792 |
|
| 793 |
IBundle bundle = getBundleFromModel(); |
| 794 |
|
| 795 |
String value = null; |
| 796 |
if (bundle != null) { |
| 797 |
value = bundle.getHeader(name); |
| 798 |
} |
| 799 |
|
| 800 |
return value; |
| 801 |
} |
| 802 |
|
| 803 |
/** |
| 804 |
* Determines whether this plug-in has a manifest on which to set/get |
| 805 |
* headers. This method will return <samp>false</samp> if the plug-in |
| 806 |
* doesn't have a manifest (e.g. it's a v3.0 plug-in) or if the method is |
| 807 |
* called before the model has been set on the template. |
| 808 |
* |
| 809 |
* It's expected that this method will only be called by sub-classes during |
| 810 |
* execution of the template (i.e. during the sub-class's |
| 811 |
* <samp>updateModel(...)</samp> method). |
| 812 |
* |
| 813 |
* @return <sampl>true</samp> if the plug-in has a manifest, <samp>false</samp> |
| 814 |
* otherwise |
| 815 |
*/ |
| 816 |
protected boolean hasBundleManifest() { |
| 817 |
|
| 818 |
IBundle bundle = getBundleFromModel(); |
| 819 |
|
| 820 |
// essentially, do we have a bundle? |
| 821 |
return (bundle != null); |
| 822 |
} |
| 823 |
|
| 824 |
/** |
| 825 |
* Try to get hold of the underlying bundle for the model, if applicable. |
| 826 |
* |
| 827 |
* @return The bundle instance, or null if not a bundle or if the model |
| 828 |
* isn't available. |
| 829 |
*/ |
| 830 |
private IBundle getBundleFromModel() { |
| 831 |
|
| 832 |
// Do early exit checks |
| 833 |
if (model == null || !(model instanceof IBundlePluginModelBase)) { |
| 834 |
return null; |
| 835 |
} |
| 836 |
|
| 837 |
IBundlePluginModelBase bundlePModel = (IBundlePluginModelBase) model; |
| 838 |
IBundleModel bundleModel = bundlePModel.getBundleModel(); |
| 839 |
|
| 840 |
IBundle bundle = null; |
| 841 |
|
| 842 |
if (bundleModel != null) { |
| 843 |
|
| 844 |
bundle = bundleModel.getBundle(); |
| 845 |
} |
| 846 |
|
| 847 |
return bundle; |
| 848 |
} |
| 747 |
} |
849 |
} |