Skip to content

Commit 02caa9b

Browse files
committed
Added a button to show the launch bundles
1 parent 2e87852 commit 02caa9b

5 files changed

Lines changed: 163 additions & 4 deletions

File tree

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

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

458458
public static String StateViewPage_suppliedByJRE;
459459

460+
public static String ShowBundlesDialog_Copy;
461+
462+
public static String ShowBundlesDialog_Close;
463+
464+
public static String ShowBundlesDialog_LaunchBundles;
465+
460466
public static String TargetCreationPage_0;
461467

462468
public static String TargetCreationPage_1;
@@ -2480,6 +2486,8 @@ public class PDEUIMessages extends NLS {
24802486

24812487
public static String AbstractPluginBlock_counter;
24822488

2489+
public static String PluginsTabToolBar_show_launch_bundles;
2490+
24832491
public static String AbstractRepository_ErrorLoadingImageFromJar;
24842492

24852493
public static String AbstractRepository_ScanForUI;

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

Lines changed: 23 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 fShowPlugin = new Button(parent, SWT.PUSH);
449+
fShowPlugin.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
450+
fShowPlugin.setText(PDEUIMessages.PluginsTabToolBar_show_launch_bundles);
451+
fShowPlugin.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,19 @@ 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> modelsWithLevels = new HashMap<>();
474+
modelsWithLevels = BundleLauncherHelper.getMergedBundleMap(launchConfig, false);
475+
ShowBundlesDialog dialog = new ShowBundlesDialog(PDEPlugin.getActiveWorkbenchShell(),
476+
modelsWithLevels);
477+
dialog.open();
478+
} catch (CoreException e) {
479+
PDEPlugin.log(e);
480+
}
481+
}
482+
463483
private Button createButton(Composite parent, int span, int indent, String text) {
464484
Button button = new Button(parent, SWT.CHECK);
465485
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: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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.Shell;
34+
import org.eclipse.swt.widgets.Text;
35+
36+
37+
public class ShowBundlesDialog extends Dialog {
38+
private Text fModuleArgumentsText;
39+
private final Map<IPluginModelBase, String> fModelsWithLevels;
40+
41+
42+
protected ShowBundlesDialog(Shell parentShell, Map<IPluginModelBase, String> modelsWithLevels) {
43+
super(parentShell);
44+
this.fModuleArgumentsText = null;
45+
fModelsWithLevels = 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+
fModuleArgumentsText = new Text(comp, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
87+
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
88+
fModuleArgumentsText.setLayoutData(gd);
89+
90+
StringJoiner lines = new StringJoiner("\n"); //$NON-NLS-1$
91+
lines.add("List of all bundles contained in this launch:\n" //$NON-NLS-1$
92+
+ "<Symbolic Name>, <Version>, <Start level>, <File Path>"); //$NON-NLS-1$
93+
fModelsWithLevels.forEach((model, value) -> {
94+
int index = value.indexOf(':');
95+
BundleDescription bundle = model.getBundleDescription();
96+
String startLevel = value.substring(0, index);
97+
lines.add(bundle.getSymbolicName() + ", " + bundle.getVersion() + ", " + startLevel + ", " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
98+
+ model.getInstallLocation());
99+
});
100+
fModuleArgumentsText.setText(lines.toString());
101+
fModuleArgumentsText.setEditable(false);
102+
103+
return comp;
104+
}
105+
106+
@Override
107+
protected void buttonPressed(int buttonId) {
108+
if (buttonId == OK) {
109+
Clipboard clipboard = new Clipboard(null);
110+
try {
111+
Transfer[] transfers = { TextTransfer.getInstance() };
112+
Object[] data = { fModuleArgumentsText.getText() };
113+
clipboard.setContents(data, transfers);
114+
} finally {
115+
clipboard.dispose();
116+
}
117+
}
118+
super.buttonPressed(buttonId);
119+
}
120+
121+
}

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

0 commit comments

Comments
 (0)