diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java index 5c9cde05dbe..114ee8c59d0 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java @@ -2562,6 +2562,8 @@ public class PDEUIMessages extends NLS { public static String PluginGeneralInfoSection_singleton; + public static String PluginGeneralInfoSection_bundleshape; + public static String FragmentGeneralInfoSection_singleton; public static String ClassSearchParticipant_taskMessage; diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/GeneralInfoSection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/GeneralInfoSection.java index 8f232502ef2..29a36debfad 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/GeneralInfoSection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/GeneralInfoSection.java @@ -16,14 +16,18 @@ import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; +import java.util.Map; + import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.core.IModelChangeProvider; import org.eclipse.pde.core.IModelChangedEvent; +import org.eclipse.pde.core.ModelChangedEvent; import org.eclipse.pde.core.plugin.IPluginBase; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.pde.internal.core.ICoreConstants; import org.eclipse.pde.internal.core.ibundle.IBundle; import org.eclipse.pde.internal.core.ibundle.IBundleModel; import org.eclipse.pde.internal.core.ibundle.IManifestHeader; @@ -41,9 +45,11 @@ import org.eclipse.pde.internal.ui.parts.FormEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IActionBars; import org.eclipse.ui.forms.widgets.FormToolkit; @@ -56,6 +62,8 @@ */ public abstract class GeneralInfoSection extends PDESection { private static String PLATFORM_FILTER = "Eclipse-PlatformFilter"; //$NON-NLS-1$ + private static String BUNDLESHAPE_JAR = "jar"; //$NON-NLS-1$ + private static String BUNDLESHAPE_DIR = "dir"; //$NON-NLS-1$ private FormEntry fIdEntry; private FormEntry fVersionEntry; @@ -77,6 +85,12 @@ public abstract class GeneralInfoSection extends PDESection { protected Button fSingleton; + protected Button fBundleShapeJar; + + protected Button fBundleShapeDir; + + protected Button fBundleShapeDefault; + public GeneralInfoSection(PDEFormPage page, Composite parent) { super(page, parent, Section.DESCRIPTION); createClient(getSection(), page.getEditor().getToolkit()); @@ -322,6 +336,15 @@ public void modelChanged(IModelChangedEvent e) { } } + void refreshBundleShape(Button on, Button off_1, Button off_2) { + if (on != null) + on.setSelection(true); + if (off_1 != null) + off_1.setSelection(false); + if (off_2 != null) + off_2.setSelection(false); + } + @Override public void refresh() { IPluginModelBase model = (IPluginModelBase) getPage().getPDEEditor().getContextManager().getAggregateModel(); @@ -340,6 +363,27 @@ public void refresh() { IManifestHeader header = getSingletonHeader(); fSingleton.setSelection(header instanceof BundleSymbolicNameHeader && ((BundleSymbolicNameHeader) header).isSingleton()); } + IBundle bundle = getBundle(); + Map headers = ((Bundle) bundle).getHeaders(); + IManifestHeader header = headers.get(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); + if (header != null) { + String value = header.getValue(); + if (value != null) { + switch (value) { + case "jar": //$NON-NLS-1$ + refreshBundleShape(fBundleShapeJar, fBundleShapeDir, fBundleShapeDefault); + break; + case "dir": //$NON-NLS-1$ + refreshBundleShape(fBundleShapeDir, fBundleShapeJar, fBundleShapeDefault); + break; + } + } else { + refreshBundleShape(fBundleShapeDefault, fBundleShapeDir, fBundleShapeJar); + } + } else { + refreshBundleShape(fBundleShapeDefault, fBundleShapeDir, fBundleShapeJar); + } + super.refresh(); } @@ -387,6 +431,13 @@ IManifestHeader getSingletonHeader() { return null; } + void createBundleShapeHeader(String shape) { + IBundle bundle = getBundle(); + if (bundle instanceof Bundle) { + bundle.setHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE, shape); + } + } + protected void createSingleton(Composite parent, FormToolkit toolkit, IActionBars actionBars, String label) { fSingleton = toolkit.createButton(parent, label, SWT.CHECK); TableWrapData td = new TableWrapData(); @@ -400,4 +451,49 @@ protected void createSingleton(Composite parent, FormToolkit toolkit, IActionBar })); } + protected void createBundleShape(Composite parent, FormToolkit toolkit, IActionBars actionBars, String label) { + Label l = toolkit.createLabel(parent, label, SWT.BORDER); + TableWrapData td = new TableWrapData(); + td.colspan = 3; + l.setLayoutData(td); + Composite c = new Composite(parent, SWT.NONE); + GridLayout gd = new GridLayout(3, true); + gd.marginLeft = 0; + gd.marginRight = 0; + gd.horizontalSpacing = 2; + c.setLayout(gd); + fBundleShapeJar = toolkit.createButton(c, BUNDLESHAPE_JAR, SWT.RADIO); + fBundleShapeDir = toolkit.createButton(c, BUNDLESHAPE_DIR, SWT.RADIO); + fBundleShapeDefault = toolkit.createButton(c, "default", SWT.RADIO); //$NON-NLS-1$ + fBundleShapeJar.setEnabled(true); + fBundleShapeDir.setEnabled(true); + fBundleShapeDefault.setEnabled(true); + fBundleShapeDefault.setSelection(true); + fBundleShapeJar.addListener(SWT.Selection, event -> { + if (fBundleShapeJar.getSelection()) { + createBundleShapeHeader(BUNDLESHAPE_JAR); + } + }); + fBundleShapeDir.addListener(SWT.Selection, event -> { + if (fBundleShapeDir.getSelection()) { + createBundleShapeHeader(BUNDLESHAPE_DIR); + } + }); + fBundleShapeDefault.addListener(SWT.Selection, event -> { + if (fBundleShapeDefault.getSelection()) { + if (getBundle() instanceof Bundle bundle) { + Map headers = bundle.getHeaders(); + Object entry = headers.get(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); + ((IManifestHeader) entry).setValue(null); + bundle.setHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE, null); + IBundleModel model = bundle.getModel(); + ((IModelChangeProvider) model).fireModelChanged( + new ModelChangedEvent(model, IModelChangedEvent.REMOVE, + new Object[] { entry }, ICoreConstants.ECLIPSE_BUNDLE_SHAPE)); + } + + } + }); + + } } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/PluginGeneralInfoSection.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/PluginGeneralInfoSection.java index cd5e6501a7a..cb10ec78e4d 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/PluginGeneralInfoSection.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/PluginGeneralInfoSection.java @@ -74,6 +74,7 @@ protected void createSpecificControls(Composite parent, FormToolkit toolkit, IAc if (isBundle() && (formEditor instanceof ManifestEditor)) { createLazyStart(parent, toolkit, actionBars); createSingleton(parent, toolkit, actionBars, PDEUIMessages.PluginGeneralInfoSection_singleton); + createBundleShape(parent, toolkit, actionBars, PDEUIMessages.PluginGeneralInfoSection_bundleshape); } } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties index fb89d329adc..a36409c7176 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties @@ -1507,6 +1507,7 @@ PluginWorkingSet_deselectAll_label=Dese&lect All PluginDevelopmentPage_presentation=Plug-in Manifest Editor Presentation PluginGeneralInfoSection_lazyStart=Activate this plug-in when one of its classes is loaded PluginGeneralInfoSection_singleton=This plug-in is a singleton +PluginGeneralInfoSection_bundleshape=Unpack behavior during P2 installation: FragmentGeneralInfoSection_singleton=This fragment is a singleton PluginWorkingSet_deselectAll_toolTip=Unselect all of these plug-ins for this working set. PluginListPage_initializeFromPlugins=&Initialize from the plug-ins list: