Skip to content

Commit

Permalink
Product Editor: Fix NPE in launcher section / macOS bundle url types
Browse files Browse the repository at this point in the history
Corner case (no <launcher> element present, yet) was missed in eclipse-pde#1326.

Fixes eclipse-pde#1443.
  • Loading branch information
sratz committed Oct 16, 2024
1 parent f6bcbe3 commit f89e5fe
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ public MacBundleUrlTypesComposite(Composite comp, FormToolkit toolkit) {
fBundleUrlTypesTable.setLabelProvider(new LabelProvider());
fBundleUrlTypesTable.setContentProvider((IStructuredContentProvider) inputElement -> {
if (inputElement instanceof IProduct product) {
return product.getLauncherInfo().getMacBundleUrlTypes().toArray();
ILauncherInfo launcherInfo = product.getLauncherInfo();
if (launcherInfo != null) {
return launcherInfo.getMacBundleUrlTypes().toArray();
}
}
return new Object[0];
});
Expand Down Expand Up @@ -477,14 +480,14 @@ private void openBundleURLTypeDialog(IMacBundleUrlType propertyToEdit, Set<IMacB
}

private Set<IMacBundleUrlType> getExistingBundleUrlTypes() {
return new HashSet<>(getProduct().getLauncherInfo().getMacBundleUrlTypes());
return new HashSet<>(getLauncherInfo().getMacBundleUrlTypes());
}

private void handleRemove() {
IStructuredSelection ssel = fBundleUrlTypesTable.getStructuredSelection();
if (!ssel.isEmpty()) {
List<IMacBundleUrlType> bundleUrlTypes = ssel.toList();
getProduct().getLauncherInfo().removeMacBundleUrlTypes(bundleUrlTypes);
getLauncherInfo().removeMacBundleUrlTypes(bundleUrlTypes);
fBundleUrlTypesTable.refresh(false);
}
}
Expand Down Expand Up @@ -554,13 +557,13 @@ protected void validate() {
@Override
protected void okPressed() {
if (fEdit != null) {
getProduct().getLauncherInfo().removeMacBundleUrlTypes(List.of(fEdit));
getLauncherInfo().removeMacBundleUrlTypes(List.of(fEdit));
}
IProductModelFactory factory = getModel().getFactory();
fEdit = factory.createMacBundleUrlType();
fEdit.setScheme(fScheme.getText().trim());
fEdit.setName(fName.getText().trim());
getProduct().getLauncherInfo().addMacBundleUrlTypes(List.of(fEdit));
getLauncherInfo().addMacBundleUrlTypes(List.of(fEdit));
super.okPressed();
}

Expand Down

0 comments on commit f89e5fe

Please sign in to comment.