Community
Participate
Working Groups
Currently, to access the active model, we use the ServiceRegistry, which in turn needs to have an active Papyrus Editor. When we are in a different context, this results in a NullPointerException. There are two options : - Find a general method to access the ServiceRegistry without a Papyrus editor. This may be problematic when more than one model is loaded (From different editors) : we need at least a "context". - Send the ServiceRegistry as a parameter to each element which requires it. This may not always be possible without a major refactoring. We should investigate on that.
We may investigate on the "Context"s in Eclipse e4 for solving this problem. This seems to be a good way of solving this kind of problems : http://www.eclipse.org/e4/resources/e4-whitepaper.php (Programming Model) http://www.vogella.de/articles/EclipseE4/article.html#programmingmodel http://www.eclipse.org/e4/resources/contexts.pdf
Note that from inside papyrus code, you should NEVER access the ServiceRegistry by using the notion of current editor. You are allowed to access the ServiceRegistry by looking for the current editor only in the case of a user interaction, i.e. from inside a command handlers. Please see comments from the following classes that provide methods to get the ServiceRegistry in different cases: - org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers - org.eclipse.papyrus.core.utils.ServiceUtils - org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
The access to the ServicesRegistry do not depends on the active editor. It has never depend on the active Editor. If you already have the ServicesRegistry, you can access it even if the currently selected editor is not Papyrus. However, if you want to find the ServicesRegistry, you need a kind of context from which you can search for it. - If you are in an ui handler, this certainly mean that you want the ServicesRegistry of the currently selected Editor. This can be done with the org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers. This utility class DEPENDS ON the active editor. - If you are in a nested editor, you should have a way to get the ServiceRegistry from this editor. Wiki pages explain how to get the ServiceRegistry from different contexts (http://wiki.eclipse.org/Papyrus_Developer_Guide/How_To_Code_Examples#How_to_get_the_ServiceRegistry)
Many different ServiceUtils* implementations are available now, which depend on a specific context element (e.g. EObject) instead of relying on the Active editor. I close this task