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 fbf66eab27f..4509755656a 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 @@ -2145,6 +2145,18 @@ public class PDEUIMessages extends NLS { public static String ProductFileWizadPage_basic; public static String Product_overview_exporting; public static String GeneralInfoSection_desc; + + public static String GeneralInfoSection_EclipseBundleShape_defaultGeneralInfoSection_EclipseBundleShape_default; + + public static String GeneralInfoSection_EclipseBundleShape_dirGeneralInfoSection_EclipseBundleShape_dir; + + public static String GeneralInfoSection_EclipseBundleShape_jarGeneralInfoSection_EclipseBundleShape_jar; + + public static String GeneralInfoSection_EclipseBundleShape_label_defaultGeneralInfoSection_EclipseBundleShape_label_default; + + public static String GeneralInfoSection_EclipseBundleShape_label_dirGeneralInfoSection_EclipseBundleShape_label_dir; + + public static String GeneralInfoSection_EclipseBundleShape_label_jarGeneralInfoSection_EclipseBundleShape_label_jar; public static String ProductInfoSection_desc; public static String ProductInfoSection_id; public static String ProductInfoSection_product; @@ -2563,6 +2575,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..82902713b56 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.stream.Stream; + import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.layout.RowLayoutFactory; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.core.IModelChangeProvider; import org.eclipse.pde.core.IModelChangedEvent; 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,6 +45,8 @@ import org.eclipse.pde.internal.ui.parts.FormEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -55,7 +61,7 @@ * Provides the first section of the manifest editor describing the bundle id/name/version/etc. */ public abstract class GeneralInfoSection extends PDESection { - private static String PLATFORM_FILTER = "Eclipse-PlatformFilter"; //$NON-NLS-1$ + private static final String PLATFORM_FILTER = "Eclipse-PlatformFilter"; //$NON-NLS-1$ private FormEntry fIdEntry; private FormEntry fVersionEntry; @@ -77,6 +83,10 @@ public abstract class GeneralInfoSection extends PDESection { protected Button fSingleton; + private Button fBundleShapeDefault; + private Button fBundleShapeJar; + private Button fBundleShapeDir; + public GeneralInfoSection(PDEFormPage page, Composite parent) { super(page, parent, Section.DESCRIPTION); createClient(getSection(), page.getEditor().getToolkit()); @@ -102,6 +112,7 @@ protected void createClient(Section section, FormToolkit toolkit) { if (isBundle() && ((ManifestEditor) getPage().getEditor()).isEquinox()) createPlatformFilterEntry(client, toolkit, actionBars); createSpecificControls(client, toolkit, actionBars); + createBundleShape(client, toolkit, PDEUIMessages.PluginGeneralInfoSection_bundleshape); toolkit.paintBordersFor(client); addListeners(); @@ -340,6 +351,24 @@ public void refresh() { IManifestHeader header = getSingletonHeader(); fSingleton.setSelection(header instanceof BundleSymbolicNameHeader && ((BundleSymbolicNameHeader) header).isSingleton()); } + // Select the corresponding 'Bundle-Shape' radio button (eventually) + Stream.of(fBundleShapeDefault, fBundleShapeJar, fBundleShapeDir).forEach(b -> b.setSelection(false)); + Button selectedBundleShape = fBundleShapeDefault; + IManifestHeader header = getBundle().getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); + if (header != null) { + String value = header.getValue(); + if (value != null) { + selectedBundleShape = switch (value) { + case ICoreConstants.SHAPE_JAR -> fBundleShapeJar; + case ICoreConstants.SHAPE_DIR -> fBundleShapeDir; + default -> null; // unsupported value + }; + } + } + if (selectedBundleShape != null) { + selectedBundleShape.setSelection(true); + } + super.refresh(); } @@ -400,4 +429,46 @@ protected void createSingleton(Composite parent, FormToolkit toolkit, IActionBar })); } + protected void createBundleShape(Composite parent, FormToolkit toolkit, String label) { + Composite c = new Composite(parent, SWT.NONE); + TableWrapData td = new TableWrapData(); + td.colspan = 3; + c.setLayoutData(td); + RowLayoutFactory.fillDefaults().spacing(5).applyTo(c); + toolkit.createLabel(c, label, SWT.NONE); + fBundleShapeDefault = toolkit.createButton(c, + PDEUIMessages.GeneralInfoSection_EclipseBundleShape_label_defaultGeneralInfoSection_EclipseBundleShape_label_default, + SWT.RADIO); + fBundleShapeJar = toolkit.createButton(c, + PDEUIMessages.GeneralInfoSection_EclipseBundleShape_label_jarGeneralInfoSection_EclipseBundleShape_label_jar, + SWT.RADIO); + fBundleShapeDir = toolkit.createButton(c, + PDEUIMessages.GeneralInfoSection_EclipseBundleShape_label_dirGeneralInfoSection_EclipseBundleShape_label_dir, + SWT.RADIO); + fBundleShapeDir.setToolTipText(PDEUIMessages.GeneralInfoSection_EclipseBundleShape_dirGeneralInfoSection_EclipseBundleShape_dir); + fBundleShapeJar.setToolTipText( + PDEUIMessages.GeneralInfoSection_EclipseBundleShape_jarGeneralInfoSection_EclipseBundleShape_jar); + fBundleShapeDefault.setToolTipText( + PDEUIMessages.GeneralInfoSection_EclipseBundleShape_defaultGeneralInfoSection_EclipseBundleShape_default); + fBundleShapeDefault.setSelection(true); + fBundleShapeJar.addSelectionListener(SelectionListener + .widgetSelectedAdapter(event -> setBundleShapeHeader(event, ICoreConstants.SHAPE_JAR))); + fBundleShapeDir.addSelectionListener(SelectionListener + .widgetSelectedAdapter(event -> setBundleShapeHeader(event, ICoreConstants.SHAPE_DIR))); + fBundleShapeDefault.addSelectionListener( + SelectionListener.widgetSelectedAdapter(event -> setBundleShapeHeader(event, null))); + } + + private void setBundleShapeHeader(SelectionEvent event, String shape) { + if (((Button) event.widget).getSelection()) { + IBundle bundle = getBundle(); + if (shape != null) { + bundle.setHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE, shape); + } else { + // Setting the header's value to null removes it (setting the + // header to null is not sufficient) + bundle.getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE).setValue(null); + } + } + } } 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 1e2ae5e1886..880f1d5660c 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=Shape after 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: @@ -2110,6 +2111,12 @@ Product_overview_exporting =
\

Use the Eclipse Product export wizard to package and export the product defined in this configuration.

\
GeneralInfoSection_desc=This section describes general information about the product. +GeneralInfoSection_EclipseBundleShape_defaultGeneralInfoSection_EclipseBundleShape_default=Set Eclipse_BundleShape to default +GeneralInfoSection_EclipseBundleShape_dirGeneralInfoSection_EclipseBundleShape_dir=Set Eclipse_BundleShape to dir +GeneralInfoSection_EclipseBundleShape_jarGeneralInfoSection_EclipseBundleShape_jar=Set Eclipse_BundleShape to jar +GeneralInfoSection_EclipseBundleShape_label_defaultGeneralInfoSection_EclipseBundleShape_label_default=default +GeneralInfoSection_EclipseBundleShape_label_dirGeneralInfoSection_EclipseBundleShape_label_dir=directory +GeneralInfoSection_EclipseBundleShape_label_jarGeneralInfoSection_EclipseBundleShape_label_jar=jar ProductInfoSection_desc=This section describes the launching product extension identifier and application. ProductInfoSection_id=ID: ProductInfoSection_product=Product: