|
19 | 19 | import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; |
20 | 20 |
|
21 | 21 | import java.util.ArrayList; |
| 22 | +import java.util.Arrays; |
| 23 | +import java.util.Collections; |
22 | 24 | import java.util.List; |
| 25 | +import java.util.Objects; |
| 26 | +import java.util.stream.Collectors; |
23 | 27 |
|
24 | 28 | import org.eclipse.jface.action.Action; |
25 | 29 | import org.eclipse.jface.action.IMenuManager; |
|
31 | 35 | import org.eclipse.jface.viewers.StructuredSelection; |
32 | 36 | import org.eclipse.jface.viewers.TableViewer; |
33 | 37 | import org.eclipse.jface.window.Window; |
| 38 | +import org.eclipse.osgi.util.NLS; |
34 | 39 | import org.eclipse.pde.core.IBaseModel; |
35 | 40 | import org.eclipse.pde.core.IModelChangedEvent; |
36 | 41 | import org.eclipse.pde.core.plugin.IPluginModelBase; |
@@ -378,6 +383,30 @@ private void update(ExportPackageObject[] objects) { |
378 | 383 | getTablePart().setButtonEnabled(1, fInternalButton.getSelection() && isEditable()); |
379 | 384 | fFriendViewer.setInput(object); |
380 | 385 | fBlockChanges = false; |
| 386 | + getSection().setDescription(description(objects)); |
| 387 | + } |
| 388 | + |
| 389 | + private String description(ExportPackageObject[] packages) { |
| 390 | + List<String> names = names(packages); |
| 391 | + switch (names.size()) { |
| 392 | + case 0: { |
| 393 | + return PDEUIMessages.ExportPackageVisibilitySection_default; |
| 394 | + } |
| 395 | + case 1: { |
| 396 | + return NLS.bind(PDEUIMessages.ExportPackageVisibilitySection_one, names.get(0)); |
| 397 | + } |
| 398 | + default: |
| 399 | + return NLS.bind(PDEUIMessages.ExportPackageVisibilitySection_many, |
| 400 | + names.stream().collect(Collectors.joining(", "))); //$NON-NLS-1$ |
| 401 | + } |
| 402 | + |
| 403 | + } |
| 404 | + |
| 405 | + private List<String> names(ExportPackageObject[] packages) { |
| 406 | + if (packages == null) { |
| 407 | + return Collections.emptyList(); |
| 408 | + } |
| 409 | + return Arrays.stream(packages).filter(Objects::nonNull).map(ExportPackageObject::getName).toList(); |
381 | 410 | } |
382 | 411 |
|
383 | 412 | private BundleInputContext getBundleContext() { |
|
0 commit comments