From 1eefd733c5d2e827ee56dc6d5c16e6e798520cd8 Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Wed, 3 Nov 2021 14:55:21 +0100 Subject: Bug 576651 - [Facet] problem when loading and unloading a Facet declared with the AF Change-Id: If6af88f5f99af1939b30d5c010768b4a5eb25d73 Signed-off-by: Vincent Lorenzo --- .../META-INF/MANIFEST.MF | 2 +- .../emf/org.eclipse.papyrus.infra.ui.emf/pom.xml | 2 +- ...ectureFrameworkCustomizationManagerUpdater.java | 7 +++--- .../facet/WorskpaceCustomizationUpdater.java | 29 ++++++++++++++++------ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF index 11f9333033d..f1f7a8a17b5 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF @@ -35,7 +35,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.papyrus.infra.core.architecture;bundle-version="[3.0.0,4.0.0)" Bundle-Vendor: %pluginProvider Bundle-ActivationPolicy: lazy -Bundle-Version: 3.1.0.qualifier +Bundle-Version: 3.1.100.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.infra.ui.internal.emf.Activator diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/pom.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/pom.xml index e89cb372391..058c5ffff8e 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/pom.xml +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/pom.xml @@ -9,6 +9,6 @@ 0.0.1-SNAPSHOT org.eclipse.papyrus.infra.ui.emf - 3.1.0-SNAPSHOT + 3.1.100-SNAPSHOT eclipse-plugin \ No newline at end of file diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/ArchitectureFrameworkCustomizationManagerUpdater.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/ArchitectureFrameworkCustomizationManagerUpdater.java index 8df55149ce2..c3d6cf1b0cf 100755 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/ArchitectureFrameworkCustomizationManagerUpdater.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/ArchitectureFrameworkCustomizationManagerUpdater.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2020 CEA LIST and others. + * Copyright (c) 2020, 2021 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,7 +10,7 @@ * * Contributors: * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 576651 *****************************************************************************/ package org.eclipse.papyrus.infra.ui.emf.internal.facet; @@ -195,6 +195,8 @@ public class ArchitectureFrameworkCustomizationManagerUpdater extends WorskpaceC if (loadedFacetPreferences != null && !"".equals(loadedFacetPreferences)) { //$NON-NLS-1$ settings.put(LOADED_FACET_ORDER, loadedFacetPreferences.split(SEPARATOR_DEFAULT_LOADED_FACET)); } + } else { + settings = settings.getSection(modelKey); } return settings; } @@ -317,7 +319,6 @@ public class ArchitectureFrameworkCustomizationManagerUpdater extends WorskpaceC final ArchitectureDescriptionUtils adUtils = new ArchitectureDescriptionUtils(modelSet); final MergedArchitectureContext ctx = adUtils.getArchitectureContext(); if (ctx instanceof MergedArchitectureDescriptionLanguage) { - // TODO on doit probablement les recharger dans un autre resource set return ((MergedArchitectureDescriptionLanguage) ctx).getTreeViewerConfigurations(); } } diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/WorskpaceCustomizationUpdater.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/WorskpaceCustomizationUpdater.java index 69b6c6aaf02..f3084d988ad 100755 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/WorskpaceCustomizationUpdater.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/internal/facet/WorskpaceCustomizationUpdater.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2020 CEA LIST and others. + * Copyright (c) 2020, 2021 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -9,8 +9,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * Vincent Lorenzo (CEA LIST) - Initial API and implementation - * + * Vincent LORENZO (CEA LIST) - Initial API and implementation + * Vincent LORENZO (CEA LIST) - Bug 576651 *****************************************************************************/ package org.eclipse.papyrus.infra.ui.emf.internal.facet; @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.DialogSettings; import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.IDialogSettingsProvider; import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager; import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory; import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; @@ -34,6 +35,7 @@ import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationManager; import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; import org.eclipse.papyrus.infra.emf.CustomizationComparator; import org.eclipse.papyrus.infra.ui.internal.emf.Activator; +import org.eclipse.ui.PlatformUI; /** * This class manages the applied customizations (apply/reset) and is able to save user changes with a workspace preferences @@ -114,7 +116,7 @@ public class WorskpaceCustomizationUpdater implements ICustomizationManagerUpdat * the dialog setting used to save the preferences or null if not found */ protected final IDialogSettings getWorkspaceBrowserCustomizationDialogSettings() { - return Activator.getDefault().getDialogSettings().getSection(CUSTOMIZATION_MANAGER_SECTION); + return getDialogSettingProvider().getDialogSettings().getSection(CUSTOMIZATION_MANAGER_SECTION); } /** @@ -134,7 +136,7 @@ public class WorskpaceCustomizationUpdater implements ICustomizationManagerUpdat protected final IDialogSettings getOrCreateWorkspaceBrowserCustomizationDialogSettings() { IDialogSettings settings = getWorkspaceBrowserCustomizationDialogSettings(); if (settings == null) { - settings = Activator.getDefault().getDialogSettings().addNewSection(CUSTOMIZATION_MANAGER_SECTION); + settings = getDialogSettingProvider().getDialogSettings().addNewSection(CUSTOMIZATION_MANAGER_SECTION); String loadedFacetPreferences = Activator.getDefault().getPreferenceStore().getString(DEFAULT_LOADED_FACET); if (loadedFacetPreferences != null && !"".equals(loadedFacetPreferences)) { //$NON-NLS-1$ settings.put(LOADED_FACET_ORDER, loadedFacetPreferences.split(SEPARATOR_DEFAULT_LOADED_FACET)); @@ -225,8 +227,10 @@ public class WorskpaceCustomizationUpdater implements ICustomizationManagerUpdat * Restores the default Customization Manager configuration */ protected void destroyUserPreferences() { - final DialogSettings settings = (DialogSettings) Activator.getDefault().getDialogSettings(); - settings.removeSection(CUSTOMIZATION_MANAGER_SECTION); + final IDialogSettings settings = getBrowserCustomizationDialogSettings(); + if (settings instanceof DialogSettings) { + ((DialogSettings) settings).removeSection(CUSTOMIZATION_MANAGER_SECTION); + } } /** @@ -249,6 +253,17 @@ public class WorskpaceCustomizationUpdater implements ICustomizationManagerUpdat customizationList.addAll(appliedCustomizations); String[] loadedCustomizationArray = customizationList.stream().map(customization -> customization.eResource().getURI().toString()).toArray(size -> new String[size]); dialogSettings.put(LOADED_FACET_ORDER, loadedCustomizationArray); + + // not required, Eclipse save itself the IDialogSettings when we close it + // just here for debug and information purpose + // getDialogSettingProvider().saveDialogSettings(); + } + + /** + * Returns the dialog setting provider + */ + protected final IDialogSettingsProvider getDialogSettingProvider() { + return PlatformUI.getDialogSettingsProvider(Activator.getDefault().getBundle()); } /** -- cgit v1.2.3