diff options
| author | Pierre-Charles David | 2015-01-27 16:22:00 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2015-04-15 07:58:34 +0000 |
| commit | 076925e0ca50be2f468de843307088a554cfe589 (patch) | |
| tree | 236a34651a904e3e886f27829e0c9d2ca1e64504 | |
| parent | 1825530c40ace1575cd1bd9247a09c519522bca9 (diff) | |
| download | org.eclipse.sirius-076925e0ca50be2f468de843307088a554cfe589.tar.gz org.eclipse.sirius-076925e0ca50be2f468de843307088a554cfe589.tar.xz org.eclipse.sirius-076925e0ca50be2f468de843307088a554cfe589.zip | |
[456352] Remove the DASI.disposeEditingDomainOnClose flag
Simply remove the flag and corresponding methods.
This required adapting a test that depended on Viewpoint instances still
being loaded after a session close/reopen cycle.
Bug: 456352
Change-Id: Ifb5e8f1cc8595f3047f501c5d117986d56ce9b72
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
7 files changed, 30 insertions, 54 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index d6f1b126d9..d40dd1e496 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -567,6 +567,11 @@ <code>warnings</code> member variable in the same way as the existing <code>errors</code> member variable. </li> + <li>The method + <code>org.eclipse.sirius.tests.support.api.SiriusTestCase.loadModeler(URI, EditingDomain)</code> has been added to load a VSM resource and make the + <code>Viewpoints</code> it defines accessible via the + <code>SiriusTestsCase.viewpoints</code> field. + </li> </ul> <ul> <li> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index f714ac4df6..82c5f8aa62 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -158,6 +158,7 @@ h4. Changes in @org.eclipse.sirius.tests.junit.support@ * The method @org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase.setReadOnly(IFile)@ has been deprecated, @org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper.setReadOnlyStatus(boolean, IResource...)@ can be used instead. * The @warnings@ member variable has been added to @org.eclipse.sirius.tests.support.api.SiriusTestCase@ to allow the recording of warning logs. Methods @doesAWarningOccurs()@, @clearWarnings()@, @setWarningCatchActive(boolean)@, @isWarningCatchActive()@ and @getWarningLoggersMessage()@ have also been added to manage the @warnings@ member variable in the same way as the existing @errors@ member variable. +* The method @org.eclipse.sirius.tests.support.api.SiriusTestCase.loadModeler(URI, EditingDomain)@ has been added to load a VSM resource and make the @Viewpoints@ it defines accessible via the @SiriusTestsCase.viewpoints@ field. * @org.eclipse.sirius.tests.support.api.ImageComposer@ has been added to the test API to do assertions on image decorators. diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_tabbar_extensions.html b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_tabbar_extensions.html index cbd8abe66a..4076b844b2 100644 --- a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_tabbar_extensions.html +++ b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_tabbar_extensions.html @@ -108,7 +108,7 @@ <em>activeEditorId</em> and the Sirius Diagram Editor id. </li> <li>it asks a property tester if the active editor should trigger the contribution visibility (see next section for the sample property tester explanation)</li> - <li>it iterates over the selection with a “OR” operator between elements and a false result for empty selection: + <li>it iterates over the selection with a «OR» operator between elements and a false result for empty selection: <ul> <li>it uses the Sirius predefined property tester to check that a selected element is a diagram element.</li> <li>it asks a property tester if the current element should trigger the contribution visibility (see next section for the sample property tester explanation)</li> diff --git a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/SiriusTestCase.java b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/SiriusTestCase.java index 3b552f20e6..b0c61ade40 100644 --- a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/SiriusTestCase.java +++ b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/SiriusTestCase.java @@ -514,7 +514,18 @@ public abstract class SiriusTestCase extends TestCase { } } - private void loadModeler(final URI modelerResourceURI, EditingDomain domain) throws Exception { + /** + * Load the VSM at the specified URI and registers all its Viewpoints in the + * testcase. + * + * @param modelerResourceURI + * the URI of the VSM. + * @param domain + * the editing domain into which the VSM should be loaded. + * @throws Exception + * if an error occurs while trying to load the VSM. + */ + protected void loadModeler(final URI modelerResourceURI, EditingDomain domain) throws Exception { Group group = null; try { group = (Group) ModelUtils.load(modelerResourceURI, domain.getResourceSet()); @@ -1128,7 +1139,7 @@ public abstract class SiriusTestCase extends TestCase { public Viewpoint getViewpointFromName(String viewpointName, Session sessionToUse) { Viewpoint localViewpoint = null; for (Viewpoint viewpoint : viewpoints) { - if (viewpoint.getName() != null && viewpoint.getName().equals(viewpointName)) { + if (viewpoint.eResource() != null && viewpoint.getName() != null && viewpoint.getName().equals(viewpointName)) { URI viewpointResourceURI = viewpoint.eResource().getURI(); Resource newViewpointResource = sessionToUse.getTransactionalEditingDomain().getResourceSet().getResource(viewpointResourceURI, true); if (!newViewpointResource.getContents().isEmpty() && newViewpointResource.getContents().get(0) instanceof Group) { diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/TablesAndEntitiesDirtyTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/TablesAndEntitiesDirtyTest.java index 6a77d2ceae..66a031bcab 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/TablesAndEntitiesDirtyTest.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/TablesAndEntitiesDirtyTest.java @@ -14,10 +14,10 @@ import java.util.Collection; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EPackage; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionStatus; -import org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl; import org.eclipse.sirius.business.internal.session.danalysis.SaveSessionJob; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.table.metamodel.table.DTable; @@ -67,7 +67,6 @@ public class TablesAndEntitiesDirtyTest extends SiriusDiagramTestCase implements @Override protected void tearDown() throws Exception { TestsUtil.synchronizationWithUIThread(); - super.tearDown(); } @@ -96,9 +95,9 @@ public class TablesAndEntitiesDirtyTest extends SiriusDiagramTestCase implements */ return; } - ((DAnalysisSessionImpl) session).setDisposeEditingDomainOnClose(false); assertsSessionIsSyncAndReload(session); + loadModeler(URI.createPlatformPluginURI(MODELER_PATH, true), session.getTransactionalEditingDomain()); rootEPackage = (EPackage) semanticModel; childEPackage = rootEPackage.getESubpackages().get(0); @@ -136,14 +135,12 @@ public class TablesAndEntitiesDirtyTest extends SiriusDiagramTestCase implements * @throws Exception */ public void testCreateAndOpenTableRepresentationInEditor() throws Exception { - if (TestsUtil.shouldSkipUnreliableTests()) { return; } - ((DAnalysisSessionImpl) session).setDisposeEditingDomainOnClose(false); - assertsSessionIsSyncAndReload(session); + loadModeler(URI.createPlatformPluginURI(MODELER_PATH, true), session.getTransactionalEditingDomain()); rootEPackage = (EPackage) semanticModel; childEPackage = rootEPackage.getESubpackages().get(0); @@ -292,11 +289,9 @@ public class TablesAndEntitiesDirtyTest extends SiriusDiagramTestCase implements * @throws Exception */ public void assertsSessionIsSyncAndReload(Session session) throws Exception { - assertEquals(SessionStatus.SYNC, session.getStatus()); closeAndReloadSession(); TestsUtil.synchronizationWithUIThread(); - assertEquals(SessionStatus.SYNC, session.getStatus()); } diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/benchmark/ProfiledCommandFactory.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/benchmark/ProfiledCommandFactory.java index a20d969eb9..e53a5d46a1 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/benchmark/ProfiledCommandFactory.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/benchmark/ProfiledCommandFactory.java @@ -151,9 +151,6 @@ public class ProfiledCommandFactory { } catch (CoreException e) { TestCase.fail("Problem during Session creation:" + e.getMessage()); } - if (session instanceof DAnalysisSessionImpl) { - ((DAnalysisSessionImpl) session).setDisposeEditingDomainOnClose(false); - } session.open(new NullProgressMonitor()); URI semanticResourceURI = model.eResource().getURI(); diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java index 4e855c668d..93688bd5c7 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java @@ -140,8 +140,6 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements private ReloadingPolicy reloadingPolicy; - private boolean disposeEditingDomainOnClose = true; - private IResourceCollector currentResourceCollector; private SessionVSMUpdater vsmUpdater = new SessionVSMUpdater(this); @@ -1145,33 +1143,6 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements // Session Configuration // ******************* - /** - * Configure this session so that when it is closed, it disposes the - * associated editing domain or not. Normally, each session has its own - * editing domain, which is disposed when the session is closed, but the - * historical behavior was to share the same editing domain for all session. - * Applications which have not been updated and still used shared editing - * domains should set this flag to <code>false</code> to avoid problems. - * - * @param disposeOnClose - * whether or not the editing domain used by this session should - * be disposed when the session is closed. - */ - public void setDisposeEditingDomainOnClose(boolean disposeOnClose) { - this.disposeEditingDomainOnClose = disposeOnClose; - } - - /** - * Tests whether this session will dispose its editing domain when it is - * closed. - * - * @return <code>true</code> if this session will dispose its editing domain - * when closed. - */ - public boolean getDisposeEditingDomainOnClose() { - return disposeEditingDomainOnClose; - } - @Override public void setAnalysisSelector(final DAnalysisSelector selector) { if (this.getServices() instanceof DAnalysisSessionService) { @@ -1341,12 +1312,10 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements flushOperations(transactionalEditingDomain); // Unload all referenced resources unloadAllResources(); - if (disposeEditingDomainOnClose) { - // To remove remaining resource like environment:/viewpoint - for (Resource resource : new ArrayList<Resource>(resourceSet.getResources())) { - resource.unload(); - resourceSet.getResources().remove(resource); - } + // To remove remaining resource like environment:/viewpoint + for (Resource resource : new ArrayList<Resource>(resourceSet.getResources())) { + resource.unload(); + resourceSet.getResources().remove(resource); } // Notify that the session is closed. notifyListeners(SessionListener.CLOSED); @@ -1358,11 +1327,9 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements crossReferencer = null; saver.dispose(); - if (disposeEditingDomainOnClose) { - transactionalEditingDomain.dispose(); - doDisposePermissionAuthority(resourceSet); - transactionalEditingDomain = null; - } + transactionalEditingDomain.dispose(); + doDisposePermissionAuthority(resourceSet); + transactionalEditingDomain = null; getActivatedViewpoints().clear(); services = null; sessionResource = null; |
