diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/OSGiLaunchConfigurationInitializer.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/OSGiLaunchConfigurationInitializer.java index 5635d94123f..6a50bc10497 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/OSGiLaunchConfigurationInitializer.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/OSGiLaunchConfigurationInitializer.java @@ -94,7 +94,7 @@ protected void initializeBundleState(ILaunchConfigurationWorkingCopy configurati } configuration.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, workspaceBundles); configuration.setAttribute(IPDELauncherConstants.SELECTED_TARGET_BUNDLES, targetBundles); - configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + configuration.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); } private boolean isSourceBundle(PDEState pdeState, IPluginModelBase model) { diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java index 9385f331d1e..80fdcb59d61 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/PluginBasedLaunchTest.java @@ -154,7 +154,7 @@ public void testGetMergedBundleMap_mixedPluginsFromWorkspaceWithAutomaticAddAndT Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0", "plugin.b")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*2.0.0", "plugin.c")); wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_BUNDLES, Set.of("plugin.x*2.0.0", "plugin.x*3.0.0", "plugin.y")); @@ -371,7 +371,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_noDisabledPlug Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); }; Set expectedBundles = Set.of( // @@ -394,7 +394,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_singleVersionP Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.c")); }; @@ -417,7 +417,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_singleVersionP Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.c*1.0.0")); }; @@ -447,7 +447,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_multiVersionPl Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*2.0.0", "plugin.a*4.0.0")); }; @@ -471,7 +471,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_multiVersionPl Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of()); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0", "plugin.a*3.0.0")); }; @@ -494,7 +494,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_multiVersionPl Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*2.0.0")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a")); }; @@ -516,7 +516,7 @@ public void testGetMergedBundleMap_automaticAddedWorkspacePlugins_sameMMMVersion Consumer launchConfigSetup = wc -> { wc.setAttribute(IPDELauncherConstants.SELECTED_WORKSPACE_BUNDLES, Set.of("plugin.a*1.0.0.202111250056")); - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); }; Set expectedBundles = Set.of( // @@ -777,7 +777,7 @@ public void testGetMergedBundleMap_workspacePluginAddedAutomaticallyAndTargetPlu bundle("plugin.b", "1.0.1")); Consumer launchConfigSetup = wc -> { - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_BUNDLES, Set.of("plugin.a", "plugin.b*1.0.1")); }; @@ -799,7 +799,7 @@ public void testGetMergedBundleMap_workspacePluginAddedAutomaticallyAndTargetPlu bundle("plugin.a", "1.0.0.202111102345")); Consumer launchConfigSetup = wc -> { - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); wc.setAttribute(IPDELauncherConstants.SELECTED_TARGET_BUNDLES, Set.of("plugin.a*1.0.0.202111102345")); }; @@ -1044,7 +1044,7 @@ private static ILaunchConfigurationWorkingCopy createPluginLaunchConfig(String n ILaunchConfigurationType type = launchManager.getLaunchConfigurationType("org.eclipse.pde.ui.RuntimeWorkbench"); ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name); wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false); - wc.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false); + wc.removeAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES); wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false); return wc; } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java index 0bf97106e6a..df9f4f0670d 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java @@ -948,10 +948,25 @@ public void performApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute(IPDELauncherConstants.AUTOMATIC_INCLUDE_REQUIREMENTS, includeRequirements); fAutoIncludeRequirementsButtonChanged = false; } - config.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, fIncludeOptionalButton.getSelection()); - config.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, fAddWorkspaceButton.getSelection()); + boolean includeOptional = fIncludeOptionalButton.getSelection(); + if (!includeOptional) { + config.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, false); + } else { + config.removeAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL); + } + boolean automaticAdd = fAddWorkspaceButton.getSelection(); + if (!automaticAdd) { + config.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false); + } else { + config.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); + } config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, fAutoValidate.getSelection()); - config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, fFilterButton.getSelection()); + boolean showSelectedOnly = fFilterButton.getSelection(); + if (showSelectedOnly) { + config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, true); + } else { + config.removeAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY); + } savePluginState(config); updateCounter(); } @@ -959,10 +974,10 @@ public void performApply(ILaunchConfigurationWorkingCopy config) { protected abstract void savePluginState(ILaunchConfigurationWorkingCopy config); public void setDefaults(ILaunchConfigurationWorkingCopy config) { - config.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true); - config.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + config.removeAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL); + config.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, true); - config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, false); + config.removeAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY); } public void enableViewer(boolean enable) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java index 2b985836d96..f8770a618f0 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java @@ -1203,7 +1203,12 @@ public void performApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute(IPDELauncherConstants.AUTOMATIC_INCLUDE_REQUIREMENTS, includeRequirements); fAutoIncludeRequirementsButtonChanged = false; } - config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, fFilterButton.getSelection()); + boolean showSelectedOnly = fFilterButton.getSelection(); + if (showSelectedOnly) { + config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, true); + } else { + config.removeAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY); + } config.setAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, fFeatureWorkspaceButton.getSelection() ? IPDELauncherConstants.LOCATION_WORKSPACE : IPDELauncherConstants.LOCATION_EXTERNAL); config.setAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, fWorkspacePluginButton.getSelection() ? IPDELauncherConstants.LOCATION_WORKSPACE : IPDELauncherConstants.LOCATION_EXTERNAL); config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, fAutoValidate.getSelection()); @@ -1256,7 +1261,7 @@ private void saveSortOrder() { } public void setDefaults(ILaunchConfigurationWorkingCopy config) { - config.setAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY, false); + config.removeAttribute(IPDELauncherConstants.SHOW_SELECTED_ONLY); config.setAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, IPDELauncherConstants.LOCATION_WORKSPACE); config.setAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, IPDELauncherConstants.LOCATION_WORKSPACE); config.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, true); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java index 0d9de821ca4..4233402bdd9 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiBundleBlock.java @@ -61,7 +61,11 @@ protected void savePluginState(ILaunchConfigurationWorkingCopy config) { } } } - config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, buffer.getNameSet()); + if (!buffer.getNameSet().isEmpty()) { + config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, buffer.getNameSet()); + } else { + config.removeAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES); + } } public void initializeFrom(ILaunchConfiguration configuration) throws CoreException { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java index db1d881d360..db7b54b9dcc 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/OSGiFrameworkBlock.java @@ -160,7 +160,12 @@ private void initializeFramework(ILaunchConfiguration config) throws CoreExcepti public void performApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute(IPDELauncherConstants.USE_DEFAULT, fLaunchWithCombo.getSelectionIndex() == 0); - config.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, fLaunchWithCombo.getSelectionIndex() == 1); + boolean useCustomFeatures = fLaunchWithCombo.getSelectionIndex() == 1; + if (useCustomFeatures) { + config.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true); + } else { + config.removeAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES); + } config.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, Boolean.toString(true).equals(fDefaultAutoStart.getText())); config.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, fDefaultStartLevel.getSelection()); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java index 2a62284062a..e78f3b3b12c 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginBlock.java @@ -156,7 +156,12 @@ protected void savePluginState(ILaunchConfigurationWorkingCopy config) { } } } - config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, buffer.getNameSet()); + if (!buffer.getNameSet().isEmpty()) { + config.setAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES, + buffer.getNameSet()); + } else { + config.removeAttribute(IPDELauncherConstants.DESELECTED_WORKSPACE_BUNDLES); + } } } diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java index 87f578fb464..a6d6eab3735 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/EclipseLaunchShortcut.java @@ -251,7 +251,7 @@ else if (TargetPlatformHelper.getTargetVersion() >= 3.2) wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, true); wc.setAttribute(IPDELauncherConstants.PRODUCT, product); } - wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); + wc.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); } else { String defaultProduct = TargetPlatform.getDefaultProduct(); if (defaultProduct != null) { diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java index 26995a12242..554b1e05f24 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/JUnitWorkbenchLaunchShortcut.java @@ -72,9 +72,9 @@ protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement // Plug-ins to launch configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, true); configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false); - configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false); // ignored - configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); // ignored - configuration.setAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true); // ignored + configuration.removeAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES); + configuration.removeAttribute(IPDELauncherConstants.AUTOMATIC_ADD); // ignored + configuration.removeAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL); // Program arguments String programArgs = LaunchArgumentsHelper.getInitialProgramArguments(); 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 8a9b45d6a16..a77ec56e3c6 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 @@ -158,6 +158,7 @@ public void createControl(Composite parent) { @Override public void initializeFrom(ILaunchConfiguration configuration) { // Long-running initialization happens on first activation of this tab + System.out.println("PluginsTab.initializeFrom()"); } @Override @@ -193,7 +194,7 @@ public void activated(ILaunchConfigurationWorkingCopy configuration) { @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, true); - configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false); + configuration.removeAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES); fBlock.setDefaults(configuration); } @@ -204,8 +205,13 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { } int index = fSelectionCombo.getSelectionIndex(); configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, index == DEFAULT_SELECTION); - configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, index == FEATURE_SELECTION); - fBlock.performApply(configuration); + boolean useCustomFeatures = index == FEATURE_SELECTION; + if (useCustomFeatures) { + configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true); + } else { + configuration.removeAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES); + } + fBlock.performApply(configuration); // clear default values for auto-start and start-level if default String autoText = fDefaultAutoStart.getText(); if (Boolean.toString(false).equals(autoText)) {