Skip to content

Commit 70a141e

Browse files
author
Neha Burnwal
committed
Added a button to show launch bundles
1 parent 8de0b27 commit 70a141e

File tree

5 files changed

+152
-6
lines changed

5 files changed

+152
-6
lines changed

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

Lines changed: 9 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;
@@ -1525,6 +1531,7 @@ public class PDEUIMessages extends NLS {
15251531
public static String TemplateSelectionPage_column_point;
15261532

15271533
public static String PluginSelectionDialog_title;
1534+
public static String LaunchPluginDialog_title;
15281535
public static String PluginSelectionDialog_message;
15291536

15301537
public static String PluginImportOperation_could_not_delete_project;
@@ -2478,6 +2485,8 @@ public class PDEUIMessages extends NLS {
24782485

24792486
public static String AbstractPluginBlock_counter;
24802487

2488+
public static String PluginsTabToolBar_show_launch_bundles;
2489+
24812490
public static String AbstractRepository_ErrorLoadingImageFromJar;
24822491

24832492
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,11 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
918918
validatecomp.setLayoutData(gd);
919919

920920
if (fTab instanceof PluginsTab) {
921-
fAutoValidate = SWTFactory.createCheckButton(validatecomp, PDEUIMessages.PluginsTabToolBar_auto_validate_plugins, null, false, 1);
921+
fAutoValidate = SWTFactory.createCheckButton(validatecomp,
922+
PDEUIMessages.PluginsTabToolBar_auto_validate_plugins, null, false, 1);
922923
} else if (fTab instanceof BundlesTab) {
923-
fAutoValidate = SWTFactory.createCheckButton(validatecomp, PDEUIMessages.PluginsTabToolBar_auto_validate_bundles, null, false, 1);
924+
fAutoValidate = SWTFactory.createCheckButton(validatecomp,
925+
PDEUIMessages.PluginsTabToolBar_auto_validate_bundles, null, false, 1);
924926
} else {
925927
fAutoValidate = SWTFactory.createCheckButton(validatecomp,
926928
NLS.bind(PDEUIMessages.PluginsTabToolBar_auto_validate,
@@ -929,9 +931,15 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
929931
}
930932

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

937+
Button fShowPlugin = SWTFactory.createPushButton(rightAlignComp,
938+
PDEUIMessages.PluginsTabToolBar_show_launch_bundles, null);
939+
fShowPlugin.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
940+
fShowPlugin.addSelectionListener(SelectionListener
941+
.widgetSelectedAdapter(e -> AbstractPluginBlock.handleShowPluginsPressed(fLaunchConfig)));
942+
935943
if (fTab instanceof PluginsTab) {
936944
fValidateButton = SWTFactory.createPushButton(rightAlignComp, PDEUIMessages.PluginsTabToolBar_validate_plugins, null);
937945
} else if (fTab instanceof BundlesTab) {
@@ -942,6 +950,7 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
942950
}
943951

944952
fValidateButton.addSelectionListener(fListener);
953+
945954
}
946955

947956
public void dispose() {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package org.eclipse.pde.internal.ui.launcher;
2+
3+
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
7+
import org.eclipse.jface.dialogs.Dialog;
8+
import org.eclipse.jface.dialogs.IDialogConstants;
9+
import org.eclipse.pde.core.plugin.IPluginModelBase;
10+
import org.eclipse.pde.internal.ui.PDEUIMessages;
11+
import org.eclipse.swt.SWT;
12+
import org.eclipse.swt.dnd.Clipboard;
13+
import org.eclipse.swt.dnd.TextTransfer;
14+
import org.eclipse.swt.dnd.Transfer;
15+
import org.eclipse.swt.graphics.Font;
16+
import org.eclipse.swt.layout.GridData;
17+
import org.eclipse.swt.layout.GridLayout;
18+
import org.eclipse.swt.widgets.Composite;
19+
import org.eclipse.swt.widgets.Control;
20+
import org.eclipse.swt.widgets.Group;
21+
import org.eclipse.swt.widgets.Shell;
22+
import org.eclipse.swt.widgets.Text;
23+
24+
25+
public class ShowBundlesDialog extends Dialog {
26+
Text fModuleArgumentsText;
27+
Map<IPluginModelBase, String> fModelsWithLevels = new HashMap<>();
28+
29+
30+
protected ShowBundlesDialog(Shell parentShell, Map<IPluginModelBase, String> modelsWithLevels) {
31+
super(parentShell);
32+
fModelsWithLevels = modelsWithLevels;
33+
}
34+
35+
@Override
36+
protected void configureShell(Shell newShell) {
37+
super.configureShell(newShell);
38+
newShell.setText(PDEUIMessages.ShowBundlesDialog_LaunchBundles);
39+
}
40+
41+
@Override
42+
protected void createButtonsForButtonBar(Composite parent) {
43+
createButton(parent, IDialogConstants.OK_ID,
44+
PDEUIMessages.ShowBundlesDialog_Copy, true);
45+
createButton(parent, IDialogConstants.CANCEL_ID,
46+
PDEUIMessages.ShowBundlesDialog_Close, false);
47+
}
48+
49+
@Override
50+
protected Control createDialogArea(Composite parent) {
51+
Composite comp = (Composite) super.createDialogArea(parent);
52+
Font font = parent.getFont();
53+
54+
Group group = new Group(comp, SWT.NONE);
55+
GridLayout topLayout = new GridLayout();
56+
group.setLayout(topLayout);
57+
GridData gd = new GridData(GridData.FILL_BOTH);
58+
gd.heightHint = convertHeightInCharsToPixels(20);
59+
gd.widthHint = convertWidthInCharsToPixels(90);
60+
group.setLayoutData(gd);
61+
group.setFont(font);
62+
63+
fModuleArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
64+
gd = new GridData(GridData.FILL_BOTH);
65+
gd.heightHint = convertHeightInCharsToPixels(10);
66+
gd.widthHint = convertWidthInCharsToPixels(60);
67+
fModuleArgumentsText.setLayoutData(gd);
68+
69+
StringBuilder command = new StringBuilder();
70+
71+
for (Map.Entry<IPluginModelBase, String> entry : fModelsWithLevels.entrySet()) {
72+
IPluginModelBase model = entry.getKey();
73+
String value = entry.getValue();
74+
int index = value.indexOf(':');
75+
String startLevel = value.substring(0, index);
76+
command.append(model.getBundleDescription().getSymbolicName()).append(", ") //$NON-NLS-1$
77+
.append(model.getBundleDescription().getVersion()).append(", ").append(model.getInstallLocation()) //$NON-NLS-1$
78+
.append(", ").append(startLevel).append("\n"); //$NON-NLS-1$//$NON-NLS-2$
79+
}
80+
81+
fModuleArgumentsText.setText(command.toString());
82+
fModuleArgumentsText.setEditable(false);
83+
84+
return comp;
85+
}
86+
87+
@Override
88+
protected void buttonPressed(int buttonId) {
89+
if (buttonId == OK) {
90+
Clipboard clipboard = new Clipboard(null);
91+
try {
92+
TextTransfer textTransfer = TextTransfer.getInstance();
93+
Transfer[] transfers = new Transfer[] { textTransfer };
94+
Object[] data = new Object[] { fModuleArgumentsText.getText() };
95+
clipboard.setContents(data, transfers);
96+
} finally {
97+
clipboard.dispose();
98+
}
99+
}
100+
super.buttonPressed(buttonId);
101+
}
102+
103+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ ImportActionGroup_Repository_project=P&roject from a Repository...
11691169
####
11701170

11711171
PluginSelectionDialog_title = Plug-in Selection
1172+
LaunchPluginDialog_title = Launch Plug-ins List
11721173
PluginStructureCreator_name=Plug-in Structure Compare
11731174
PluginSelectionDialog_message = &Select a Plug-in:
11741175
PluginImportOperation_could_not_delete_project=Import operation could not delete the following project: {0}
@@ -1332,6 +1333,9 @@ EditorUtilities_pathNotValidImage=The specified path does not point to a valid i
13321333
EditorUtilities_imageTooLargeInfo=Images larger than {0} will overlap or hide text
13331334
EditorPreferencePage_text=Text
13341335
EditorPreferencePage_proc=Processing instructions
1336+
ShowBundlesDialog_Copy=C&opy && Close
1337+
ShowBundlesDialog_Close=&Close
1338+
ShowBundlesDialog_LaunchBundles=Launch Bundles
13351339

13361340
# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts"
13371341
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 +1511,7 @@ PluginsView_manifestEditor=&PDE Manifest Editor
15071511
PluginsTabToolBar_validate=&Validate {0}
15081512
PluginsTabToolBar_validate_plugins=&Validate Plug-ins
15091513
PluginsTabToolBar_validate_bundles=&Validate Bundles
1514+
PluginsTabToolBar_show_launch_bundles=&Show launch bundles
15101515
PluginsTab_selectedPlugins=Plug-ins selected below
15111516
PluginContentPage_rcpGroup=Rich Client Application
15121517
PluginWorkingSet_emptyName=The name must not be empty

0 commit comments

Comments
 (0)