diff options
| author | Pierre-Charles David | 2017-08-25 11:59:35 +0000 |
|---|---|---|
| committer | Joao Barata | 2017-09-22 11:08:04 +0000 |
| commit | 49e04be599afc297f1e399f802ede599433507ae (patch) | |
| tree | b45a3f5527fcee5125c84749399ddc229c6b6015 | |
| parent | ae26a270718482b65efd1a12f0ae16c9e5e4030d (diff) | |
| download | org.eclipse.amalgam-49e04be599afc297f1e399f802ede599433507ae.tar.gz org.eclipse.amalgam-49e04be599afc297f1e399f802ede599433507ae.tar.xz org.eclipse.amalgam-49e04be599afc297f1e399f802ede599433507ae.zip | |
[509735] Get the session from the root EObject instead of a global singleton
This makes it possible for AbstractHyperlinkAdapter to be executed
from other contexts than the ActicityExplorer editor (e.g. the Sirius
aird editor).
Bug: 509735
Change-Id: I99d5b0402b4ea78603bcec78033e3bd4320930e9
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/hyperlinkadapter/AbstractHyperlinkAdapter.java | 84 |
1 files changed, 35 insertions, 49 deletions
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/hyperlinkadapter/AbstractHyperlinkAdapter.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/hyperlinkadapter/AbstractHyperlinkAdapter.java index a501a0b2..bc31c342 100644 --- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/hyperlinkadapter/AbstractHyperlinkAdapter.java +++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/hyperlinkadapter/AbstractHyperlinkAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2006, 2017 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.amalgam.explorer.activity.ui.api.hyperlinkadapter; -import org.eclipse.amalgam.explorer.activity.ui.api.manager.ActivityExplorerManager; import org.eclipse.emf.ecore.EObject; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.ui.forms.events.HyperlinkAdapter; @@ -18,57 +17,44 @@ import org.eclipse.ui.forms.events.HyperlinkEvent; /** * Base class to implement an {@link HyperlinkAdapter} in Modeling context. - * + * */ public abstract class AbstractHyperlinkAdapter extends HyperlinkAdapter { - /** - * Root Element of the Semantic model. - */ - protected EObject _root; + /** + * Root Element of the Semantic model. + */ + protected final EObject root; - /** - * Constructor. - * - * @param root - */ - public AbstractHyperlinkAdapter(EObject root) { - _root = root; - } + /** + * Constructor. + * + * @param root + */ + public AbstractHyperlinkAdapter(EObject root) { + this.root = root; + } - /** - * Constructor. - * - * @param root - */ - @Deprecated - public AbstractHyperlinkAdapter(EObject root, Session session) { - this(root); - } - - /** - * Get the model element that the run is performed against.<br> - * - * @param root - * @return - */ - protected EObject getModelElement(EObject root) { - return _root; - } + /** + * Get the model element that the run is performed against.<br> + * + * @param root + * @return + */ + protected EObject getModelElement(EObject root) { + return this.root; + } - /** - * @see org.eclipse.ui.forms.events.HyperlinkAdapter#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent) - */ - @Override - public void linkActivated(HyperlinkEvent event) { - linkPressed(event, _root, ActivityExplorerManager.INSTANCE.getSession()); - } + @Override + public void linkActivated(HyperlinkEvent event) { + Session.of(root).ifPresent(s -> linkPressed(event, root, s)); + } - /** - * Called when link is activated i.e pressed by the end-user. - * - * @param event - * @param root - * @param session - */ - protected abstract void linkPressed(HyperlinkEvent event, EObject root, Session session); + /** + * Called when link is activated i.e pressed by the end-user. + * + * @param event + * @param root + * @param session + */ + protected abstract void linkPressed(HyperlinkEvent event, EObject root, Session session); } |
