Skip to content

Commit

Permalink
eclipse-capella#2894 Avoid potential deadlocks in refresh
Browse files Browse the repository at this point in the history
Change-Id: I653a0e579d58abf71f44ceb8eb85179cc07d5eb5
Signed-off-by: Maxime Porhel <[email protected]>
  • Loading branch information
mPorhel committed Sep 9, 2024
1 parent fb402a8 commit 2a6be8b
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2023 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2024 THALES GLOBAL SERVICES and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* Thales - initial API and implementation
* Maxime Porhel (Obeo) - Avoid potential deadlocks in refresh
*******************************************************************************/
package org.polarsys.capella.core.sirius.analysis;

Expand Down Expand Up @@ -93,6 +94,8 @@
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
import org.eclipse.sirius.tools.api.SiriusPlugin;
import org.eclipse.sirius.ui.business.api.dialect.DialectEditor;
import org.eclipse.sirius.ui.business.api.session.IEditingSession;
import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
Expand Down Expand Up @@ -2100,13 +2103,20 @@ public void refreshRepresentationOfEditor(IEditorPart editor) {
* @return
*/
public EditPart getEditPart(DDiagramElement diagramElement) {
IEditorPart editor = EclipseUIUtil.getActiveEditor();
if (editor instanceof DiagramEditor) {
Session session = new EObjectQuery(diagramElement).getSession();
DDiagram parentDiagram = diagramElement == null ? null : diagramElement.getParentDiagram();
Session session = parentDiagram == null ? null : new EObjectQuery(parentDiagram).getSession();
IEditingSession uiSession = SessionUIManager.INSTANCE.getUISession(session);

DialectEditor editor = null;
if (uiSession != null && parentDiagram != null) {
editor = uiSession.getEditor(parentDiagram);
}

if (editor instanceof DiagramEditor diagramEditor) {
View gmfView = SiriusGMFHelper.getGmfView(diagramElement, session);

if (gmfView != null && editor instanceof DiagramEditor) {
final Map<?, ?> editPartRegistry = ((DiagramEditor) editor).getDiagramGraphicalViewer().getEditPartRegistry();
if (gmfView != null && diagramEditor.getDiagramGraphicalViewer() != null) {
final Map<?, ?> editPartRegistry = diagramEditor.getDiagramGraphicalViewer().getEditPartRegistry();
final Object editPart = editPartRegistry.get(gmfView);
if (editPart instanceof EditPart) {
return (EditPart) editPart;
Expand Down

0 comments on commit 2a6be8b

Please sign in to comment.