From 57af836c6627bfaeec2336096b0abb22ba72547b Mon Sep 17 00:00:00 2001 From: Thanh Liem PHAN Date: Fri, 25 Aug 2017 15:43:32 +0200 Subject: Bug 521353: [Test][Diagram] Edit part selection is not restored after reloading diagram https://bugs.eclipse.org/bugs/show_bug.cgi?id=521353 - Call setFofus to initialize the graphical viewer before restoring an editor part. This ensure the selection of the edit part of current editor to be restored correctly. Change-Id: Ibccb7d5ec0f9357880f483e4e7836978c4c27721 Signed-off-by: Thanh Liem PHAN (cherry picked from commit ec4f46fe7a166e5bb0ef71b80210aa61e499bca0) (cherry picked from commit 6e49019e94036a776c9db4865862c732361ab579) --- .../infra/ui/editor/reload/DelegatingReloadContext.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/editor/reload/DelegatingReloadContext.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/editor/reload/DelegatingReloadContext.java index 386e1722ff2..4fb24b7cf89 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/editor/reload/DelegatingReloadContext.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/editor/reload/DelegatingReloadContext.java @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2014 CEA and others. +/***************************************************************************** + * Copyright (c) 2014, 2017 CEA and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,12 +8,13 @@ * * Contributors: * Christian W. Damus (CEA) - Initial API and implementation - * - */ + * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 521353 + *****************************************************************************/ package org.eclipse.papyrus.infra.ui.editor.reload; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.papyrus.infra.core.utils.AdapterUtils; +import org.eclipse.ui.part.EditorPart; /** @@ -53,6 +54,12 @@ public class DelegatingReloadContext implements IDisposableReloadContext, IAdapt if (delegate != null) { IReloadContextProvider provider = AdapterUtils.adapt(reloadContextProvider, IReloadContextProvider.class, null); if (provider != null) { + // Call setFocus to initialize the graphical viewer before restoring element of the current editor + // This assures that the selected edit part of the current editor is properly initialized + // Please see bug 519107 and 521353 for more details + if (reloadContextProvider instanceof EditorPart) { + ((EditorPart) reloadContextProvider).setFocus(); + } provider.restore(delegate); } } -- cgit v1.2.3