Skip to content

Commit 6640099

Browse files
nburnwal09HannesWell
authored andcommitted
Add a button to show the bundles of a launch
Fixes #1850
1 parent adbf1fc commit 6640099

6 files changed

Lines changed: 159 additions & 5 deletions

File tree

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ public class PDEUIMessages extends NLS {
457457

458458
public static String StateViewPage_suppliedByJRE;
459459

460+
public static String ShowBundlesDialog_Copy;
461+
public static String ShowBundlesDialog_Close;
462+
public static String ShowBundlesDialog_LaunchBundles;
463+
460464
public static String TargetCreationPage_0;
461465

462466
public static String TargetCreationPage_1;
@@ -2480,6 +2484,8 @@ public class PDEUIMessages extends NLS {
24802484

24812485
public static String AbstractPluginBlock_counter;
24822486

2487+
public static String PluginsTabToolBar_show_launch_bundles;
2488+
24832489
public static String AbstractRepository_ErrorLoadingImageFromJar;
24842490

24852491
public static String AbstractRepository_ScanForUI;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,21 @@ public void createControl(Composite parent, int span, int indent) {
435435
label.setLayoutData(gd);
436436

437437
if (fTab instanceof PluginsTab) {
438-
fAutoValidate = createButton(parent, span - 1, indent, PDEUIMessages.PluginsTabToolBar_auto_validate_plugins);
438+
fAutoValidate = createButton(parent, span - 2, indent,
439+
PDEUIMessages.PluginsTabToolBar_auto_validate_plugins);
439440
} else if (fTab instanceof BundlesTab) {
440-
fAutoValidate = createButton(parent, span - 1, indent, PDEUIMessages.PluginsTabToolBar_auto_validate_bundles);
441+
fAutoValidate = createButton(parent, span - 2, indent,
442+
PDEUIMessages.PluginsTabToolBar_auto_validate_bundles);
441443
} else{
442-
fAutoValidate = createButton(parent, span - 1, indent,
444+
fAutoValidate = createButton(parent, span - 2, indent,
443445
NLS.bind(PDEUIMessages.PluginsTabToolBar_auto_validate,
444446
fTab.getName().replace("&", "").toLowerCase(Locale.ENGLISH))); //$NON-NLS-1$ //$NON-NLS-2$
445447
}
448+
Button listPlugins = new Button(parent, SWT.PUSH);
449+
listPlugins.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
450+
listPlugins.setText(PDEUIMessages.PluginsTabToolBar_show_launch_bundles);
451+
listPlugins.addSelectionListener(
452+
SelectionListener.widgetSelectedAdapter(e -> handleShowPluginsPressed(fLaunchConfig)));
446453

447454
fValidateButton = new Button(parent, SWT.PUSH);
448455
fValidateButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
@@ -460,6 +467,17 @@ public void createControl(Composite parent, int span, int indent) {
460467
fValidateButton.addSelectionListener(fListener);
461468
}
462469

470+
// Dialog to Show the launch bundles
471+
static void handleShowPluginsPressed(ILaunchConfiguration launchConfig) {
472+
try {
473+
Map<IPluginModelBase, String> models = BundleLauncherHelper.getMergedBundleMap(launchConfig, false);
474+
ShowBundlesDialog dialog = new ShowBundlesDialog(PDEPlugin.getActiveWorkbenchShell(), models);
475+
dialog.open();
476+
} catch (CoreException e) {
477+
PDEPlugin.log(e);
478+
}
479+
}
480+
463481
private Button createButton(Composite parent, int span, int indent, String text) {
464482
Button button = new Button(parent, SWT.CHECK);
465483
button.setText(text);

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,9 +929,15 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
929929
}
930930

931931
fAutoValidate.addSelectionListener(fListener);
932-
Composite rightAlignComp = SWTFactory.createComposite(validatecomp, 1, 1, SWT.NONE, 0, 0);
932+
Composite rightAlignComp = SWTFactory.createComposite(validatecomp, 2, 1, SWT.NONE, 0, 0);
933933
rightAlignComp.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true));
934934

935+
Button fShowPlugin = SWTFactory.createPushButton(rightAlignComp,
936+
PDEUIMessages.PluginsTabToolBar_show_launch_bundles, null);
937+
fShowPlugin.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
938+
fShowPlugin.addSelectionListener(SelectionListener
939+
.widgetSelectedAdapter(e -> AbstractPluginBlock.handleShowPluginsPressed(fLaunchConfig)));
940+
935941
if (fTab instanceof PluginsTab) {
936942
fValidateButton = SWTFactory.createPushButton(rightAlignComp, PDEUIMessages.PluginsTabToolBar_validate_plugins, null);
937943
} else if (fTab instanceof BundlesTab) {
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 IBM Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.pde.internal.ui.launcher;
15+
16+
17+
import java.util.Map;
18+
import java.util.StringJoiner;
19+
20+
import org.eclipse.jface.dialogs.Dialog;
21+
import org.eclipse.jface.dialogs.IDialogConstants;
22+
import org.eclipse.osgi.service.resolver.BundleDescription;
23+
import org.eclipse.pde.core.plugin.IPluginModelBase;
24+
import org.eclipse.pde.internal.ui.PDEUIMessages;
25+
import org.eclipse.swt.SWT;
26+
import org.eclipse.swt.dnd.Clipboard;
27+
import org.eclipse.swt.dnd.TextTransfer;
28+
import org.eclipse.swt.dnd.Transfer;
29+
import org.eclipse.swt.graphics.Rectangle;
30+
import org.eclipse.swt.layout.GridData;
31+
import org.eclipse.swt.widgets.Composite;
32+
import org.eclipse.swt.widgets.Control;
33+
import org.eclipse.swt.widgets.Label;
34+
import org.eclipse.swt.widgets.Shell;
35+
import org.eclipse.swt.widgets.Text;
36+
37+
38+
public class ShowBundlesDialog extends Dialog {
39+
private Text fModuleArgumentsText;
40+
private final Map<IPluginModelBase, String> fModelsWithStartLevels;
41+
42+
43+
protected ShowBundlesDialog(Shell parentShell, Map<IPluginModelBase, String> modelsWithLevels) {
44+
super(parentShell);
45+
fModelsWithStartLevels = modelsWithLevels;
46+
}
47+
48+
@Override
49+
protected void configureShell(Shell newShell) {
50+
super.configureShell(newShell);
51+
newShell.setText(PDEUIMessages.ShowBundlesDialog_LaunchBundles);
52+
}
53+
54+
@Override
55+
protected void createButtonsForButtonBar(Composite parent) {
56+
createButton(parent, IDialogConstants.OK_ID,
57+
PDEUIMessages.ShowBundlesDialog_Copy, true);
58+
createButton(parent, IDialogConstants.CANCEL_ID,
59+
PDEUIMessages.ShowBundlesDialog_Close, false);
60+
}
61+
62+
@Override
63+
protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
64+
Rectangle result = super.getConstrainedShellBounds(preferredSize);
65+
int heightLimit = convertHeightInCharsToPixels(40);
66+
int widthLimit = convertWidthInCharsToPixels(150);
67+
if (result.height > heightLimit) {
68+
result.y += (result.height - heightLimit) / 2;
69+
result.height = heightLimit;
70+
}
71+
if (result.width > widthLimit) {
72+
result.x += (result.width - widthLimit) / 2;
73+
result.width = widthLimit;
74+
}
75+
return result;
76+
}
77+
78+
@Override
79+
protected boolean isResizable() {
80+
return true;
81+
}
82+
83+
@Override
84+
protected Control createDialogArea(Composite parent) {
85+
Composite comp = (Composite) super.createDialogArea(parent);
86+
Label explanation = new Label(comp, SWT.NONE);
87+
explanation.setText("List of all bundles contained in this launch using the schema:\n" //$NON-NLS-1$
88+
+ "<Symbolic Name>, <Version>, <Start level>, <File Path>"); //$NON-NLS-1$
89+
explanation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
90+
fModuleArgumentsText = new Text(comp, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
91+
fModuleArgumentsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
92+
StringJoiner lines = new StringJoiner("\n"); //$NON-NLS-1$
93+
fModelsWithStartLevels.forEach((model, value) -> {
94+
BundleDescription bundle = model.getBundleDescription();
95+
String startLevel = value.substring(0, value.indexOf(':'));
96+
lines.add(bundle.getSymbolicName() + ", " + bundle.getVersion() + ", " + startLevel + ", " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
97+
+ model.getInstallLocation());
98+
});
99+
fModuleArgumentsText.setText(lines.toString());
100+
fModuleArgumentsText.setEditable(false);
101+
102+
return comp;
103+
}
104+
105+
@Override
106+
protected void buttonPressed(int buttonId) {
107+
if (buttonId == OK) {
108+
Clipboard clipboard = new Clipboard(null);
109+
try {
110+
Transfer[] transfers = { TextTransfer.getInstance() };
111+
Object[] data = { fModuleArgumentsText.getText() };
112+
clipboard.setContents(data, transfers);
113+
} finally {
114+
clipboard.dispose();
115+
}
116+
}
117+
super.buttonPressed(buttonId);
118+
}
119+
120+
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,9 @@ EditorUtilities_pathNotValidImage=The specified path does not point to a valid i
13321332
EditorUtilities_imageTooLargeInfo=Images larger than {0} will overlap or hide text
13331333
EditorPreferencePage_text=Text
13341334
EditorPreferencePage_proc=Processing instructions
1335+
ShowBundlesDialog_Copy=C&opy && Close
1336+
ShowBundlesDialog_Close=&Close
1337+
ShowBundlesDialog_LaunchBundles=Launch Bundles
13351338

13361339
# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts"
13371340
EditorPreferencePage_link=See <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">'Text Editors'</a> for general text editor preferences and <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">'Colors and Fonts'</a> to configure the font.
@@ -1507,6 +1510,7 @@ PluginsView_manifestEditor=&PDE Manifest Editor
15071510
PluginsTabToolBar_validate=&Validate {0}
15081511
PluginsTabToolBar_validate_plugins=&Validate Plug-ins
15091512
PluginsTabToolBar_validate_bundles=&Validate Bundles
1513+
PluginsTabToolBar_show_launch_bundles=&Show launch bundles
15101514
PluginsTab_selectedPlugins=Plug-ins selected below
15111515
PluginContentPage_rcpGroup=Rich Client Application
15121516
PluginWorkingSet_emptyName=The name must not be empty

ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/BundlesTab.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void createControl(Composite parent) {
7777
composite.setLayout(new GridLayout(2, false));
7878

7979
fFrameworkBlock.createControl(composite);
80-
fBlock.createControl(composite, 2, 5);
80+
fBlock.createControl(composite, 3, 5);
8181

8282
setControl(composite);
8383
Dialog.applyDialogFont(composite);

0 commit comments

Comments
 (0)