From 62638c385088e0a5e9eaf85c5dd262cd46187609 Mon Sep 17 00:00:00 2001 From: fedejeanne <2205684+fedejeanne@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:10:09 +0200 Subject: [PATCH] Skip the method PluginsTab::performApply until after activation If this method (or part of it) is run before the tab has been activated then the default configuration passed as parameter will be modified and incorrect values will be introduced. This commit fixes a regression introduced in 98a58656a74bd163c8f4ad8f7a36dc492ac67e1c Fixes https://github.com/eclipse-pde/eclipse.pde/issues/1250 --- .../forceQualifierUpdate.txt | 3 +- .../eclipse/pde/ui/launcher/PluginsTab.java | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/org.eclipse.pde.doc.user/forceQualifierUpdate.txt b/org.eclipse.pde.doc.user/forceQualifierUpdate.txt index d47984e601b..ccd973021c4 100644 --- a/org.eclipse.pde.doc.user/forceQualifierUpdate.txt +++ b/org.eclipse.pde.doc.user/forceQualifierUpdate.txt @@ -1,3 +1,2 @@ Comparator Errors in 4.32 I-Build I20240304-0140 -Update to IPDELauncherConstants -https://github.com/eclipse-pde/eclipse.pde/issues/1250 +Update to IPDELauncherConstants \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java index ec5192f5643..8a9b45d6a16 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java @@ -59,6 +59,7 @@ public class PluginsTab extends AbstractLauncherTab { private Combo fDefaultAutoStart; private Spinner fDefaultStartLevel; private final Listener fListener; + private boolean fActivated; private static final int DEFAULT_SELECTION = 0; private static final int PLUGIN_SELECTION = 1; @@ -156,6 +157,16 @@ public void createControl(Composite parent) { @Override public void initializeFrom(ILaunchConfiguration configuration) { + // Long-running initialization happens on first activation of this tab + } + + @Override + public void activated(ILaunchConfigurationWorkingCopy configuration) { + if (fActivated) { + // Since this method can be expensive, only activate this tab once. + return; + } + try { int index = DEFAULT_SELECTION; if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false)) { @@ -171,6 +182,9 @@ public void initializeFrom(ILaunchConfiguration configuration) { fDefaultAutoStart.setText(Boolean.toString(auto)); int level = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); fDefaultStartLevel.setSelection(level); + + // If everything ran smoothly, this tab is activated + fActivated = true; } catch (CoreException e) { PDEPlugin.log(e); } @@ -185,10 +199,13 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { + if (!fActivated) { + return; + } int index = fSelectionCombo.getSelectionIndex(); configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, index == DEFAULT_SELECTION); configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, index == FEATURE_SELECTION); - fBlock.performApply(configuration); + fBlock.performApply(configuration); // clear default values for auto-start and start-level if default String autoText = fDefaultAutoStart.getText(); if (Boolean.toString(false).equals(autoText)) { @@ -217,16 +234,9 @@ public Image getImage() { return fImage; } - /** - * Validates the tab. If the feature option is chosen, and the workspace is not correctly set up, - * the error message is set. - * - * @see org.eclipse.pde.ui.launcher.AbstractLauncherTab#validateTab() - */ @Override public void validateTab() { - String errorMessage = null; - setErrorMessage(errorMessage); + setErrorMessage(null); } @Override