Skip to content

Commit

Permalink
[eclipse-pde#1417] Plug-in editor: Runtime tab should show selected p…
Browse files Browse the repository at this point in the history
…ackage

The simplest solution would be to use the section description
  • Loading branch information
ruspl-afed committed Nov 7, 2024
1 parent 03ff9fb commit 050b5af
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,10 @@ public class PDEUIMessages extends NLS {

public static String ExportPackageVisibilitySection_default;

public static String ExportPackageVisibilitySection_one;

public static String ExportPackageVisibilitySection_many;

public static String ExportPackageVisibilitySection_hideAll;

public static String ExportPackageSection_add;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
Expand All @@ -31,6 +35,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.core.plugin.IPluginModelBase;
Expand Down Expand Up @@ -373,6 +378,30 @@ private void update(ExportPackageObject[] objects) {
getTablePart().setButtonEnabled(1, fInternalButton.getSelection() && isEditable());
fFriendViewer.setInput(object);
fBlockChanges = false;
getSection().setDescription(description(objects));
}

private String description(ExportPackageObject[] packages) {
List<String> names = names(packages);
switch (names.size()) {
case 0: {
return PDEUIMessages.ExportPackageVisibilitySection_default;
}
case 1: {
return NLS.bind(PDEUIMessages.ExportPackageVisibilitySection_one, names.get(0));
}
default:
return NLS.bind(PDEUIMessages.ExportPackageVisibilitySection_many,
names.stream().collect(Collectors.joining(", "))); //$NON-NLS-1$
}

}

private List<String> names(ExportPackageObject[] packages) {
if (packages == null) {
return Collections.emptyList();
}
return Arrays.stream(packages).filter(Objects::nonNull).map(ExportPackageObject::getName).toList();
}

private BundleInputContext getBundleContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,9 @@ ExportPackageSection_findReferences=Find References
ExportOptionsTab_antReservedMessage=build.xml is a file name reserved for PDE
ExportOptionsTab_allowBinaryCycles=A&llow for binary cycles in target platform
ExportOptionsTab_use_workspace_classfiles=&Use class files compiled in the workspace
ExportPackageVisibilitySection_default=The select package is:
ExportPackageVisibilitySection_default=The selected package is:
ExportPackageVisibilitySection_one=The selected package {0} is:
ExportPackageVisibilitySection_many=The selected packages {0} are:
ExportPackageVisibilitySection_hideAll=provisional API, generating warnings, except for:
CrossPlatformExportPage_available=&Available platforms:
CrossPlatformExportPage_title=Cross-platform export
Expand Down

0 comments on commit 050b5af

Please sign in to comment.