diff options
| author | Maxime Porhel | 2015-07-17 09:34:15 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-07-17 12:45:49 +0000 |
| commit | 02dea85d860f38c423da5b2b35f971736bd48d5b (patch) | |
| tree | c801bea335c9afa4c1aa414238362de1c8ac159b | |
| parent | 910260a82bf4173c857656d7a0920edbff06b833 (diff) | |
| download | org.eclipse.sirius-02dea85d860f38c423da5b2b35f971736bd48d5b.tar.gz org.eclipse.sirius-02dea85d860f38c423da5b2b35f971736bd48d5b.tar.xz org.eclipse.sirius-02dea85d860f38c423da5b2b35f971736bd48d5b.zip | |
[453037] Do not restore session
Call getSession(false) instead of getSession() in places where the
session is closed and we want to avoid to recreate and open a new
session. Typically in CustomSiriusDocumentProvider: the session has been
closed, the ui session tries to close all opened editor but check if the
editor is dirty: this checks ask to retrieve the session.
Bug: 453037
Change-Id: Ic5a04975f7bea17b69a47390fd89e9c3fc48b166
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
5 files changed, 18 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java index 086827b4ee..b0705ba0e0 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/resource/CustomSiriusDocumentProvider.java @@ -302,6 +302,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple * @see org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider#createInputWithEditingDomain(org.eclipse.ui.IEditorInput, * org.eclipse.emf.transaction.TransactionalEditingDomain) */ + @Override public IEditorInput createInputWithEditingDomain(final IEditorInput editorInput, final TransactionalEditingDomain domain) { return editorInput; } @@ -311,6 +312,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple * * @see org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider#getDiagramDocument(java.lang.Object) */ + @Override public IDiagramDocument getDiagramDocument(final Object element) { final IDocument doc = getDocument(element); if (doc instanceof IDiagramDocument) { @@ -341,7 +343,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple boolean isModifiable = true; if (element instanceof SessionEditorInput) { SessionEditorInput sessionEditorInput = (SessionEditorInput) element; - Session session = sessionEditorInput.getSession(); + Session session = sessionEditorInput.getSession(false); if (session != null) { ResourceSet resourceSet = session.getTransactionalEditingDomain().getResourceSet(); URI inputURI = sessionEditorInput.getURI(); @@ -375,7 +377,7 @@ public class CustomSiriusDocumentProvider extends AbstractDocumentProvider imple @Override public boolean canSaveDocument(final Object element) { if (element instanceof SessionEditorInput) { - Session session = ((SessionEditorInput) element).getSession(); + Session session = ((SessionEditorInput) element).getSession(false); return session != null && session.isOpen() && session.getStatus() == SessionStatus.DIRTY; } return super.canSaveDocument(element); diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 633370d2cc..9a3ea5c9b9 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -121,6 +121,11 @@ <code>org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getInput()</code> method has been added to get the real input for a <code>DRepresentation</code>. </li> + <li><span class="label label-success">Added</span> + <code>org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getSession(boolean)</code> method has been added to let the caller choose to create and open a new + <code>Session</code> or not when the known session is closed or does not exist. The + <code>getSession</code> method calls getSession(true). + </li> </ul> <h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support">Changes in <code>org.eclipse.sirius.tests.swtbot.support</code> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index 168e339bca..23e17afd84 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -31,6 +31,7 @@ h4. Changes in @org.eclipse.sirius.ui@ * <span class="label label-warning">Deprecated</span> @org.eclipse.sirius.ui.business.api.session.SessionEditorInput.dispose()@ method has been deprecated as a @IEditorInput@ can be reused by several instances of @IEditorPart@ through the navigation history view. * <span class="label label-success">Added</span> @org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getInput()@ method has been added to get the real input for a @DRepresentation@. +* <span class="label label-success">Added</span> @org.eclipse.sirius.ui.business.api.session.SessionEditorInput.getSession(boolean)@ method has been added to let the caller choose to create and open a new @Session@ or not when the known session is closed or does not exist. The @getSession@ method calls getSession(true). h4. Changes in @org.eclipse.sirius.tests.swtbot.support@ diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java index d366a72e33..0cffb00e14 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/api/session/SessionEditorInput.java @@ -100,13 +100,14 @@ public class SessionEditorInput extends URIEditorInput { } /** - * return the model editing session. + * Return the model editing session. * * @param restore - * true to restore the session if it is not instantiated + * true to restore the session if it is not instantiated or + * closed. * @return the model editing session. */ - private Session getSession(boolean restore) { + public Session getSession(boolean restore) { Session session = sessionRef != null ? sessionRef.get() : null; // Avoid to create a new session if the default editor name is used: we // do not known yet for which representation the input is, like diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SessionLinkHelper.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SessionLinkHelper.java index 84a0eed18b..de1d444676 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SessionLinkHelper.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/common/navigator/SessionLinkHelper.java @@ -52,6 +52,7 @@ public class SessionLinkHelper implements ILinkHelper { /** * {@inheritDoc} */ + @Override public IStructuredSelection findSelection(IEditorInput anInput) { Object foundElement = null; @@ -80,7 +81,8 @@ public class SessionLinkHelper implements ILinkHelper { if (anInput instanceof SessionEditorInput) { SessionEditorInput sessionInput = (SessionEditorInput) anInput; - if (sessionInput.getSession() != null && sessionInput.getSession().isOpen() && editor instanceof DialectEditor) { + Session session = sessionInput.getSession(false); + if (session != null && session.isOpen() && editor instanceof DialectEditor) { foundElement = ((DialectEditor) editor).getRepresentation(); } } @@ -90,6 +92,7 @@ public class SessionLinkHelper implements ILinkHelper { /** * {@inheritDoc} */ + @Override public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) { if (aPage == null || aSelection == null || aSelection.isEmpty()) return; |
