Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-12-19 12:03:33 +0000
committercletavernie2012-12-19 12:03:33 +0000
commit94b1a2e63c775254f9c2453a8a33186d2421b729 (patch)
tree8546534c7c80cc28385a3b76a7aad91997458ed3
parentd199d1d8d2f51fad5fca7a76d74a6577a58f4b25 (diff)
downloadorg.eclipse.papyrus-94b1a2e63c775254f9c2453a8a33186d2421b729.tar.gz
org.eclipse.papyrus-94b1a2e63c775254f9c2453a8a33186d2421b729.tar.xz
org.eclipse.papyrus-94b1a2e63c775254f9c2453a8a33186d2421b729.zip
396483: [Tests] Papyrus tests should be able to run on any Thread
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396483 382335: [Tests] Java Heap Space when running the tests https://bugs.eclipse.org/bugs/show_bug.cgi?id=382335
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java23
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java6
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java45
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java9
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java177
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java3
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java100
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForWorkbenchPage.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java7
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java15
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java118
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeDropEditPolicy.java16
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy.java17
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/EncapsulatedClassifierDropEditPolicy.java16
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/StructureClassifierDropEditPolicy.java16
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/TypedElementDropEditPolicy.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinAndParameterSynchronizer.java50
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/locators/CustomEntryExitPointPositionLocator.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java48
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java67
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java19
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java33
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/NavigatorUtils.java44
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java10
-rw-r--r--tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSClassProviderTest.java2
-rw-r--r--tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java30
-rw-r--r--tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.diff.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.file.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.core.queries.configuration.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.core.queries.test/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/wizard/TestNewModelWizardBase.java19
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.paletteconfiguration.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.di.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainerDisposeCalledTest.java146
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditor.java131
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditorTest.java144
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/customization/org.eclipse.papyrus.customization.properties.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java75
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java26
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java28
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java7
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java46
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java46
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/EditorUtils.java13
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/TestUtils.java70
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java38
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/EditorUtils.java21
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestPrepareUtils.java105
-rw-r--r--tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java71
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java77
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java15
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java29
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java15
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java17
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java9
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java14
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityAffixedChildNode.java12
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestCaseIntoStructureActivity.java10
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/src/org/eclipse/papyrus/uml/diagram/dnd/tests/tests/InstanceSpecificationTest.java43
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestSpecificTopNode.java16
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestUseCaseLinkOwnedBySource.java23
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF5
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java70
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java115
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java8
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java51
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java30
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.common.tests/META-INF/MANIFEST.MF1
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AbstractPapyrusTestCase.java68
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java61
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/ContentProviderTest.java4
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/.settings/org.eclipse.jdt.ui.prefs54
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java218
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/DeleteHandlerTest.java54
-rw-r--r--tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/ModelExplorerViewTests.java36
107 files changed, 1944 insertions, 1074 deletions
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
index 6b2ad9b0134..69ba1aaf25a 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@ Bundle-SymbolicName: org.eclipse.papyrus.infra.core.serviceregistry.tests;single
Bundle-Version: 0.10.0.qualifier
Fragment-Host: org.eclipse.papyrus.infra.core.serviceregistry;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.junit,
+Require-Bundle: org.junit4,
org.eclipse.emf.ecore.xmi
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
index 203c98eeada..57da21f6e28 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF
@@ -4,8 +4,7 @@ Export-Package: org.eclipse.papyrus.infra.core.sasheditor,
org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple,
org.eclipse.papyrus.infra.core.sasheditor.editor,
org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor,
- org.eclipse.papyrus.infra.core.sasheditor.editor.gef,
- org.eclipse.papyrus.infra.core.sasheditor.multipage.editor
+ org.eclipse.papyrus.infra.core.sasheditor.editor.gef
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Name: %pluginName
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
index 387e64281dd..8329d3bea13 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
@@ -22,7 +22,6 @@ import org.eclipse.papyrus.infra.core.sasheditor.internal.IMultiEditorManager;
import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -149,6 +148,7 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
protected void deactivate() {
tabsSynchronizer.dispose();
+ tabsSynchronizer = null;
}
/**
@@ -160,6 +160,13 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
@Override
public void dispose() {
deactivate();
+ //The selection provider keeps a reference to "this". It is not disposed.
+ getSite().setSelectionProvider(null);
+ sashContainer.dispose();
+ sashContainer = null;
+
+ pageProvider = null;
+
super.dispose();
}
@@ -196,8 +203,8 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
// Look in hierarchy
Object result = super.getAdapter(adapter);
- // restrict delegating to the UI thread for bug 144851
- if(result == null && Display.getCurrent() != null) {
+
+ if(result == null) {
IEditorPart innerEditor = getActiveEditor();
// see bug 138823 - prevent some subclasses from causing
// an infinite loop
@@ -212,14 +219,15 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
* Needed by MultiPageActionBarContributor and MultiPageSelectionProvider.
*/
public IEditorPart getActiveEditor() {
- if( sashContainer.isDisposed())
+ if(sashContainer.isDisposed()) {
return null;
-
+ }
+
return sashContainer.getActiveEditor();
}
/**
- * Get the {@link ISashWindowsContainer}.
+ * Get the {@link ISashWindowsContainer}.
* Note the the ISashWindowsContainer can also be acuired with getAdapter(ISashWindowsContainer.class).
*/
public ISashWindowsContainer getISashWindowsContainer() {
@@ -247,6 +255,7 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
* @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#isDirty()
* @deprecated A SaveAndDirtyService is used instead.
*/
+ @Deprecated
@Override
public boolean isDirty() {
// return sashContainer.isDirty();
@@ -268,8 +277,10 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
*
* TODO Move this method aways. This method is too tightly coupled to the Papyrus GMF UML IEditor.
* It doesn't work on other kind of IEditor. It introduce problems in IEditor of other kinds
+ *
* @deprecated A SaveAndDirtyService is used instead.
*/
+ @Deprecated
protected void markSaveLocation() {
// return sashContainer.isDirty();
EditorVisitor visitor = new EditorVisitor();
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java
index a213d0e8b05..3b30efacfa5 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java
@@ -114,6 +114,12 @@ public class ComposedActionBarContributor extends MultiPageEditorActionBarContri
// if(activeContributor!=this)
// activeContributor.setActiveEditor(part);
}
+
+ @Override
+ public void dispose(){
+ super.dispose();
+ activeNestedEditor = null;
+ }
/**
* Get the active nested contributor, if any.
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
index 7acb102e21b..8362573473a 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
@@ -219,6 +219,29 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
return mainEditorSite;
}
+ private static class PapyrusContextFunction extends ContextFunction {
+
+ private MultiPageEditorSite editorSite;
+
+ public PapyrusContextFunction(MultiPageEditorSite multiPageEditorSite4x) {
+ this.editorSite = multiPageEditorSite4x;
+ }
+
+ @Override
+ public Object compute(IEclipseContext ctxt) {
+ if(editorSite.contextService == null) {
+ editorSite.contextService = new NestableContextService(ctxt.getParent().get(IContextService.class), new ActivePartExpression(editorSite.mainEditorSite.getPart()));
+ }
+ return editorSite.contextService;
+ }
+
+ public void dispose() {
+ this.editorSite = null;
+ }
+ }
+
+ private PapyrusContextFunction contextFunction;
+
/**
* Initialize the slave services for this site.
*/
@@ -232,17 +255,9 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
// }
// });
+ contextFunction = new PapyrusContextFunction(this);
- context.set(IContextService.class.getName(), new ContextFunction() {
-
- @Override
- public Object compute(IEclipseContext ctxt) {
- if(contextService == null) {
- contextService = new NestableContextService(ctxt.getParent().get(IContextService.class), new ActivePartExpression(mainEditorSite.getPart()));
- }
- return contextService;
- }
- });
+ context.set(IContextService.class.getName(), contextFunction);
// create a local handler service so that when this page
// activates/deactivates, its handlers will also be taken into/out of
@@ -313,17 +328,23 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
if(contextService != null) {
contextService.dispose();
+ contextService = null;
}
if(serviceLocator != null) {
serviceLocator.dispose();
}
+ context.remove(IContextService.class.getName());
context.dispose();
+ contextFunction.dispose();
+ contextFunction = null;
+
// dispose properties to help GC
setSelectionProvider(null);
mainEditorSite = null;
editor = null;
+
actionBarContributor = null;
}
@@ -621,14 +642,14 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
if(menuExtenders == null) {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, context, menuExtenders);
+ PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, menuExtenders);
}
public final void registerContextMenu(final String menuId, final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) {
if(menuExtenders == null) {
menuExtenders = new ArrayList(1);
}
- PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput, editor, context, menuExtenders);
+ PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput, editor, menuExtenders);
}
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java
index bce9ed01a88..3fbcc4ef9d1 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java
@@ -91,13 +91,15 @@ public class ContentOutlineRegistry {
// look for the one with the highest priority
for(IConfigurationElement ele : configElements) {
ContentOutlineDescriptor desc = new ContentOutlineDescriptor(ele);
- if(desc.isHigher(found))
+ if(desc.isHigher(found)) {
found = desc;
+ }
}
// Instanciate the object
- if(found == null)
+ if(found == null) {
throw new NotFoundException("No ContentOutline registered.");
+ }
return found;
@@ -154,8 +156,9 @@ public class ContentOutlineRegistry {
this.element = element;
// check parameters
- if(className == null)
+ if(className == null) {
throw new BadClassNameException("Class name must be set", "contentoutline", classAttributeName);
+ }
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
index e1ef11dea66..3cb759ea258 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
@@ -79,16 +79,19 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributo
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
/**
- * Multi diagram editor allowing to plug various kind of editors. Editors are registered with the help of the Eclipse extension mechanism. This
- * implementation allows to register editors and context
- * separately. An editor should specify which context it need to run. This multi diagram editor allows to show editor side by side in one or more sash
- * windows.
+ * Multi diagram editor allowing to plug various kind of editors. Editors are
+ * registered with the help of the Eclipse extension mechanism. This
+ * implementation allows to register editors and context separately. An editor
+ * should specify which context it need to run. This multi diagram editor allows
+ * to show editor side by side in one or more sash windows.
*
- * The real implementation for the generic type T of SashMultiPageEditorPart is actually di2.Diagram
+ * The real implementation for the generic type T of SashMultiPageEditorPart is
+ * actually di2.Diagram
*
* @author cedric dumoulin
* @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
- * @author <a href="mailto:thomas.szadel@atosorigin.com">Thomas Szadel</a> Refactoring.
+ * @author <a href="mailto:thomas.szadel@atosorigin.com">Thomas Szadel</a>
+ * Refactoring.
*
* TODO : remove GMF dependency !
*/
@@ -104,7 +107,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
private ServicesRegistry servicesRegistry;
/**
- * ActionBarContributor Registry. Allows to get an ActionBar by its Id. The registry is initialized from the Eclipse extension mechanism.
+ * ActionBarContributor Registry. Allows to get an ActionBar by its Id. The
+ * registry is initialized from the Eclipse extension mechanism.
*/
private ActionBarContributorRegistry actionBarContributorRegistry;
@@ -119,10 +123,17 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
/**
* Listener on {@link ISaveAndDirtyService#addInputChangedListener(IEditorInputChangedListener)}
*/
- protected IEditorInputChangedListener editorInputChangedListener = new IEditorInputChangedListener() {
+ private static class EditorInputChangedListener implements IEditorInputChangedListener {
+
+ private CoreMultiDiagramEditor editor;
+
+ public EditorInputChangedListener(CoreMultiDiagramEditor editor) {
+ this.editor = editor;
+ }
/**
- * This method is called when the editor input is changed from the ISaveAndDirtyService.
+ * This method is called when the editor input is changed from the
+ * ISaveAndDirtyService.
*
* @see org.eclipse.papyrus.infra.core.lifecycleevents.IEditorInputChangedListener#editorInputChanged(org.eclipse.ui.part.FileEditorInput)
*
@@ -130,8 +141,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
*/
public void editorInputChanged(FileEditorInput fileEditorInput) {
// Change the editor input.
- setInputWithNotify(fileEditorInput);
- setPartName(fileEditorInput.getName());
+ editor.setInputWithNotify(fileEditorInput);
+ editor.setPartName(fileEditorInput.getName());
}
/**
@@ -143,14 +154,20 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
public void isDirtyChanged() {
// Run it in async way.
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ editor.getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
- firePropertyChange(IEditorPart.PROP_DIRTY);
+ editor.firePropertyChange(IEditorPart.PROP_DIRTY);
}
});
}
- };
+
+ public void dispose() {
+ this.editor = null;
+ }
+ }
+
+ protected EditorInputChangedListener editorInputChangedListener = new EditorInputChangedListener(this);
private TransactionalEditingDomain transactionalEditingDomain;
@@ -169,33 +186,58 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
*/
private TabbedPropertySheetPage tabbedPropertySheetPage = null;
- /**
- * My editing domain provider.
- */
- private IEditingDomainProvider domainProvider = new IEditingDomainProvider() {
+ private static class EditingDomainProvider implements IEditingDomainProvider {
+
+ private CoreMultiDiagramEditor editor;
+
+ public EditingDomainProvider(CoreMultiDiagramEditor editor) {
+ this.editor = editor;
+ }
public EditingDomain getEditingDomain() {
- return transactionalEditingDomain;
+ return editor.transactionalEditingDomain;
+ }
+
+ public void dispose() {
+ this.editor = null;
}
- };
+ }
/**
- * A listener on model change events.
+ * My editing domain provider.
*/
- private IContentChangedListener contentChangedListener = new IContentChangedListener() {
+ private EditingDomainProvider domainProvider = new EditingDomainProvider(this);
+
+ private static class ContentChangedListener implements IContentChangedListener {
+
+ private CoreMultiDiagramEditor editor;
+
+ public ContentChangedListener(CoreMultiDiagramEditor editor) {
+ this.editor = editor;
+ }
/**
* Called when the content is changed. RefreshTabs.
*/
public void contentChanged(ContentEvent event) {
- refreshTabs();
+ editor.refreshTabs();
}
- };
+
+ public void dispose() {
+ this.editor = null;
+ }
+ }
/**
- * Undo context used to have the same undo context in all Papyrus related views and editors.
- * TODO : move away, use a version independent of GMF, add a listener that will add
- * the context to all commands modifying attached Resources (==> linked to ModelSet ?)
+ * A listener on model change events.
+ */
+ private ContentChangedListener contentChangedListener = new ContentChangedListener(this);
+
+ /**
+ * Undo context used to have the same undo context in all Papyrus related
+ * views and editors. TODO : move away, use a version independent of GMF,
+ * add a listener that will add the context to all commands modifying
+ * attached Resources (==> linked to ModelSet ?)
*/
private IUndoContext undoContext;
@@ -240,7 +282,7 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// Create Services Registry
try {
ServicesRegistry servicesRegistry = new ExtensionServicesRegistry(Activator.PLUGIN_ID);
- // servicesRegistry.startRegistry();
+ // servicesRegistry.startRegistry();
return servicesRegistry;
} catch (ServiceException e) {
// Show log and error
@@ -277,9 +319,9 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
/**
- * Get The {@link IPageMngr} used to add, open, remove or close a diagram in the
- * SashWindow.
- * This method is available as soon as the {@link CoreMultiDiagramEditor#init(IEditorSite, IEditorInput)} method is called.
+ * Get The {@link IPageMngr} used to add, open, remove or close a diagram in
+ * the SashWindow. This method is available as soon as the {@link CoreMultiDiagramEditor#init(IEditorSite, IEditorInput)} method is
+ * called.
*
* @return
*/
@@ -346,7 +388,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
if(IPropertySheetPage.class == adapter) {
// Do not test if tabbedPropertySheetPage is null before calling new
- // this is managed by Eclipse which only call current method when necessary
+ // this is managed by Eclipse which only call current method when
+ // necessary
return getPropertySheetPage();
}
@@ -368,10 +411,9 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
/*
- * Return context used for undo/redo.
- * All papyrus views should use this context.
- * The prefer way to get this is to use
- * undoContext = servicesRegistry.getService(IUndoContext.class);
+ * Return context used for undo/redo. All papyrus views should use this
+ * context. The prefer way to get this is to use undoContext =
+ * servicesRegistry.getService(IUndoContext.class);
*/
if(IUndoContext.class == adapter) {
return undoContext;
@@ -380,7 +422,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// EMF requirements
if(IEditingDomainProvider.class == adapter) {
- // return (IEditingDomainProvider) defaultContext.getTransactionalEditingDomain().getResourceSet();
+ // return (IEditingDomainProvider)
+ // defaultContext.getTransactionalEditingDomain().getResourceSet();
return domainProvider;
}
@@ -483,7 +526,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
ILabelProvider labelProvider = new AdapterFactoryLabelProvider(factory) {
/**
- * This implements {@link ILabelProvider}.getText by forwarding it to an object that implements {@link IItemLabelProvider#getText
+ * This implements {@link ILabelProvider}.getText by forwarding it
+ * to an object that implements {@link IItemLabelProvider#getText
* IItemLabelProvider.getText}
*/
@Override
@@ -516,16 +560,17 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
servicesRegistry.startRegistry();
} catch (ModelMultiException e) {
try {
- // with the ModelMultiException it is still possible to open the editors that's why the service registry is still started
+ // with the ModelMultiException it is still possible to open the
+ // editors that's why the service registry is still started
servicesRegistry.startRegistry();
warnUser(e);
} catch (ServiceException e1) {
log.error(e);
- throw new PartInitException("could not initialize services", e); //$NON-NLS-1$
+ //throw new PartInitException("could not initialize services", e); //$NON-NLS-1$
}
} catch (ServiceException e) {
log.error(e);
- throw new PartInitException("could not initialize services", e);
+ //throw new PartInitException("could not initialize services", e);
}
@@ -539,7 +584,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
undoContext = servicesRegistry.getService(IUndoContext.class);
} catch (ServiceException e) {
log.error("A required service is missing.", e);
- // if one of the services above fail to start, the editor can't run => stop
+ // if one of the services above fail to start, the editor can't run
+ // => stop
throw new PartInitException("could not initialize services", e);
}
@@ -579,11 +625,11 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
}
-
/**
- * Init the contextual menu shown in the folder tabs.
- * This popup menu is contributed by the help of Eclipse extensions, using the Commands framework.
- * I.e, to add a menu item, create a menu, a command and an handler in the extension.
+ * Init the contextual menu shown in the folder tabs. This popup menu is
+ * contributed by the help of Eclipse extensions, using the Commands
+ * framework. I.e, to add a menu item, create a menu, a command and an
+ * handler in the extension.
*/
protected void initFolderTabMenus() {
ISashWindowsContainer container = getISashWindowsContainer();
@@ -626,19 +672,52 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// Avoid memory leak
// This call is done from the ServicesRegistry when it is disposed.
// Don't need to do it there.
- // if(resourceSet != null) {
- // resourceSet.unload();
- // }
+ // if(resourceSet != null) {
+ // resourceSet.unload();
+ // }
// dispose available service
if(servicesRegistry != null) {
try {
servicesRegistry.disposeRegistry();
+ servicesRegistry = null;
} catch (ServiceMultiException e) {
log.error(e);
}
}
+ if(domainProvider != null) {
+ this.domainProvider.dispose();
+ this.domainProvider = null;
+ }
+
+ if(contentChangedListener != null) {
+ this.contentChangedListener.dispose();
+ this.contentChangedListener = null;
+ }
+
+ if(editorInputChangedListener != null) {
+ this.editorInputChangedListener.dispose();
+ this.editorInputChangedListener = null;
+ }
+
+ if(gefAdaptorDelegate != null) {
+ gefAdaptorDelegate.dispose();
+ gefAdaptorDelegate = null;
+ }
+
+ contentOutlineRegistry = null;
+ transactionalEditingDomain = null;
+ resourceSet = null;
+ undoContext = null;
+ saveAndDirtyService = null;
+ sashModelMngr = null;
+
+ if(tabbedPropertySheetPage != null) {
+ tabbedPropertySheetPage.dispose();
+ tabbedPropertySheetPage = null;
+ }
+
super.dispose();
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
index ee657dec743..aaf3e486b45 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
@@ -494,9 +494,9 @@ public class ModelSet extends ResourceSetImpl {
* Unload all the resources. Do not disguard associated models.
*/
public void unload() {
-
// call snippets to allow them to do their stuff
snippets.performDispose(this);
+ snippets.clear();
// Walk all registered models
for(IModel model : models.values()) {
@@ -515,6 +515,7 @@ public class ModelSet extends ResourceSetImpl {
// Dispose Editing Domain
if(transactionalEditingDomain != null) {
transactionalEditingDomain.dispose();
+ transactionalEditingDomain = null;
}
// Detach associated factories
if(adapterFactories != null) {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
index d281bf26609..478d7338535 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
@@ -120,9 +120,9 @@ public class ServicesRegistry {
// Check if the service already exist.
ServiceStartupEntry service = addedServices.get(serviceDescriptor.getKey());
if(service != null) {
- if(service.getDescriptor().getPriority() > serviceDescriptor.getPriority())
+ if(service.getDescriptor().getPriority() > serviceDescriptor.getPriority()) {
return;
- else if(service.getDescriptor().getPriority() == serviceDescriptor.getPriority()) {
+ } else if(service.getDescriptor().getPriority() == serviceDescriptor.getPriority()) {
log.warning("Two services with same priority (" + serviceDescriptor.getPriority() + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only. (bundles: " + service.getDescriptor().getClassBundleID() + ", " + serviceDescriptor.getClassBundleID() + ")");
}
}
@@ -130,12 +130,13 @@ public class ServicesRegistry {
// Compute the service type entry
ServiceTypeEntry serviceTypeEntry;
ServiceTypeKind typeKind = serviceDescriptor.getServiceTypeKind();
- if(typeKind == ServiceTypeKind.service)
+ if(typeKind == ServiceTypeKind.service) {
serviceTypeEntry = new ServiceEntry(serviceDescriptor);
- else if(typeKind == ServiceTypeKind.serviceFactory)
+ } else if(typeKind == ServiceTypeKind.serviceFactory) {
serviceTypeEntry = new ServiceFactoryEntry(serviceDescriptor);
- else
+ } else {
serviceTypeEntry = new PojoServiceEntry(serviceDescriptor);
+ }
// Create the entry
ServiceStartupEntry serviceEntry;
@@ -190,19 +191,21 @@ public class ServicesRegistry {
// Check if the service already exist.
ServiceStartupEntry service = addedServices.get(key);
if(service != null) {
- if(service.getDescriptor().getPriority() > priority)
+ if(service.getDescriptor().getPriority() > priority) {
return;
- else if(service.getDescriptor().getPriority() == priority)
+ } else if(service.getDescriptor().getPriority() == priority) {
log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only.");
+ }
}
// Create descriptor and add service.
ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority);
- if(startKind == ServiceStartKind.STARTUP)
+ if(startKind == ServiceStartKind.STARTUP) {
addedServices.put(key, new StartStartupEntry(new ServiceEntry(descriptor, serviceInstance)));
- else
+ } else {
addedServices.put(key, new LazyStartupEntry(new ServiceEntry(descriptor, serviceInstance), this));
+ }
}
/**
@@ -254,19 +257,21 @@ public class ServicesRegistry {
// Check if the service already exist.
ServiceStartupEntry service = addedServices.get(key);
if(service != null) {
- if(service.getDescriptor().getPriority() > priority)
+ if(service.getDescriptor().getPriority() > priority) {
return;
- else if(service.getDescriptor().getPriority() == priority)
+ } else if(service.getDescriptor().getPriority() == priority) {
log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only.");
+ }
}
// Create descriptor and add service.
ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority);
- if(startKind == ServiceStartKind.STARTUP)
+ if(startKind == ServiceStartKind.STARTUP) {
addedServices.put(key, new StartStartupEntry(new PojoServiceEntry(descriptor, serviceInstance)));
- else
+ } else {
addedServices.put(key, new LazyStartupEntry(new PojoServiceEntry(descriptor, serviceInstance), this));
+ }
}
@@ -328,10 +333,11 @@ public class ServicesRegistry {
// throw an exception.
// If added, say it.
service = addedServices.get(key);
- if(service != null)
+ if(service != null) {
throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor());
- else
+ } else {
throw new ServiceNotFoundException("No service registered under '" + key + "'");
+ }
}
return service.getServiceInstance();
@@ -357,10 +363,11 @@ public class ServicesRegistry {
// throw an exception.
// If added, say it.
service = addedServices.get(realKey);
- if(service != null)
+ if(service != null) {
throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor());
- else
+ } else {
throw new ServiceNotFoundException("No service registered under '" + key + "'");
+ }
}
return (S)service.getServiceInstance();
@@ -406,12 +413,20 @@ public class ServicesRegistry {
* If a service can't be started.
*/
public void startRegistry() throws ServiceMultiException {
+ // Create an object to collect errors if any.
+ ServiceMultiException errors = new ServiceMultiException();
// Build the lookup maps
LookupMap map = new LookupMap(addedServices, namedServices);
// Check if all dependencies exist.
- checkDependencies(addedServices.values(), map);
+ try {
+ checkDependencies(addedServices.values(), map);
+ } catch (ServiceMultiException ex) {
+ for(Throwable t : ex.getExceptions()) {
+ errors.addException(t);
+ }
+ }
// Get all roots : LAZY and START
Collection<ServiceStartupEntry> roots = getServiceRoots(addedServices.values(), map);
@@ -427,9 +442,6 @@ public class ServicesRegistry {
showServices(" Services to start:", toStart);
}
- // Create an object to collect errors if any.
- ServiceMultiException errors = new ServiceMultiException();
-
createServices(toStart, errors);
// Register all new services : lazy and start
registerServices(addedServices.values());
@@ -437,8 +449,9 @@ public class ServicesRegistry {
startServices(toStart, errors);
// Report errors if any
- if(errors.getExceptions().size() > 0)
+ if(errors.getExceptions().size() > 0) {
throw errors;
+ }
}
@@ -558,8 +571,17 @@ public class ServicesRegistry {
* If a service can't be started.
*/
private void startServices(List<ServiceStartupEntry> services, LookupMap map) throws ServiceMultiException {
+ // Create an object to collect errors if any.
+ ServiceMultiException errors = new ServiceMultiException();
+
// Check if all dependencies exist.
- checkDependencies(services, map);
+ try {
+ checkDependencies(addedServices.values(), map);
+ } catch (ServiceMultiException ex) {
+ for(Throwable t : ex.getExceptions()) {
+ errors.addException(t);
+ }
+ }
// Get all roots : LAZY and START
Collection<ServiceStartupEntry> roots = getServiceRoots(services, map);
@@ -582,9 +604,6 @@ public class ServicesRegistry {
showServices(" Services to start:", toStart);
// }
- // Create an object to collect errors if any.
- ServiceMultiException errors = new ServiceMultiException();
-
createServices(toStart, errors);
// Register all started services
registerServices(toStart);
@@ -592,8 +611,9 @@ public class ServicesRegistry {
startServices(toStart, errors);
// Report errors if any
- if(errors.getExceptions().size() > 0)
+ if(errors.getExceptions().size() > 0) {
throw errors;
+ }
}
/**
@@ -684,8 +704,9 @@ public class ServicesRegistry {
}
// Throw errors if any
- if(errors.getExceptions().size() > 0)
+ if(errors.getExceptions().size() > 0) {
throw errors;
+ }
}
/**
@@ -756,8 +777,9 @@ public class ServicesRegistry {
private void walkGraphDepthFirst(List<ServiceStartupEntry> result, ServiceStartupEntry node, LookupMap map) {
// Do not add already added or started node.
- if(result.contains(node) || node.isStarted())
+ if(result.contains(node) || node.isStarted()) {
return;
+ }
// add direct child
for(String serviceKey : node.getDescriptor().getRequiredServiceKeys()) {
@@ -834,10 +856,11 @@ public class ServicesRegistry {
anonymousServices = null;
namedServices.clear();
namedServices = null;
-
+
// Report errors if any
- if(errors.getExceptions().size() > 0)
+ if(errors.getExceptions().size() > 0) {
throw errors;
+ }
}
/**
@@ -1018,10 +1041,12 @@ public class ServicesRegistry {
public ServiceStartupEntry get(String key) {
ServiceStartupEntry res = map1.get(key);
- if(res != null)
+ if(res != null) {
return res;
- if(map2 != null)
+ }
+ if(map2 != null) {
res = map2.get(key);
+ }
return res;
}
@@ -1037,12 +1062,15 @@ public class ServicesRegistry {
public ServiceStartupEntry getChecked(String key) throws ServiceNotFoundException {
ServiceStartupEntry res = map1.get(key);
- if(res != null)
+ if(res != null) {
return res;
- if(map2 != null)
+ }
+ if(map2 != null) {
res = map2.get(key);
- if(res != null)
+ }
+ if(res != null) {
return res;
+ }
throw new ServiceNotFoundException("No service found under key '" + key.toString() + "'");
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForWorkbenchPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForWorkbenchPage.java
index c876d517f32..540ebd90678 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForWorkbenchPage.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForWorkbenchPage.java
@@ -33,7 +33,7 @@ public class ServiceUtilsForWorkbenchPage extends AbstractServiceUtils<IWorkbenc
}
}
- throw new ServiceException("Cannot resolve the ServiceRegistry from the IWorkbenchPage");
+ throw new ServiceException("Cannot resolve the ServiceRegistry from the IWorkbenchPage. Page: " + from);
}
public static ServiceUtilsForWorkbenchPage getInstance() {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
index 47e6b9af11b..898c34feecf 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
@@ -30,4 +30,11 @@ public class PapyrusROTransactionalEditingDomain extends TransactionalEditingDom
public boolean isReadOnly(Resource resource) {
return ReadOnlyManager.isReadOnly(resource, this);
}
+
+ @Override
+ public void dispose(){
+ super.dispose();
+ resourceSet = null;
+ adapterFactory = null;
+ }
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java
index ffbc16063f6..e3f0ea8a69b 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngineImpl.java
@@ -31,7 +31,6 @@ import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter;
import org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine;
import org.eclipse.e4.ui.css.core.impl.sac.CSSConditionFactoryImpl;
import org.eclipse.e4.ui.css.core.impl.sac.CSSSelectorFactoryImpl;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.converters.BooleanConverter;
import org.eclipse.papyrus.infra.gmfdiag.css.converters.ColorToGMFConverter;
import org.eclipse.papyrus.infra.gmfdiag.css.converters.IntegerConverter;
@@ -42,7 +41,6 @@ import org.eclipse.papyrus.infra.gmfdiag.css.lists.ExtendedStyleSheetList;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.EmbeddedStyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference;
-import org.eclipse.swt.widgets.Display;
import org.w3c.css.sac.ConditionFactory;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSStyleDeclaration;
@@ -350,12 +348,15 @@ public abstract class ExtendedCSSEngineImpl extends AbstractCSSEngine implements
*/
public void notifyChange(Element elementAdapter) {
resetCache(); //TODO: We should only refresh a subset of the cache
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- DiagramHelper.refreshDiagrams(); //TODO: Contextual refresh
- }
- });
+ //FIXME: It seems the refresh can create a deadlock in some cases
+
+ // Display.getCurrent().asyncExec(new Runnable() {
+ //
+ // public void run() {
+ // DiagramHelper.refreshDiagrams(); //TODO: Contextual refresh
+ // }
+ // });
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
index ef0c70d9bb0..a9b1798347c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramOutline.java
@@ -22,6 +22,7 @@ import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gmf.runtime.diagram.ui.render.editparts.RenderedDiagramRootEditPart;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
@@ -57,6 +58,48 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
//See #refresh()
public class DiagramOutline extends Page implements IPapyrusContentOutlinePage, ISelectionListener {
+ private final class ShowAllAction extends Action {
+
+ private ShowAllAction(String text, int style) {
+ super(text, style);
+ }
+
+ @Override
+ public void run() {
+ if(sashComp != null && !sashComp.isDisposed()) {
+ performShowAction();
+ }
+ }
+ }
+
+ private final class ShowOverviewAction extends Action {
+
+ private ShowOverviewAction(String text, int style) {
+ super(text, style);
+ }
+
+ @Override
+ public void run() {
+ if(overview != null && !overview.isDisposed()) {
+ performShowAction();
+ }
+ }
+ }
+
+ private final class ShowTreeAction extends Action {
+
+ private ShowTreeAction(String text, int style) {
+ super(text, style);
+ }
+
+ @Override
+ public void run() {
+ if(navigator != null && !navigator.isDisposed()) {
+ performShowAction();
+ }
+ }
+ }
+
protected EditingDomain editingDomain;
private IMultiDiagramEditor multiEditor;
@@ -80,11 +123,11 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
private Composite overview;
/** Actions */
- private IAction showTreeAction;
+ private ActionContributionItem showTreeItem;
- private IAction showOverviewAction;
+ private ActionContributionItem showOverviewItem;
- private IAction showAllAction;
+ private ActionContributionItem showAllItem;
public DiagramOutline() {
super();
@@ -173,48 +216,26 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
* the outline tool bar manager
*/
private void createShowOutlineActions(IToolBarManager tbm) {
-
// Show Tree action
- showTreeAction = new Action(Messages.DiagramOutline_ShowNavigator, IAction.AS_RADIO_BUTTON) {
-
- @Override
- public void run() {
- if(navigator != null && !navigator.isDisposed()) {
- performShowAction();
- }
- }
- };
+ IAction showTreeAction = new ShowTreeAction(Messages.DiagramOutline_ShowNavigator, IAction.AS_RADIO_BUTTON);
showTreeAction.setToolTipText(showTreeAction.getText());
showTreeAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/tree_co.gif")); //$NON-NLS-1$
- tbm.add(showTreeAction);
+ showTreeItem = new ActionContributionItem(showTreeAction);
+ tbm.add(showTreeItem);
// Show overview action
- showOverviewAction = new Action(Messages.DiagramOutline_ShowOverview, IAction.AS_RADIO_BUTTON) {
-
- @Override
- public void run() {
- if(overview != null && !overview.isDisposed()) {
- performShowAction();
- }
- }
- };
+ IAction showOverviewAction = new ShowOverviewAction(Messages.DiagramOutline_ShowOverview, IAction.AS_RADIO_BUTTON);
showOverviewAction.setToolTipText(showOverviewAction.getText());
showOverviewAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/overview_co.gif")); //$NON-NLS-1$
- tbm.add(showOverviewAction);
+ showOverviewItem = new ActionContributionItem(showOverviewAction);
+ tbm.add(showOverviewItem);
// Show All (Tree and Overview) action
- showAllAction = new Action(Messages.DiagramOutline_ShowBoth, IAction.AS_RADIO_BUTTON) {
-
- @Override
- public void run() {
- if(sashComp != null && !sashComp.isDisposed()) {
- performShowAction();
- }
- }
- };
+ IAction showAllAction = new ShowAllAction(Messages.DiagramOutline_ShowBoth, IAction.AS_RADIO_BUTTON);
showAllAction.setToolTipText(showAllAction.getText());
showAllAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/elcl16/all_co.gif")); //$NON-NLS-1$
- tbm.add(showAllAction);
+ showAllItem = new ActionContributionItem(showAllAction);
+ tbm.add(showAllItem);
// Set overview as default choice
showOverviewAction.setChecked(true);
@@ -261,15 +282,38 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
// Navigator, overview... can be null
if(navigator != null) {
navigator.dispose();
+ navigator = null;
}
if(overview != null) {
overview.dispose();
+ overview = null;
}
if(multiEditor != null) {
// Remove selection change listener
multiEditor.getSite().getPage().removePostSelectionListener(this);
+ multiEditor = null;
+ }
+
+ IToolBarManager toolBarManager = getSite().getActionBars().getToolBarManager();
+ if(showTreeItem != null) {
+ showTreeItem.dispose();
+ showTreeItem = null;
+ }
+
+ if(showOverviewItem != null) {
+ showOverviewItem.dispose();
+ showOverviewItem = null;
}
+
+ if(showAllItem != null) {
+ showAllItem.dispose();
+ showAllItem = null;
+ }
+
+ toolBarManager.update(false);
+
+ getSite().setSelectionProvider(null);
}
/**
@@ -395,13 +439,13 @@ public class DiagramOutline extends Page implements IPapyrusContentOutlinePage,
private int getShowActionMode() {
int showActionMode = -1;
- if(showTreeAction.isChecked()) {
+ if(showTreeItem.getAction().isChecked()) {
showActionMode = SHOW_TREE;
}
- if(showOverviewAction.isChecked()) {
+ if(showOverviewItem.getAction().isChecked()) {
showActionMode = SHOW_OVERVIEW;
}
- if(showAllAction.isChecked()) {
+ if(showAllItem.getAction().isChecked()) {
showActionMode = SHOW_BOTH;
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeDropEditPolicy.java
index f62af154697..5c2ad50852d 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyCompositeDropEditPolicy.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -31,6 +32,7 @@ import org.eclipse.papyrus.sysml.diagram.internalblock.utils.PortDropHelper;
import org.eclipse.papyrus.sysml.diagram.internalblock.utils.TypeDropHelper;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Port;
@@ -85,7 +87,7 @@ public class CustomBlockPropertyCompositeDropEditPolicy extends CustomDragDropEd
if(dropRequest.getObjects().size() == 1) {
// List of available drop commands
- List<Command> commandChoice = new ArrayList<Command>();
+ final List<Command> commandChoice = new ArrayList<Command>();
// 1. Try to set the target element type with dropped object
Command dropAsSetType = helper.getDropAsTypedElementType(dropRequest, (GraphicalEditPart)getHost());
@@ -130,9 +132,17 @@ public class CustomBlockPropertyCompositeDropEditPolicy extends CustomDragDropEd
// Prepare the selection command (if several command are available) or return the drop command
if(commandChoice.size() > 1) {
- SelectAndExecuteCommand selectCommand = new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice);
- return new ICommandProxy(selectCommand);
+ RunnableWithResult<ICommand> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() {
+
+ public void run() {
+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice));
+ }
+ });
+ ICommand selectCommand = runnable.getResult();
+
+ return new ICommandProxy(selectCommand);
} else if(commandChoice.size() == 1) {
return commandChoice.get(0);
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy.java
index 88fafc7dff0..d30a5eda6c3 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy.java
@@ -16,8 +16,10 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
@@ -26,6 +28,7 @@ import org.eclipse.papyrus.sysml.diagram.internalblock.utils.BlockDropHelper;
import org.eclipse.papyrus.sysml.diagram.internalblock.utils.PartDropHelper;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -53,7 +56,7 @@ public class CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy exten
if(dropRequest.getObjects().size() == 1) {
// List of available drop commands
- List<Command> commandChoice = new ArrayList<Command>();
+ final List<Command> commandChoice = new ArrayList<Command>();
// 1. Build command to drop BlockProperty
PartDropHelper partDropHelper = new PartDropHelper(getEditingDomain());
@@ -101,9 +104,17 @@ public class CustomBlockPropertyStructureCompartmentEditPartDropEditPolicy exten
// Prepare the selection command (if several command are available) or return the drop command
if(commandChoice.size() > 1) {
- SelectAndExecuteCommand selectCommand = new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice);
- return new ICommandProxy(selectCommand);
+ RunnableWithResult<ICommand> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() {
+
+ public void run() {
+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice));
+ }
+ });
+ ICommand selectCommand = runnable.getResult();
+
+ return new ICommandProxy(selectCommand);
} else if(commandChoice.size() == 1) {
return commandChoice.get(0);
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/EncapsulatedClassifierDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/EncapsulatedClassifierDropEditPolicy.java
index 522fad1c4b8..7f89985f17f 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/EncapsulatedClassifierDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/EncapsulatedClassifierDropEditPolicy.java
@@ -16,14 +16,17 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand;
import org.eclipse.papyrus.sysml.diagram.internalblock.utils.TypeDropHelper;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -51,7 +54,7 @@ public class EncapsulatedClassifierDropEditPolicy extends CustomDragDropEditPoli
if(dropRequest.getObjects().size() == 1) {
// List of available drop commands
- List<Command> commandChoice = new ArrayList<Command>();
+ final List<Command> commandChoice = new ArrayList<Command>();
// 1. Try to create a Port typed by the dropped object
Command dropAsTypedPort = helper.getDropAsTypedPort(dropRequest, (GraphicalEditPart)getHost());
@@ -82,7 +85,16 @@ public class EncapsulatedClassifierDropEditPolicy extends CustomDragDropEditPoli
// Prepare the selection command (if several command are available) or return the drop command
if(commandChoice.size() > 1) {
- SelectAndExecuteCommand selectCommand = new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice);
+ RunnableWithResult<ICommand> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() {
+
+ public void run() {
+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice));
+ }
+ });
+
+ ICommand selectCommand = runnable.getResult();
+
return new ICommandProxy(selectCommand);
} else if(commandChoice.size() == 1) {
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/StructureClassifierDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/StructureClassifierDropEditPolicy.java
index ad4c163a4f6..eb2ed7001e9 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/StructureClassifierDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/StructureClassifierDropEditPolicy.java
@@ -16,8 +16,10 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
@@ -25,6 +27,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand
import org.eclipse.papyrus.sysml.diagram.internalblock.utils.BlockDropHelper;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -52,7 +55,7 @@ public class StructureClassifierDropEditPolicy extends CustomDragDropEditPolicy
if(dropRequest.getObjects().size() == 1) {
// List of available drop commands
- List<Command> commandChoice = new ArrayList<Command>();
+ final List<Command> commandChoice = new ArrayList<Command>();
// 1. Try to create a Part typed by the dropped object
Command dropAsTypedPart = helper.getDropAsStructureItem(dropRequest, (GraphicalEditPart)getHost(), SysMLElementTypes.PART_PROPERTY);
@@ -93,7 +96,16 @@ public class StructureClassifierDropEditPolicy extends CustomDragDropEditPolicy
// Prepare the selection command (if several command are available) or return the drop command
if(commandChoice.size() > 1) {
- SelectAndExecuteCommand selectCommand = new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice);
+ RunnableWithResult<ICommand> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() {
+
+ public void run() {
+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice));
+ }
+ });
+
+ ICommand selectCommand = runnable.getResult();
+
return new ICommandProxy(selectCommand);
} else if(commandChoice.size() == 1) {
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/TypedElementDropEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/TypedElementDropEditPolicy.java
index 11f3b4cca8f..b07c3dd4c34 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/TypedElementDropEditPolicy.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src/org/eclipse/papyrus/sysml/diagram/internalblock/edit/policy/TypedElementDropEditPolicy.java
@@ -16,13 +16,16 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.edit.policy;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand;
import org.eclipse.papyrus.sysml.diagram.internalblock.utils.TypeDropHelper;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -49,7 +52,7 @@ public class TypedElementDropEditPolicy extends CustomDragDropEditPolicy {
if(dropRequest.getObjects().size() == 1) {
// List of available drop commands
- List<Command> commandChoice = new ArrayList<Command>();
+ final List<Command> commandChoice = new ArrayList<Command>();
// 1. Try to set the target element type with dropped object
Command dropAsSetType = helper.getDropAsTypedElementType(dropRequest, (GraphicalEditPart)getHost());
@@ -66,9 +69,17 @@ public class TypedElementDropEditPolicy extends CustomDragDropEditPolicy {
// Prepare the selection command (if several command are available) or return the drop command
if(commandChoice.size() > 1) {
- SelectAndExecuteCommand selectCommand = new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice);
- return new ICommandProxy(selectCommand);
+ RunnableWithResult<ICommand> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommand>() {
+
+ public void run() {
+ setResult(new SelectAndExecuteCommand("Select drop action for ", PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), commandChoice));
+ }
+ });
+ ICommand selectCommand = runnable.getResult();
+
+ return new ICommandProxy(selectCommand);
} else if(commandChoice.size() == 1) {
return commandChoice.get(0);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinAndParameterSynchronizer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinAndParameterSynchronizer.java
index dd9bcd95b0c..e7aa05215cf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinAndParameterSynchronizer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinAndParameterSynchronizer.java
@@ -59,7 +59,9 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.uml.diagram.activity.commands.CreatePinToParameterLinkEAnnotation;
import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.ConfirmPinAndParameterSyncDialog;
import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.WarningAndCreateAttributeDialog;
@@ -456,6 +458,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
}
SafeDialogOpenerDuringValidation<Boolean> opener = new SafeDialogOpenerDuringValidation<Boolean>() {
+ @Override
protected Boolean openDialog() {
WarningAndCreateParameterDialog dialog = new WarningAndCreateParameterDialog(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UnauthorizedModificationTitle, message, element, labelProvider, preferredDirection);
boolean result = dialog.open() == Window.OK;
@@ -489,7 +492,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
for(InvocationAction action : callingActions) {
if(action instanceof CallAction) {
int index = action.getArguments().size();
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, Collections.singletonMap(index, (TypedElement)parameter), empty, preferredPinClass);
+ CompoundCommand cmd = getAddPinsCmd(action, Collections.singletonMap(index, (TypedElement)parameter), empty, preferredPinClass);
globalCmd.append(cmd);
}
}
@@ -499,7 +502,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
for(InvocationAction action : callingActions) {
if(action instanceof CallAction) {
int index = ((CallAction)action).getResults().size();
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, empty, Collections.singletonMap(index, (TypedElement)parameter), preferredPinClass);
+ CompoundCommand cmd = getAddPinsCmd(action, empty, Collections.singletonMap(index, (TypedElement)parameter), preferredPinClass);
globalCmd.append(cmd);
}
}
@@ -509,7 +512,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
if(action instanceof CallAction) {
int indexIn = action.getArguments().size();
int indexOut = ((CallAction)action).getResults().size();
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, Collections.singletonMap(indexIn, (TypedElement)parameter), Collections.singletonMap(indexOut, (TypedElement)parameter), preferredPinClass);
+ CompoundCommand cmd = getAddPinsCmd(action, Collections.singletonMap(indexIn, (TypedElement)parameter), Collections.singletonMap(indexOut, (TypedElement)parameter), preferredPinClass);
globalCmd.append(cmd);
}
}
@@ -534,6 +537,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String message = NLS.bind(Messages.PinAndParameterSynchronizer_UnauthorizedModification, elementLabel);
SafeDialogOpenerDuringValidation<Boolean> opener = new SafeDialogOpenerDuringValidation<Boolean>() {
+ @Override
protected Boolean openDialog() {
WarningAndCreateAttributeDialog dialog = new WarningAndCreateAttributeDialog(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UnauthorizedModificationTitle, message, element, labelProvider);
boolean result = dialog.open() == Window.OK;
@@ -565,7 +569,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
for(InvocationAction action : callingActions) {
if(action instanceof SendSignalAction || action instanceof BroadcastSignalActionEditPart) {
int index = action.getArguments().size();
- CompoundCommand cmd = getAddPinsCmd((SendSignalAction)action, Collections.singletonMap(index, property), preferredPinClass);
+ CompoundCommand cmd = getAddPinsCmd(action, Collections.singletonMap(index, property), preferredPinClass);
globalCmd.append(cmd);
}
}
@@ -586,6 +590,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String message = NLS.bind(Messages.PinAndParameterSynchronizer_UnauthorizedModificationRedirection, elementLabel);
SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+ @Override
protected Void openDialog() {
WarningAndLinkDialog dialog = new WarningAndLinkDialog(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UnauthorizedModificationTitle, message, element, elementLabel);
dialog.open();
@@ -725,7 +730,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
if(action instanceof CallAction) {
CompoundCommand cmd = getRemovePinsCmd((CallAction)action, Collections.singletonList(inIndex), emptyList);
globalCmd.append(cmd);
- cmd = getAddPinsCmd((CallAction)action, emptyMap, Collections.singletonMap(outIndex, parameter), null);
+ cmd = getAddPinsCmd(action, emptyMap, Collections.singletonMap(outIndex, parameter), null);
globalCmd.append(cmd);
}
}
@@ -733,7 +738,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
// explore referencing actions to add out
for(InvocationAction action : callingActions) {
if(action instanceof CallAction) {
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, emptyMap, Collections.singletonMap(outIndex, parameter), null);
+ CompoundCommand cmd = getAddPinsCmd(action, emptyMap, Collections.singletonMap(outIndex, parameter), null);
globalCmd.append(cmd);
}
}
@@ -745,7 +750,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
if(action instanceof CallAction) {
CompoundCommand cmd = getRemovePinsCmd((CallAction)action, emptyList, Collections.singletonList(outIndex));
globalCmd.append(cmd);
- cmd = getAddPinsCmd((CallAction)action, Collections.singletonMap(inIndex, parameter), emptyMap, null);
+ cmd = getAddPinsCmd(action, Collections.singletonMap(inIndex, parameter), emptyMap, null);
globalCmd.append(cmd);
}
}
@@ -753,7 +758,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
// explore referencing actions to add in
for(InvocationAction action : callingActions) {
if(action instanceof CallAction) {
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, Collections.singletonMap(inIndex, parameter), emptyMap, null);
+ CompoundCommand cmd = getAddPinsCmd(action, Collections.singletonMap(inIndex, parameter), emptyMap, null);
globalCmd.append(cmd);
}
}
@@ -890,6 +895,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String msg = NLS.bind(Messages.PinAndParameterSynchronizer_UndeleteablePinMessage, UMLPackage.eINSTANCE.getCallOperationAction_Target().getName());
SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+ @Override
protected Void openDialog() {
MessageDialog.openWarning(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UndeleteablePinTitle, msg);
return null;
@@ -1143,6 +1149,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String msg = NLS.bind(Messages.PinAndParameterSynchronizer_UndeleteablePinMessage, UMLPackage.eINSTANCE.getSendSignalAction_Target().getName());
SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+ @Override
protected Void openDialog() {
MessageDialog.openWarning(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UndeleteablePinTitle, msg);
return null;
@@ -1176,6 +1183,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String msg = NLS.bind(Messages.PinAndParameterSynchronizer_UndeleteablePinMessage, UMLPackage.eINSTANCE.getSendObjectAction_Target().getName());
SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+ @Override
protected Void openDialog() {
MessageDialog.openWarning(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UndeleteablePinTitle, msg);
return null;
@@ -1192,6 +1200,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
final String msg = NLS.bind(Messages.PinAndParameterSynchronizer_UndeleteablePinMessage, UMLPackage.eINSTANCE.getSendObjectAction_Request().getName());
SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+ @Override
protected Void openDialog() {
MessageDialog.openWarning(new Shell(Display.getDefault()), Messages.PinAndParameterSynchronizer_UndeleteablePinTitle, msg);
return null;
@@ -1527,7 +1536,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
List<InvocationAction> callingActions = getCallingActions(element);
for(InvocationAction action : callingActions) {
if(action instanceof CallAction) {
- CompoundCommand cmd = getAddPinsCmd((CallAction)action, addedInputPinMap, addedOutputPinMap, null);
+ CompoundCommand cmd = getAddPinsCmd(action, addedInputPinMap, addedOutputPinMap, null);
globalCmd.append(cmd);
}
}
@@ -1624,7 +1633,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
}
List<Property> newAttributes = Collections.emptyList();
if(element instanceof Signal) {
- newAttributes = ((Signal)element).getOwnedAttributes();
+ newAttributes = element.getOwnedAttributes();
}
Map<Integer, Property> addedInputPinMap = new HashMap<Integer, Property>();
// iterate on the list of added attributes to deduce pins indexes
@@ -1638,7 +1647,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
List<InvocationAction> callingActions = getCallingActions(element);
for(InvocationAction action : callingActions) {
if(action instanceof SendSignalAction) {
- CompoundCommand cmd = getAddPinsCmd((SendSignalAction)action, addedInputPinMap, null);
+ CompoundCommand cmd = getAddPinsCmd(action, addedInputPinMap, null);
globalCmd.append(cmd);
}
}
@@ -2247,7 +2256,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
if(feature != null && feature.getType() != null) {
Type owningType = feature.getType();
if(owningType instanceof Type) {
- pin.setType((Type)owningType);
+ pin.setType(owningType);
}
}
}
@@ -2267,7 +2276,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
if(var != null) {
Type owningType = var.getType();
if(owningType instanceof Type) {
- pin.setType((Type)owningType);
+ pin.setType(owningType);
}
}
pin.setName(VALUE_IN_ADD_VARIABLE_VALUE_ACTION);
@@ -2309,7 +2318,13 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
*/
protected CompoundCommand getResetPinsCmd(ReadStructuralFeatureAction action) {
// Get the editing domain
- TransactionalEditingDomain editingdomain = EditorUtils.getTransactionalEditingDomain();
+ TransactionalEditingDomain editingdomain;
+ try {
+ editingdomain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(action);
+ } catch (ServiceException ex) {
+ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, ex.getMessage(), ex);
+ return null;
+ }
CompoundCommand globalCmd = new CompoundCommand();
// add result pin
if(action.getResult() == null) {
@@ -2582,14 +2597,14 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
//In
if(direction == ParameterDirectionKind.IN_LITERAL || direction == ParameterDirectionKind.INOUT_LITERAL) {
if(!paramsToIgnore.contains(param)) {
- inParams.put(inIndex, (TypedElement)param);
+ inParams.put(inIndex, param);
}
inIndex++;
}
//Out
if(direction == ParameterDirectionKind.OUT_LITERAL || direction == ParameterDirectionKind.INOUT_LITERAL || direction == ParameterDirectionKind.RETURN_LITERAL) {
if(!paramsToIgnore.contains(param)) {
- outParams.put(outIndex, (TypedElement)param);
+ outParams.put(outIndex, param);
}
outIndex++;
}
@@ -2599,7 +2614,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
Integer inIndex = 0;
for(TypedElement typeElem : allParams) {
if(!paramsToIgnore.contains(typeElem)) {
- inParams.put(inIndex, (TypedElement)typeElem);
+ inParams.put(inIndex, typeElem);
}
inIndex++;
}
@@ -2929,6 +2944,7 @@ public class PinAndParameterSynchronizer extends AbstractModelConstraint {
protected boolean askForValidation(final List<? extends NamedElement> listOfActions) {
SafeDialogOpenerDuringValidation<Boolean> opener = new SafeDialogOpenerDuringValidation<Boolean>() {
+ @Override
protected Boolean openDialog() {
return ConfirmPinAndParameterSyncDialog.openConfirmFromParameter(Display.getDefault().getActiveShell(), listOfActions, labelProvider);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
index 710b6cc0e76..13340905a5a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/part/UmlGmfDiagramEditor.java
@@ -85,6 +85,9 @@ public class UmlGmfDiagramEditor extends SynchronizableGmfDiagramEditor {
// Do nothing
}
+ partNameSynchronizer = null;
+ diagram = null;
+ servicesRegistry = null;
}
/**
@@ -190,11 +193,10 @@ public class UmlGmfDiagramEditor extends SynchronizableGmfDiagramEditor {
diagram.eAdapters().add(diagramNameListener);
}
}
-
+
@Override
public void createPartControl(Composite parent) {
- IContextService contextService = (IContextService) getSite()
- .getService(IContextService.class);
+ IContextService contextService = (IContextService)getSite().getService(IContextService.class);
//FIXME : before Eclipse Juno, this line was not necessary
//see bug 367816 and bug 382218
contextService.activateContext("org.eclipse.gmf.runtime.diagram.ui.diagramContext"); //$NON-NLS-1$
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/locators/CustomEntryExitPointPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/locators/CustomEntryExitPointPositionLocator.java
index 2f615888c7b..3f42ea0aa00 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/locators/CustomEntryExitPointPositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/locators/CustomEntryExitPointPositionLocator.java
@@ -50,7 +50,7 @@ public class CustomEntryExitPointPositionLocator implements IBorderItemLocator {
public int getCurrentSideOfParent() {
int position = PositionConstants.NONE;
- System.out.println("parentsBounds = " + parentFigure.getBounds());
+ // System.out.println("parentsBounds = " + parentFigure.getBounds());
//we are not on EAST, not on WEST, but we are on the NORTH
if((constraint.x != parentFigure.getBounds().width - borderItemOffset) && (constraint.x != -this.borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
index c0522df9594..53d9ba6e5ca 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/AbstractEMFCommandHandler.java
@@ -23,13 +23,18 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
import org.eclipse.papyrus.uml.commands.Activator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -72,7 +77,7 @@ public abstract class AbstractEMFCommandHandler extends AbstractHandler {
*
* </pre>
*/
- protected abstract Command getCommand();
+ protected abstract Command getCommand(ServicesRegistry registry);
/**
* <pre>
@@ -127,8 +132,18 @@ public abstract class AbstractEMFCommandHandler extends AbstractHandler {
List<EObject> selectedEObjects = new ArrayList<EObject>();
+ //FIXME: This method should always be called from the UI Thread.
+ //TODO: Fix the tests and remove the syncExec call
// Parse current selection
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ RunnableWithResult<ISelection> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ISelection>() {
+
+ public void run() {
+ setResult(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection());
+ }
+ });
+
+ ISelection selection = runnable.getResult();
if(selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
for(Object current : structuredSelection.toArray()) {
@@ -167,11 +182,10 @@ public abstract class AbstractEMFCommandHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
+ ServicesRegistry registry = ServiceUtilsForHandlers.getInstance().getServiceRegistry(event);
+ Command emfCommand = getCommand(registry);
- ServiceUtilsForActionHandlers util = ServiceUtilsForActionHandlers.getInstance();
- Command emfCommand = getCommand();
-
- util.getTransactionalEditingDomain().getCommandStack().execute(emfCommand);
+ ServiceUtils.getInstance().getTransactionalEditingDomain(registry).getCommandStack().execute(emfCommand);
return emfCommand.getResult();
@@ -190,8 +204,24 @@ public abstract class AbstractEMFCommandHandler extends AbstractHandler {
*
* @return true (enabled) when the command can be executed.
*/
+ @Override
public boolean isEnabled() {
- return getCommand().canExecute();
+ return getCommand(getServicesRegistryFromSelection()).canExecute();
+ }
+
+ protected ServicesRegistry getServicesRegistryFromSelection() {
+ for(EObject selectedElement : getSelectedElements()) {
+ try {
+ ServicesRegistry registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(selectedElement);
+ if(registry != null) {
+ return registry;
+ }
+ } catch (ServiceException ex) {
+ //Ignore it and keep searching for a ServicesRegistry
+ }
+ }
+
+ return null;
}
/**
@@ -199,6 +229,6 @@ public abstract class AbstractEMFCommandHandler extends AbstractHandler {
* @return true (visible) when the command can be executed.
*/
public boolean isVisible() {
- return getCommand().canExecute();
+ return getCommand(getServicesRegistryFromSelection()).canExecute();
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
index 36891432350..5ce796357c1 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/CopyHandler.java
@@ -24,6 +24,10 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AbstractOverrideableCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.uml.commands.Activator;
/**
* Handler for the Copy Action
@@ -40,33 +44,42 @@ public class CopyHandler extends AbstractEMFCommandHandler {
* @return
*/
@Override
- protected Command getCommand() {
- final TransactionalEditingDomain editingDomain = getEditingDomain();
- List<EObject> selection = getSelectedElements();
- if(editingDomain != null && !selection.isEmpty()) {
- final Collection<Object> stereotypedSelection = new ArrayList<Object>();
- stereotypedSelection.addAll(getSelectedElements());
- // Iterator<EObject> selecIterator = selection.iterator();
- // while(selecIterator.hasNext()) {
- // EObject eObject = (EObject)selecIterator.next();
- //
- // if(eObject instanceof Element) {
- // stereotypedSelection.addAll(((Element)eObject).getStereotypeApplications());
- // }
- // //copy stereotype contained into
- // Iterator<EObject> iter = eObject.eAllContents();
- // while(iter.hasNext()) {
- // EObject subeObject = (EObject)iter.next();
- // if(subeObject instanceof Element) {
- // stereotypedSelection.addAll(((Element)subeObject).getStereotypeApplications());
- // }
- //
- // }
- //
- // }
-
- return new PutInClipboardCommand(editingDomain, stereotypedSelection);
- //return CopyToClipboardCommand.create(getEditingDomain(), stereotypedSelection);
+ protected Command getCommand(ServicesRegistry registry) {
+ if(registry != null) {
+ final TransactionalEditingDomain editingDomain;
+ try {
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ List<EObject> selection = getSelectedElements();
+ if(editingDomain != null && !selection.isEmpty()) {
+ final Collection<Object> stereotypedSelection = new ArrayList<Object>();
+ stereotypedSelection.addAll(getSelectedElements());
+ // Iterator<EObject> selecIterator = selection.iterator();
+ // while(selecIterator.hasNext()) {
+ // EObject eObject = (EObject)selecIterator.next();
+ //
+ // if(eObject instanceof Element) {
+ // stereotypedSelection.addAll(((Element)eObject).getStereotypeApplications());
+ // }
+ // //copy stereotype contained into
+ // Iterator<EObject> iter = eObject.eAllContents();
+ // while(iter.hasNext()) {
+ // EObject subeObject = (EObject)iter.next();
+ // if(subeObject instanceof Element) {
+ // stereotypedSelection.addAll(((Element)subeObject).getStereotypeApplications());
+ // }
+ //
+ // }
+ //
+ // }
+
+ return new PutInClipboardCommand(editingDomain, stereotypedSelection);
+ //return CopyToClipboardCommand.create(getEditingDomain(), stereotypedSelection);
+ }
}
return UnexecutableCommand.INSTANCE;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
index 93bb876bf69..11df06777e2 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.commands/src/org/eclipse/papyrus/uml/commands/handler/PasteHandler.java
@@ -19,7 +19,11 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.commands.Activator;
import org.eclipse.papyrus.uml.commands.command.PasteElementCommand;
/**
@@ -35,8 +39,19 @@ public class PasteHandler extends AbstractEMFCommandHandler {
* @return
*/
@Override
- protected Command getCommand() {
- TransactionalEditingDomain editingDomain = getEditingDomain();
+ protected Command getCommand(ServicesRegistry registry) {
+ if(registry == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ final TransactionalEditingDomain editingDomain;
+ try {
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return UnexecutableCommand.INSTANCE;
+ }
+
List<EObject> selection = getSelectedElements();
if(editingDomain != null && selection.size() == 1) {
//return PasteFromClipboardCommand.create(getEditingDomain(), selection.get(0), null);
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index c49f48a472b..85ef9a584de 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -63,6 +63,7 @@ import org.eclipse.papyrus.views.modelexplorer.matching.ReferencableMatchingItem
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
@@ -680,7 +681,7 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
* @param commonViewer
* The CommonViewer they are to be revealed in
*/
- public static void reveal(Iterable<?> elementList, CommonViewer commonViewer) {
+ public static void reveal(Iterable<?> elementList, final CommonViewer commonViewer) {
ArrayList<IMatchingItem> matchingItemsToSelect = new ArrayList<IMatchingItem>();
// filter out non EMF objects
Iterable<EObject> list = Iterables.transform(Iterables.filter(elementList, EObject.class), new Function<Object, EObject>() {
@@ -739,10 +740,27 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
if(parent.eContainingFeature() != null && previousParent != null) {
commonViewer.expandToLevel(new LinkItemMatchingItem(previousParent, parent.eContainmentFeature()), 1);
}
- commonViewer.expandToLevel(new ModelElementItemMatchingItem(parent), 1);
+
+ final IMatchingItem itemToExpand = new ModelElementItemMatchingItem(parent);
+
+ commonViewer.getControl().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ commonViewer.expandToLevel(itemToExpand, 1);
+ }
+ });
+
previousParent = parent;
}
- commonViewer.expandToLevel(new LinkItemMatchingItem(currentEObject.eContainer(), currentEObject.eContainmentFeature()), 1);
+
+ final IMatchingItem itemToExpand = new LinkItemMatchingItem(currentEObject.eContainer(), currentEObject.eContainmentFeature());
+
+ commonViewer.getControl().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ commonViewer.expandToLevel(itemToExpand, 1);
+ }
+ });
}
}
@@ -757,8 +775,13 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
* @param commonViewer
* The ComonViewer to select it in
*/
- public static void selectReveal(ISelection structuredSelection, Viewer commonViewer) {
- commonViewer.setSelection(structuredSelection, true);
+ public static void selectReveal(final ISelection structuredSelection, final Viewer commonViewer) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ commonViewer.setSelection(structuredSelection, true);
+ }
+ });
}
/**
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/NavigatorUtils.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/NavigatorUtils.java
index 26573c032fa..f6438f7b543 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/NavigatorUtils.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/NavigatorUtils.java
@@ -13,6 +13,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
@@ -21,6 +22,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
@@ -52,21 +54,33 @@ public class NavigatorUtils {
*
* @return the i view part
*/
- public static IViewPart findViewPart(String viewID) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if(page == null) {
- return null;
- }
- IViewReference reference = page.findViewReference(viewID);
- if(reference == null) {
- return null;
- }
- IWorkbenchPart part = reference.getPart(false);
- if(part instanceof IViewPart) {
- return (IViewPart)part;
- } else {
- return null;
- }
+ public static IViewPart findViewPart(final String viewID) {
+ RunnableWithResult<IViewPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IViewPart>() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if(page == null) {
+ setResult(null);
+ return;
+ }
+ IViewReference reference = page.findViewReference(viewID);
+ if(reference == null) {
+ setResult(null);
+ return;
+ }
+ IWorkbenchPart part = reference.getPart(false);
+ if(part instanceof IViewPart) {
+ setResult((IViewPart)part);
+ return;
+ } else {
+ setResult(null);
+ return;
+ }
+ }
+ });
+
+ return runnable.getResult();
}
/**
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
index 20ba2b1ec49..9e618d63056 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTTabDescriptorProvider.java
@@ -65,6 +65,12 @@ public class XWTTabDescriptorProvider implements ITabDescriptorProvider {
display.dispose();
displays.remove(part);
}
+
+ //We remove pointers to the cached IWorkbenchPart, to avoid Memory Leaks.
+ //Even if the closed part is not the previousPart, both parts may share the same objects (e.g. ModelExplorer & DiagramEditor).
+ //We'd better not retain the selection at all. In such a case, we won't receive a SelectionChangedEvent from the ModelExplorer.
+ previousPart = null;
+ previousSelection = null;
}
public void partActivated(IWorkbenchPart part) {
@@ -114,6 +120,7 @@ public class XWTTabDescriptorProvider implements ITabDescriptorProvider {
if(contributor != null) {
// get all tab descriptors for the registered extension points
+ //Memory leak here
TabbedPropertyRegistry registry = TabbedPropertyRegistryFactory.getInstance().createRegistry(contributor);
// invoke dynamically on the tab registry, as method is private
@@ -149,6 +156,9 @@ public class XWTTabDescriptorProvider implements ITabDescriptorProvider {
orderTabDescriptors(descriptors);
cachedResult = descriptors.toArray(new ITabDescriptor[descriptors.size()]);
+
+ //Workaround for memory leak
+ TabbedPropertyRegistryFactory.getInstance().disposeRegistry((ITabbedPropertySheetPageContributor)part);
}
return cachedResult;
diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
index 5b687cf90bb..e19f67a35ac 100644
--- a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="0.10.0",
org.eclipse.papyrus.infra.gmfdiag.css.configuration;bundle-version="0.10.0",
org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="0.10.0",
diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSClassProviderTest.java b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSClassProviderTest.java
index 95abb653611..a6946632989 100644
--- a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSClassProviderTest.java
+++ b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSClassProviderTest.java
@@ -58,7 +58,7 @@ public class CSSClassProviderTest {
}
@Test
- public void testResult() {
+ public void testCSSClassContentProvider() {
ExtendedCSSEngine engine = diagram.getEngine();
IStaticContentProvider provider = new CSSClassContentProvider("Interface", engine);
Object[] result = provider.getElements();
diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
index 07ddb184e24..0c1efe15355 100644
--- a/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
+++ b/tests/junit/extraplugins/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSStylesheetTest.java
@@ -61,7 +61,7 @@ public class CSSStylesheetTest {
return;
}
- Assert.assertTrue("Invalid color", classView.getFillColor() == rgb(255, 0, 0)); //Red = #FF0000
+ Assert.assertEquals("Invalid color", rgb(255, 0, 0), classView.getFillColor()); //Red = #FF0000
Assert.assertNull("Invalid gradient", classView.getGradient());
Assert.assertTrue(AppearanceHelper.showElementIcon(classView));
}
@@ -70,36 +70,36 @@ public class CSSStylesheetTest {
public void testInterfaceStyle() {
Shape interfaceView = findShape("Interface1");
- Assert.assertTrue(interfaceView.getGradient() != null);
- Assert.assertTrue(interfaceView.getFillColor() == rgb(255, 255, 0)); //Yellow = #FFFF00
- Assert.assertTrue(interfaceView.getGradient().getGradientColor1() == rgb(255, 0, 0)); //Red = #FF0000
- Assert.assertTrue(interfaceView.getGradient().getGradientStyle() == GradientStyle.VERTICAL);
+ Assert.assertNotNull(interfaceView.getGradient());
+ Assert.assertEquals(rgb(255, 255, 0), interfaceView.getFillColor()); //Yellow = #FFFF00
+ Assert.assertEquals(rgb(255, 0, 0), interfaceView.getGradient().getGradientColor1()); //Red = #FF0000
+ Assert.assertEquals(GradientStyle.VERTICAL, interfaceView.getGradient().getGradientStyle());
Assert.assertTrue(AppearanceHelper.showElementIcon(interfaceView));
}
@Test
public void testCSSClassStyle() {
Shape interfaceView = findShape("Interface2");
- Assert.assertTrue(interfaceView.getGradient() != null);
- Assert.assertTrue(interfaceView.getFillColor() == rgb(144, 238, 144)); //Lightgreen = #90EE90
+ Assert.assertNotNull(interfaceView.getGradient());
+ Assert.assertEquals(rgb(144, 238, 144), interfaceView.getFillColor()); //Lightgreen = #90EE90
//Case insensitive color name
- Assert.assertTrue(interfaceView.getGradient().getGradientColor1() == rgb(0, 191, 255)); //DeepSkyBlue = #00BFFF
+ Assert.assertEquals(rgb(0, 191, 255), interfaceView.getGradient().getGradientColor1()); //DeepSkyBlue = #00BFFF
- Assert.assertTrue(interfaceView.getGradient().getGradientStyle() == GradientStyle.HORIZONTAL);
+ Assert.assertEquals(GradientStyle.HORIZONTAL, interfaceView.getGradient().getGradientStyle());
Assert.assertFalse(AppearanceHelper.showElementIcon(interfaceView));
//TODO: Font names should be case-insensitive
- Assert.assertTrue("KaiTi".equals(interfaceView.getFontName()));
+ Assert.assertEquals("KaiTi", interfaceView.getFontName());
}
@Test
public void testPackage() {
Shape packageView = findShape("Package1");
- Assert.assertTrue(packageView.getGradient() != null);
+ Assert.assertNotNull(packageView.getGradient());
//Inherited style (From *)
- Assert.assertTrue(packageView.getGradient().getGradientColor1() == rgb(255, 0, 0)); //Red = #FF0000
+ Assert.assertEquals(rgb(255, 0, 0), packageView.getGradient().getGradientColor1()); //Red = #FF0000
}
@Test
@@ -132,19 +132,19 @@ public class CSSStylesheetTest {
}
private void testBlueStyle(Shape shape) {
- Assert.assertTrue(shape.getFillColor() == rgb(195, 205, 255)); //rgb syntax
+ Assert.assertEquals(rgb(195, 205, 255), shape.getFillColor()); //rgb syntax
Assert.assertTrue(shape.isBold());
Assert.assertNotNull(shape.getGradient());
}
private void testWhiteStyle(Shape shape) {
- Assert.assertTrue(shape.getFillColor() == rgb(255, 255, 255)); //White = #FFFFFF (Hexa syntax)
+ Assert.assertEquals(rgb(255, 255, 255), shape.getFillColor()); //White = #FFFFFF (Hexa syntax)
Assert.assertFalse(shape.isBold());
Assert.assertNull(shape.getGradient());
}
private void testFontName(Shape shape) {
- Assert.assertTrue("Tunga".equals(shape.getFontName()));
+ Assert.assertEquals("Tunga", shape.getFontName());
}
@After
diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF
index f1b081d4f12..0e0c9bb8aec 100644
--- a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.papyrus.tests.extra.Activator
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit;bundle-version="4.8.2",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.gmfdiag.css.tests;bundle-version="0.10.0",
org.eclipse.papyrus.bundles.tests;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.diff.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.diff.tests/META-INF/MANIFEST.MF
index b9866fa3679..6a2098ea9bd 100644
--- a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.diff.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.diff.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit;bundle-version="4.10.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.junit.utils;bundle-version="0.10.0",
org.eclipse.core.resources,
org.eclipse.uml2.uml;bundle-version="4.0.0",
diff --git a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.file.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.file.tests/META-INF/MANIFEST.MF
index 5901cedd4f8..06dacb5ef47 100644
--- a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.file.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.file.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.papyrus.junit.utils;bundle-version="0.10.0",
org.eclipse.core.resources;bundle-version="3.8.0",
org.eclipse.jdt.ui;bundle-version="3.8.0",
diff --git a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.tests/META-INF/MANIFEST.MF
index 9a77d62b73e..d5d9085c796 100644
--- a/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.8.1",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.junit.utils;bundle-version="0.10.0",
org.eclipse.core.resources,
org.eclipse.papyrus.views.modelexplorer;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.configuration.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.configuration.tests/META-INF/MANIFEST.MF
index 7ce2528e7b0..ad7161177fe 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.configuration.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.configuration.tests/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.facet.infra.query;visibility:=reexport,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.junit;visibility:=reexport,
+ org.junit4;visibility:=reexport,
org.eclipse.papyrus.infra.queries.core;bundle-version="0.10.0",
org.eclipse.papyrus.core.queries.test;bundle-version="0.10.0",
org.eclipse.uml2.uml,
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.test/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.test/META-INF/MANIFEST.MF
index 0443350d3c8..4fe88ac2bf2 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.test/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.core.queries.test/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.papyrus.infra.queries.core;bundle-version="0.10.0",
- org.junit;resolution:=optional,
+ org.junit4;resolution:=optional,
org.eclipse.emf.facet.infra.query;bundle-version="0.1.0",
org.eclipse.emf.facet.infra.query.core;bundle-version="0.1.0",
org.eclipse.emf.facet.infra.common.core;bundle-version="0.1.0",
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/META-INF/MANIFEST.MF
index ab0be6e05bc..7ba9046a75d 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.core.resourceloading.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.1",
+Require-Bundle: org.junit4;bundle-version="4.0.0",
org.eclipse.uml2.uml;bundle-version="3.1.0",
org.eclipse.papyrus.infra.services.resourceloading.preferences;bundle-version="0.10.0",
org.eclipse.papyrus.uml.resourceloading.profile;bundle-version="0.10.0"
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF
index 78566786c2f..da582f62495 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit,
+Require-Bundle: org.junit4,
org.eclipse.papyrus.uml.service.types;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.infra.extendedtypes
Bundle-Vendor: %providerName
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch
index d2da13fb896..cbfc9a9841f 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.extendedtypes.tests/org.eclipse.papyrus.extendedtypes.tests.launch
@@ -30,7 +30,7 @@
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
-<booleanAttribute key="run_in_ui_thread" value="true"/>
+<booleanAttribute key="run_in_ui_thread" value="false"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
index 790bd444b31..f1a3724c148 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.1",
+Require-Bundle: org.junit4;bundle-version="4.0.0",
org.eclipse.uml2.uml;bundle-version="3.1.0",
org.eclipse.papyrus.uml.diagram.wizards;bundle-version="0.10.0",
org.eclipse.papyrus.uml.diagram.profile;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/wizard/TestNewModelWizardBase.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/wizard/TestNewModelWizardBase.java
index 01366f6f331..d900b68e156 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/wizard/TestNewModelWizardBase.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.tests/test/org/eclipse/papyrus/infra/core/wizard/TestNewModelWizardBase.java
@@ -9,6 +9,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.papyrus.uml.diagram.wizards.Activator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
@@ -37,12 +38,18 @@ public abstract class TestNewModelWizardBase extends TestCase {
return wizard;
}
- protected IWorkbenchWizard initWizardDialog(IWorkbenchWizard wizard) {
- wizard.init(getWorkbench(), getSelection());
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont());
- dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
- dialog.create();
+ protected IWorkbenchWizard initWizardDialog(final IWorkbenchWizard wizard) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ wizard.init(getWorkbench(), getSelection());
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont());
+ dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
+ dialog.create();
+ }
+ });
+
return wizard;
}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.paletteconfiguration.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.paletteconfiguration.tests/META-INF/MANIFEST.MF
index 7187295707a..f13f55c9e66 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.paletteconfiguration.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.paletteconfiguration.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.1",
+Require-Bundle: org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.core.queries.test;bundle-version="0.10.0"
Bundle-Vendor: Eclipse Modeling Project
Fragment-Host: org.eclipse.papyrus.uml.diagram.paletteconfiguration;bu
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.di.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.di.tests/META-INF/MANIFEST.MF
index b4b057c6da3..f7c6c0b2072 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.di.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.di.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.1"
+Require-Bundle: org.junit4;bundle-version="4.0.0"
Bundle-Vendor: %Bundle-Vendor
Fragment-Host: org.eclipse.papyrus.infra.core.sasheditor.di;bundle-ver
sion="0.10.0"
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/META-INF/MANIFEST.MF
index 7685fdd6551..d0e010066d9 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Require-Bundle: org.eclipse.ui.editors;bundle-version="3.8.0",
org.eclipse.jface.text;bundle-version="3.8.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
org.eclipse.core.resources;bundle-version="3.8.0",
- org.junit;bundle-version="4.10.0"
+ org.junit4;bundle-version="4.0.0"
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.infra.core.sasheditor;bundle-versio
n="0.10.0"
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainerDisposeCalledTest.java b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainerDisposeCalledTest.java
index 0a0dcbf398f..0956dc9178f 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainerDisposeCalledTest.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsContainerDisposeCalledTest.java
@@ -26,6 +26,7 @@ import org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.FakeMultiSashP
import org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.TestTextEditor;
import org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.TextEditorPartModel;
import org.eclipse.papyrus.infra.core.sasheditor.tests.utils.trace.ITraceRecords;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -36,10 +37,10 @@ import org.junit.Before;
import org.junit.Test;
/**
- * Tests to check memory leak and dispose() calls.
+ * Tests to check memory leak and dispose() calls.
*
* @author Cedric Dumoulin
- *
+ *
*/
public class SashWindowsContainerDisposeCalledTest {
@@ -55,25 +56,30 @@ public class SashWindowsContainerDisposeCalledTest {
*/
@After
public void tearDown() throws Exception {
-
- // Close all remaining opened editors
- IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- page.closeAllEditors(false);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // Close all remaining opened editors
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ page.closeAllEditors(false);
+ }
+ });
}
-
+
/**
- * Test the call of dispose() on nestedEditor when the editor is
+ * Test the call of dispose() on nestedEditor when the editor is
* closed independently
*
- * * @throws PartInitException
- * @throws Exception
+ * * @throws PartInitException
+ *
+ * @throws Exception
*/
@Test
public void testDisposeCallOnNestedEditorRemoval() throws Exception {
// Create
SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider();
-
+
// Create pages and add them to the default folder
int pageCount = 3;
List<IPageModel> models = new ArrayList<IPageModel>();
@@ -82,37 +88,43 @@ public class SashWindowsContainerDisposeCalledTest {
contentProvider.addPage(newModel);
models.add(newModel);
}
-
-
+
+
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor(contentProvider);
// Get the container
- SashWindowsContainer container = editor.getSashWindowsContainer();
-
+ final SashWindowsContainer container = editor.getSashWindowsContainer();
+
// Check if nested editor creation work
IEditorPart activeNestedEditor = editor.getActiveEditor();
assertEquals("nested editor is of right type", TestTextEditor.class, activeNestedEditor.getClass());
-// // Close the editor by removing its model
-// contentProvider.removePage(models.get(0));
-// // Refresh the container: this should close the editor
-// container.refreshTabs();
-// assertNull( "No more active editor", container.getActiveEditor() );
-// // Check if dispose() is called
-// ITraceRecords traces = ((TextEditorPartModel)models.get(0)).getTraceRecords();
-// assertTrue("dispose is called", traces.contains(null, "dispose"));
-
+ // // Close the editor by removing its model
+ // contentProvider.removePage(models.get(0));
+ // // Refresh the container: this should close the editor
+ // container.refreshTabs();
+ // assertNull( "No more active editor", container.getActiveEditor() );
+ // // Check if dispose() is called
+ // ITraceRecords traces = ((TextEditorPartModel)models.get(0)).getTraceRecords();
+ // assertTrue("dispose is called", traces.contains(null, "dispose"));
+
// Close each container and check dispose call
for(IPageModel model : models) {
// Close the editor by removing its model
contentProvider.removePage(model);
// Refresh the container: this should close the editor
- container.refreshTabs();
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ container.refreshTabs();
+ }
+ });
+
// Check if dispose() is called
ITraceRecords traces = ((TextEditorPartModel)model).getTraceRecords();
- assertTrue("dispose is called", traces.contains(null, "dispose"));
-
+ assertTrue("dispose is called", traces.contains(null, "dispose"));
+
}
-
+
FakeMultiSashPageEditor.closeEditor(editor);
}
@@ -120,51 +132,51 @@ public class SashWindowsContainerDisposeCalledTest {
/**
* Test if dispose can be called twice without errors.
*
- * * @throws PartInitException
+ * * @throws PartInitException
*/
@Test
public void testCallingDisposeTwice() throws PartInitException {
}
-
+
/**
- * Test the call of dispose() on nestedEditor when the main editor is
- * closed. Normally, each nested editor should be disposed.
- *
- * * @throws PartInitException
- */
- @Test
- public void testDisposeCallOnMainEditorClose() throws PartInitException {
- // Create
- SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider();
-
- // Create pages and add them to the default folder
- int pageCount = 3;
- List<IPageModel> models = new ArrayList<IPageModel>();
- for(int i = 0; i < pageCount; i++) {
- IPageModel newModel = new TextEditorPartModel("model" + i, true);
- contentProvider.addPage(newModel);
- models.add(newModel);
- }
-
-
- FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor(contentProvider);
-
- // Check if nested editor creation work
- IEditorPart activeNestedEditor = editor.getActiveEditor();
- assertEquals("nested editor is of right type", TestTextEditor.class, activeNestedEditor.getClass());
-
- // Close the main editor
- FakeMultiSashPageEditor.closeEditor(editor);
-
- // for each container check dispose call
- assertEquals("list of model is alive", pageCount, models.size());
- for(IPageModel model : models) {
- // Check if dispose() is called
- ITraceRecords traces = ((TextEditorPartModel)model).getTraceRecords();
- assertTrue("dispose nested editor is called when main editor close", traces.contains(null, "dispose"));
- }
+ * Test the call of dispose() on nestedEditor when the main editor is
+ * closed. Normally, each nested editor should be disposed.
+ *
+ * * @throws PartInitException
+ */
+ @Test
+ public void testDisposeCallOnMainEditorClose() throws PartInitException {
+ // Create
+ SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider();
+ // Create pages and add them to the default folder
+ int pageCount = 3;
+ List<IPageModel> models = new ArrayList<IPageModel>();
+ for(int i = 0; i < pageCount; i++) {
+ IPageModel newModel = new TextEditorPartModel("model" + i, true);
+ contentProvider.addPage(newModel);
+ models.add(newModel);
}
+ FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor(contentProvider);
+
+ // Check if nested editor creation work
+ IEditorPart activeNestedEditor = editor.getActiveEditor();
+ assertEquals("nested editor is of right type", TestTextEditor.class, activeNestedEditor.getClass());
+
+ // Close the main editor
+ FakeMultiSashPageEditor.closeEditor(editor);
+
+ // for each container check dispose call
+ assertEquals("list of model is alive", pageCount, models.size());
+ for(IPageModel model : models) {
+ // Check if dispose() is called
+ ITraceRecords traces = ((TextEditorPartModel)model).getTraceRecords();
+ assertTrue("dispose nested editor is called when main editor close", traces.contains(null, "dispose"));
+ }
+
+ }
+
+
}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditor.java b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditor.java
index 76b9b90ae87..2136d09e0d2 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditor.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditor.java
@@ -23,6 +23,7 @@ import org.eclipse.papyrus.infra.core.sasheditor.internal.IMultiEditorManager;
import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -42,18 +43,19 @@ import org.eclipse.ui.part.EditorPart;
* See {@link FakeMultiSashPageEditorTest} for code examples.
*
* For tests to run properly, the editor should be registered as eclipse extension:
- * <pre>
+ *
+ * <pre>
* {@code
- <extension
- point="org.eclipse.ui.editors">
- <editor
- class="org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.FakeMultiSashPageEditor"
- default="false"
- id="org.eclipse.papyrus.infra.core.sasheditor.tests.editor.FakeMultiSashPageEditor"
- name="FakeMultiSashPageEditor">
- </editor>
- </extension>
- }
+ * <extension
+ * point="org.eclipse.ui.editors">
+ * <editor
+ * class="org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.FakeMultiSashPageEditor"
+ * default="false"
+ * id="org.eclipse.papyrus.infra.core.sasheditor.tests.editor.FakeMultiSashPageEditor"
+ * name="FakeMultiSashPageEditor">
+ * </editor>
+ * </extension>
+ * }
* </pre>
*
* @author Cedric Dumoulin
@@ -65,7 +67,7 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
* Can be used to open the editor.
*/
public static String EditorID = "org.eclipse.papyrus.infra.core.sasheditor.tests.editor.FakeMultiSashPageEditor";
-
+
/** The pageProvider */
private ISashWindowsContentProvider pageProvider;
@@ -76,15 +78,17 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
* IEditorPart of the opened editor.
*/
protected IEditorPart mainEditorPart;
-
-
+
+
/**
* Return an instance of the editor inside the Eclipse framework.
* The Editor should be registered to Eclipse extension.
* The editor will be created with the specified number of nested editors of type {@link TestTextEditor}
- * @param nestedEditorCount Number of expected nested editors.
*
- * @throws PartInitException
+ * @param nestedEditorCount
+ * Number of expected nested editors.
+ *
+ * @throws PartInitException
*/
public static FakeMultiSashPageEditor openEditor(int nestedEditorCount) throws PartInitException {
// Create a content provider with one editor
@@ -94,7 +98,7 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
IPageModel newModel = new TextEditorPartModel("editor" + i);
contentProvider.addPage(newModel);
}
-
+
return openEditor(contentProvider);
}
@@ -102,45 +106,78 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
* Return an instance of the editor inside the Eclipse framework.
* The Editor should be registered to Eclipse extension.
* The editor will contain one nested editor.
- * @throws PartInitException
+ *
+ * @throws PartInitException
*/
public static FakeMultiSashPageEditor openEditor() throws PartInitException {
-
+
return openEditor(1);
}
+ private static class OpenEditorRunnable implements Runnable {
+
+ private ISashWindowsContentProvider contentProvider;
+
+ private FakeMultiSashPageEditor editor;
+
+ public OpenEditorRunnable(ISashWindowsContentProvider contentProvider) {
+ this.contentProvider = contentProvider;
+ }
+
+ public void run() {
+ IEditorInput input = new FakeEditorInput(contentProvider);
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ IEditorPart part = page.openEditor(input, FakeMultiSashPageEditor.EditorID);
+
+ this.editor = (FakeMultiSashPageEditor)part;
+ } catch (PartInitException ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+
+ public FakeMultiSashPageEditor getEditor() {
+ return editor;
+ }
+ }
+
/**
* Return an instance of the editor inside the Eclipse framework.
* The Editor should be registered to Eclipse extension.
- * @throws PartInitException
+ *
+ * @throws PartInitException
*/
public static FakeMultiSashPageEditor openEditor(ISashWindowsContentProvider contentProvider) throws PartInitException {
- IEditorInput input = new FakeEditorInput(contentProvider);
-
- IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- IEditorPart part = page.openEditor(input, FakeMultiSashPageEditor.EditorID);
-
- return (FakeMultiSashPageEditor)part;
+ OpenEditorRunnable runnable = new OpenEditorRunnable(contentProvider);
+ Display.getDefault().syncExec(runnable);
+ return runnable.getEditor();
}
/**
* Close the specified editor.
+ *
* @param editor
*/
- public static void closeEditor( FakeMultiSashPageEditor editor ) {
- IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- page.closeEditor(editor, false);
+ public static void closeEditor(final FakeMultiSashPageEditor editor) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ page.closeEditor(editor, false);
+ }
+ });
}
-
+
/**
* get the contentProvider. Create it if necessary.
*
* @return
*/
public ISashWindowsContentProvider getContentProvider() {
-
+
return getContentProviderImpl();
}
@@ -196,9 +233,9 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
* @param propertyId
* the id of the property that changed
*/
-// protected void handlePropertyChange(int propertyId) {
-// firePropertyChange(propertyId);
-// }
+ // protected void handlePropertyChange(int propertyId) {
+ // firePropertyChange(propertyId);
+ // }
/**
* The <code>MultiPageEditorPart</code> implementation of this <code>IEditorPart</code> method sets its site to the given
@@ -215,16 +252,17 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
*/
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-
+
// Check if the input carry a ContentProvider.
- if( input instanceof FakeEditorInput) {
+ if(input instanceof FakeEditorInput) {
// Get the content provider from the input
FakeEditorInput providerInput = (FakeEditorInput)input;
ISashWindowsContentProvider provider = providerInput.getContentProvider();
- if( provider != null)
- setContentProvider(provider);
+ if(provider != null) {
+ setContentProvider(provider);
+ }
}
-
+
setSite(site);
setInput(input);
site.setSelectionProvider(new MultiPageSelectionProvider(this));
@@ -269,7 +307,7 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
public void dispose() {
deactivate();
super.dispose();
-// System.err.println("editor disposed");
+ // System.err.println("editor disposed");
// Clean references
mainEditorPart = null;
pageProvider = null;
@@ -295,7 +333,7 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
}
/**
- * Get the {@link ISashWindowsContainer}.
+ * Get the {@link ISashWindowsContainer}.
* Note the the ISashWindowsContainer can also be acuired with getAdapter(ISashWindowsContainer.class).
*/
public ISashWindowsContainer getISashWindowsContainer() {
@@ -303,7 +341,7 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
}
/**
- * Get the {@link ISashWindowsContainer}.
+ * Get the {@link ISashWindowsContainer}.
* Note the the ISashWindowsContainer can also be acuired with getAdapter(ISashWindowsContainer.class).
*/
public SashWindowsContainer getSashWindowsContainer() {
@@ -324,18 +362,19 @@ public class FakeMultiSashPageEditor extends EditorPart implements IMultiEditorM
* (non-Javadoc)
* Method declared on IEditorPart.
*/
+ @Override
public boolean isSaveAsAllowed() {
return false;
}
@Override
public void doSave(IProgressMonitor monitor) {
-
+
}
@Override
public void doSaveAs() {
-
+
}
@Override
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditorTest.java b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditorTest.java
index db9ec1378e1..4e2f8f6cc39 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditorTest.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.sasheditor.tests/test/org/eclipse/papyrus/infra/core/sasheditor/tests/texteditor/FakeMultiSashPageEditorTest.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple.SimpleSashWindowsContentProvider;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -39,8 +40,8 @@ import org.junit.Test;
/**
* Tests for testing the {@link FakeMultiSashPageEditor} test editor.
*
- * @author Cedric dumoulin
- *
+ * @author Cedric dumoulin
+ *
*/
public class FakeMultiSashPageEditorTest {
@@ -56,23 +57,28 @@ public class FakeMultiSashPageEditorTest {
*/
@After
public void tearDown() throws Exception {
-
- // Close all remaining opened editors
- IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- page.closeAllEditors(false);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // Close all remaining opened editors
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ page.closeAllEditors(false);
+ }
+ });
}
/**
- * Test openEditor with a provided provider.
- * @throws Exception
+ * Test openEditor with a provided provider.
+ *
+ * @throws Exception
*/
@Test
public void testOpenEditor_contentProvider() throws Exception {
-
+
// Create a content provider
SimpleSashWindowsContentProvider contentProvider = new SimpleSashWindowsContentProvider();
-
+
// Create pages and add them to the default folder
List<IPageModel> models = new ArrayList<IPageModel>();
for(int i = 0; i < 3; i++) {
@@ -80,33 +86,34 @@ public class FakeMultiSashPageEditorTest {
contentProvider.addPage(newModel);
models.add(newModel);
}
-
+
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor(contentProvider);
-
+
assertNotNull("Editor is created", editor);
- assertSame( "ContentProvider is set", contentProvider, editor.getContentProvider());
-
+ assertSame("ContentProvider is set", contentProvider, editor.getContentProvider());
+
// Check nested editor types
IEditorPart nestedEditor = editor.getActiveEditor();
assertTrue("nested editor is of right type", (nestedEditor instanceof TestTextEditor));
-
+
FakeMultiSashPageEditor.closeEditor(editor);
}
/**
- * Test openEditor with a provided provider.
- * @throws Exception
+ * Test openEditor with a provided provider.
+ *
+ * @throws Exception
*/
@Test
public void testOpenEditor() throws Exception {
-
+
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor();
-
+
assertNotNull("Editor is created", editor);
- assertNotNull( "ContentProvider is set", editor.getContentProvider());
+ assertNotNull("ContentProvider is set", editor.getContentProvider());
IEditorPart activeEditor = editor.getActiveEditor();
assertNotNull("Active editor set", activeEditor);
-
+
// Check nested editor types
IEditorPart nestedEditor = editor.getActiveEditor();
assertEquals("nested editor is of right type", TestTextEditor.class, nestedEditor.getClass());
@@ -115,21 +122,22 @@ public class FakeMultiSashPageEditorTest {
}
/**
- * Test openEditor with a provided provider.
- * @throws Exception
+ * Test openEditor with a provided provider.
+ *
+ * @throws Exception
*/
@Test
public void testOpenEditor_nestedEditorCount() throws Exception {
-
+
int nestedEditorCount = 4;
-
+
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor(nestedEditorCount);
-
+
assertNotNull("Editor is created", editor);
- assertNotNull( "ContentProvider is set", editor.getContentProvider());
+ assertNotNull("ContentProvider is set", editor.getContentProvider());
IEditorPart activeEditor = editor.getActiveEditor();
assertNotNull("Active editor set", activeEditor);
-
+
// Check nested editor types
IEditorPart nestedEditor = editor.getActiveEditor();
assertEquals("nested editor is of right type", TestTextEditor.class, nestedEditor.getClass());
@@ -138,19 +146,20 @@ public class FakeMultiSashPageEditorTest {
}
/**
- * Test openEditor with a provided provider.
- * @throws Exception
+ * Test openEditor with a provided provider.
+ *
+ * @throws Exception
*/
@Test
public void testCloseEditor() throws Exception {
-
+
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor();
-
+
assertNotNull("Editor is created", editor);
- assertNotNull( "ContentProvider is set", editor.getContentProvider());
+ assertNotNull("ContentProvider is set", editor.getContentProvider());
IEditorPart activeEditor = editor.getActiveEditor();
assertNotNull("Active editor set", activeEditor);
-
+
// Check nested editor types
IEditorPart nestedEditor = editor.getActiveEditor();
assertEquals("nested editor is of right type", TestTextEditor.class, nestedEditor.getClass());
@@ -160,90 +169,93 @@ public class FakeMultiSashPageEditorTest {
/**
* Test method for {@link org.eclipse.papyrus.infra.core.sasheditor.tests.texteditor.FakeMultiSashPageEditor#getActiveEditor()}.
- * @throws PartInitException
+ *
+ * @throws PartInitException
*/
@Test
public void testGetSashContainer() throws PartInitException {
FakeMultiSashPageEditor editor = FakeMultiSashPageEditor.openEditor();
-
+
assertNotNull("Container is set", editor.getSashWindowsContainer());
-
+
FakeMultiSashPageEditor.closeEditor(editor);
}
/**
* Check if we can start several {@link FakeMultiSashPageEditor} in the same time
- * @throws PartInitException
+ *
+ * @throws PartInitException
*/
@Test
public void testStartMultipleFakeEditors() throws PartInitException {
-
-
+
+
FakeMultiSashPageEditor editor1 = FakeMultiSashPageEditor.openEditor(2);
FakeMultiSashPageEditor editor2 = FakeMultiSashPageEditor.openEditor(2);
FakeMultiSashPageEditor editor3 = FakeMultiSashPageEditor.openEditor(2);
-
+
assertNotSame("got different editors", editor1, editor2);
assertNotSame("got different editors", editor1, editor3);
assertNotSame("got different editors", editor2, editor3);
-
+
FakeMultiSashPageEditor.closeEditor(editor1);
FakeMultiSashPageEditor.closeEditor(editor2);
FakeMultiSashPageEditor.closeEditor(editor3);
-
+
}
/**
* Check if we can start several {@link FakeMultiSashPageEditor} in the same time
- * @throws PartInitException
+ *
+ * @throws PartInitException
*/
@Test
public void testStartMultipleFakeEditorsOneByOne() throws PartInitException {
-
-
+
+
FakeMultiSashPageEditor editor1 = FakeMultiSashPageEditor.openEditor();
FakeMultiSashPageEditor.closeEditor(editor1);
-
+
FakeMultiSashPageEditor editor2 = FakeMultiSashPageEditor.openEditor();
assertNotSame("got different editors", editor1, editor2);
FakeMultiSashPageEditor.closeEditor(editor2);
-
-
+
+
FakeMultiSashPageEditor editor3 = FakeMultiSashPageEditor.openEditor();
-
+
assertNotSame("got different editors", editor1, editor3);
assertNotSame("got different editors", editor2, editor3);
-
+
FakeMultiSashPageEditor.closeEditor(editor3);
}
/**
- * Check if we can start several {@link FakeMultiSashPageEditor} in the same time. Here
+ * Check if we can start several {@link FakeMultiSashPageEditor} in the same time. Here
* editors are closed by calling editor.dispose().
- * This test succeed, but exception are outputted because the dispose() on editor doesn't
+ * This test succeed, but exception are outputted because the dispose() on editor doesn't
* fried the editors from workbench.
*
- * @throws PartInitException
+ * @throws PartInitException
*/
@Test
- @Ignore
+ @Ignore
public void testStartMultipleFakeEditorsOneByOneAndDispose() throws PartInitException {
-
-
+
+
FakeMultiSashPageEditor editor1 = FakeMultiSashPageEditor.openEditor();
- editor1.dispose();
-
+ editor1.dispose();
+
FakeMultiSashPageEditor editor2 = FakeMultiSashPageEditor.openEditor();
assertNotSame("got different editors", editor1, editor2);
- editor2.dispose();
-
-
+ editor2.dispose();
+
+
FakeMultiSashPageEditor editor3 = FakeMultiSashPageEditor.openEditor();
-
+
assertNotSame("got different editors", editor1, editor3);
assertNotSame("got different editors", editor2, editor3);
-
- editor3.dispose();
+
+ editor3.dispose();
}
}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF
index 5e5d5f52242..c4b1e481a9b 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit;bundle-version="4.8.1",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.0",
org.eclipse.papyrus.infra.services.resourceloading;bundle-version="0.10.0",
org.eclipse.papyrus.uml.service.types;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/customization/org.eclipse.papyrus.customization.properties.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/customization/org.eclipse.papyrus.customization.properties.tests/META-INF/MANIFEST.MF
index bd7b9e98974..7aae5bffcc7 100644
--- a/tests/junit/plugins/customization/org.eclipse.papyrus.customization.properties.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/customization/org.eclipse.papyrus.customization.properties.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.papyrus.customization.properties.model.xwt;bundle-version="0.10.0",
org.eclipse.papyrus.customization.properties.generation;bundle-version="0.10.0",
- org.junit4;bundle-version="4.8.1",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.emf.ecore;bundle-version="2.8.0",
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
org.eclipse.papyrus.views.properties;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF
index c30ae2367aa..57d3bae39af 100644
--- a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.pde.runtime
Export-Package: org.eclipse.papyrus.bundles.tests
Bundle-Vendor: %Bundle-Vendor
diff --git a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
index aebf03a0bea..e285e6f3f20 100644
--- a/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/emf/org.eclipse.papyrus.infra.emf.tests/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.infra.emf.utils
-Require-Bundle: org.junit,
+Require-Bundle: org.junit4,
org.eclipse.emf.ecore.xmi;bundle-version="2.8.0"
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.infra.emf;bundle-version="0.10.0"
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF
index 582c18ce41c..ae514a79456 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.2",
+Require-Bundle: org.junit4;bundle-version="4.0.0",
org.eclipse.ui.ide;bundle-version="3.8.0"
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.infra.services.edit;bundle-version=
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java
index 649e3559463..902cddcf37d 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/AbstractTestElementEditService.java
@@ -8,6 +8,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gmf.runtime.emf.type.core.ClientContextManager;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
@@ -17,11 +18,14 @@ import org.eclipse.papyrus.infra.services.edit.Activator;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditServiceProvider;
import org.eclipse.papyrus.infra.services.edit.tests.edit.helper.EPackageEditHelper;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -38,36 +42,43 @@ public abstract class AbstractTestElementEditService {
protected IElementEditServiceProvider service;
+ protected static IEditorPart editor;
+
@BeforeClass
public static void openPapyrusWithAnEmptyProject() throws Exception {
+ // Prepare new project for tests
+ IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
+ if(!testProject.exists()) {
+ testProject.create(new NullProgressMonitor());
+ }
+ if(!testProject.isOpen()) {
+ testProject.open(new NullProgressMonitor());
+ }
- try {
- // Prepare new project for tests
- IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
- if(!testProject.exists()) {
- testProject.create(new NullProgressMonitor());
- }
- if(!testProject.isOpen()) {
- testProject.open(new NullProgressMonitor());
+ // Copy EmptyModel from bundle to the test project
+ final IFile emptyModel_di = testProject.getFile("EmptyModel.di");
+ IFile emptyModel_no = testProject.getFile("EmptyModel.notation");
+ IFile emptyModel_uml = testProject.getFile("EmptyModel.uml");
+
+ emptyModel_di.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.di").openStream(), true, new NullProgressMonitor());
+ emptyModel_no.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.notation").openStream(), true, new NullProgressMonitor());
+ emptyModel_uml.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.uml").openStream(), true, new NullProgressMonitor());
+
+ // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(emptyModel_di.getName());
+ try {
+ editor = page.openEditor(new FileEditorInput(emptyModel_di), desc.getId());
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
}
+ });
- // Copy EmptyModel from bundle to the test project
- IFile emptyModel_di = testProject.getFile("EmptyModel.di");
- IFile emptyModel_no = testProject.getFile("EmptyModel.notation");
- IFile emptyModel_uml = testProject.getFile("EmptyModel.uml");
-
- emptyModel_di.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.di").openStream(), true, new NullProgressMonitor());
- emptyModel_no.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.notation").openStream(), true, new NullProgressMonitor());
- emptyModel_uml.create(Activator.getDefault().getBundle().getResource("/model/EmptyModel.uml").openStream(), true, new NullProgressMonitor());
-
- // Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(emptyModel_di.getName());
- page.openEditor(new FileEditorInput(emptyModel_di), desc.getId());
-
- } catch (Exception e) {
- fail("Papyrus initialization failed (" + e.getMessage() + ")."); // $NON-NLS-1$
- }
+ Assert.assertNotNull(editor);
}
@Before
@@ -88,11 +99,17 @@ public abstract class AbstractTestElementEditService {
@AfterClass
public static void closePapyrusAndCleanProject() {
+ RunnableWithResult<Boolean> closeEditorsRunnable;
+ Display.getDefault().syncExec(closeEditorsRunnable = new RunnableWithResult.Impl<Boolean>() {
+
+ public void run() {
+ setResult(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false));
+ }
+ });
+ editor = null;
+
// Close all editors
- boolean closed = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
- if(!closed) {
- fail("Could not close editors correctly.");
- }
+ Assert.assertTrue("Could not close editors correctly.", closeEditorsRunnable.getResult());
// Delete test project
IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java
index 13c5fc5f26a..2ce2df43f6b 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureCommandFactory.java
@@ -1,7 +1,6 @@
package org.eclipse.papyrus.infra.services.edit.tests.commands;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -15,7 +14,6 @@ import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.services.edit.commands.ConfigureFeatureCommandFactory;
import org.eclipse.papyrus.infra.services.edit.commands.IConfigureCommandFactory;
import org.eclipse.papyrus.infra.services.edit.internal.ElementEditService;
@@ -46,28 +44,20 @@ public class TestConfigureFeatureCommandFactory extends AbstractTestElementEditS
}
@Test
- public void testGetEditCommand() {
- try {
+ public void testGetEditCommand() throws ServiceException, ExecutionException {
+ ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
- ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
-
- // Try to execute command and make quick result verification.
- assertTrue("The service command should be executable.", correctCommand.canExecute());
- correctCommand.execute(new NullProgressMonitor(), null);
- assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
- assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
-
- } catch (ServiceException e) {
- fail("Test aborted - Papyrus editing domain not found.");
- } catch (ExecutionException e) {
- fail("Test aborted - Command execution failed.");
- }
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", correctCommand.canExecute());
+ correctCommand.execute(new NullProgressMonitor(), null);
+ assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
+ assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
}
/** Prepare a creation request (create a EPackage in an EPackage) and adds a ConfigureFeatureCommand */
@SuppressWarnings("unchecked")
private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
- TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
IEditCommandRequest request = new CreateElementRequest(editingDomain, ePckg, ePackgType);
// Create a configure command factory and add it to the request
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java
index 5941ac1caa4..f13301bca66 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/commands/TestConfigureFeatureListCommandFactory.java
@@ -50,29 +50,21 @@ public class TestConfigureFeatureListCommandFactory extends AbstractTestElementE
}
@Test
- public void testGetEditCommand() {
- try {
-
- ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
-
- // Try to execute command and make quick result verification.
- assertTrue("The service command should be executable.", correctCommand.canExecute());
- correctCommand.execute(new NullProgressMonitor(), null);
- assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
- assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
- assertTrue("The service configure command result is incorrect.", "ASpecificNsURI".equals(ePckg.getESubpackages().get(0).getNsURI()));
-
- } catch (ServiceException e) {
- fail("Test aborted - Papyrus editing domain not found.");
- } catch (ExecutionException e) {
- fail("Test aborted - Command execution failed.");
- }
+ public void testGetEditCommand() throws ServiceException, ExecutionException {
+ ICommand correctCommand = ePckgService.getEditCommand(prepareCorrectRequest());
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", correctCommand.canExecute());
+ correctCommand.execute(new NullProgressMonitor(), null);
+ assertTrue("The service command result is incorrect.", !ePckg.getESubpackages().isEmpty());
+ assertTrue("The service configure command result is incorrect.", "ASpecificName".equals(ePckg.getESubpackages().get(0).getName()));
+ assertTrue("The service configure command result is incorrect.", "ASpecificNsURI".equals(ePckg.getESubpackages().get(0).getNsURI()));
}
/** Prepare a creation request (create a EPackage in an EPackage) and adds a ConfigureFeatureCommand */
@SuppressWarnings("unchecked")
private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
- TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
IEditCommandRequest request = new CreateElementRequest(editingDomain, ePckg, ePackgType);
// Create a configure command factory and add it to the request
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java
index 0148f812859..236d9133dd4 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/service/TestElementEditService.java
@@ -17,7 +17,6 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.services.edit.internal.ElementEditService;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
@@ -83,8 +82,10 @@ public class TestElementEditService extends AbstractTestElementEditService {
assertFalse("The service command should not be executable.", incorrectCommand.canExecute());
} catch (ServiceException e) {
+ e.printStackTrace(System.out);
fail("Test aborted - Papyrus editing domain not found.");
} catch (ExecutionException e) {
+ e.printStackTrace(System.out);
fail("Test aborted - Command execution failed.");
}
}
@@ -103,13 +104,13 @@ public class TestElementEditService extends AbstractTestElementEditService {
/** Correct creation request (create a EPackage in an EPackage) */
private IEditCommandRequest prepareCorrectRequest() throws ServiceException {
- TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
return new CreateElementRequest(editingDomain, ePckg, ePackgType);
}
/** Incorrect creation request (create a EClass in an EPackage) */
private IEditCommandRequest prepareIncorrectRequest() throws ServiceException {
- TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
return new CreateElementRequest(editingDomain, eClass, ePackgType);
}
}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java
index 6062e867bb7..f215cd475f9 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/utils/TestGMFCommandUtils.java
@@ -1,7 +1,6 @@
package org.eclipse.papyrus.infra.services.edit.tests.utils;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -12,10 +11,10 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.tests.AbstractTestElementEditService;
import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils;
+import org.junit.Assert;
import org.junit.Test;
/**
@@ -24,33 +23,22 @@ import org.junit.Test;
public class TestGMFCommandUtils extends AbstractTestElementEditService {
@Test
- public void testGetCommandEObjectResult() {
-
- try {
-
- TransactionalEditingDomain editingDomain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
-
- // Prepare and execute a command that adds a sub-EPackage
- EPackage ePckg = EcoreFactory.eINSTANCE.createEPackage();
- CreateElementRequest req = new CreateElementRequest(editingDomain, ePckg, ePackgType);
- ICommand createCommand = ElementEditServiceUtils.getCommandProvider(ePckg).getEditCommand(req);
-
- // Try to execute command and make quick result verification.
- assertTrue("The service command should be executable.", createCommand.canExecute());
- createCommand.execute(new NullProgressMonitor(), null);
-
- // Inspect the result (should be a new EObject)
- EObject eObject = GMFCommandUtils.getCommandEObjectResult(createCommand);
- assertTrue("Could not get new element from command.", eObject != null);
- assertTrue("New element from command should be an EPackage.", eObject instanceof EPackage);
-
- } catch (ServiceException e) {
- fail("Test aborted - Service exception.");
-
- } catch (ExecutionException e) {
- fail("Test aborted - Command execution failed.");
- }
-
+ public void testGetCommandEObjectResult() throws ServiceException, ExecutionException {
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
+
+ // Prepare and execute a command that adds a sub-EPackage
+ EPackage ePckg = EcoreFactory.eINSTANCE.createEPackage();
+ CreateElementRequest req = new CreateElementRequest(editingDomain, ePckg, ePackgType);
+ ICommand createCommand = ElementEditServiceUtils.getCommandProvider(ePckg).getEditCommand(req);
+
+ // Try to execute command and make quick result verification.
+ assertTrue("The service command should be executable.", createCommand.canExecute());
+ createCommand.execute(new NullProgressMonitor(), null);
+
+ // Inspect the result (should be a new EObject)
+ EObject eObject = GMFCommandUtils.getCommandEObjectResult(createCommand);
+ Assert.assertNotNull("Could not get new element from command.", eObject);
+ assertTrue("New element from command should be an EPackage.", eObject instanceof EPackage);
}
}
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider.tests/META-INF/MANIFEST.MF
index 171b1ef5b51..95a3f195707 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.labelprovider.tests/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.papyrus.infra.services.labelprovider.tests.Activat
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit;bundle-version="4.10.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/META-INF/MANIFEST.MF b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/META-INF/MANIFEST.MF
index 9e5e8f31c21..f8a2129c2d4 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.8.0",
org.eclipse.jdt.ui,
- org.junit;bundle-version="4.8.2",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.views.modelexplorer;bundle-version="0.10.0",
org.eclipse.ui.navigator,
org.eclipse.ui.views.properties.tabbed,
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/META-INF/MANIFEST.MF
index 635d238340b..4013cd34879 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit
+Require-Bundle: org.junit4
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.sysml.diagram.blockdefinition;bundl
e-version="0.10.0"
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
index 357cec9a968..3079d38d75a 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/AbstractTest.java
@@ -13,11 +13,14 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.blockdefinition.tests;
+import static org.junit.Assert.assertNotNull;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.Activator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@@ -34,13 +37,20 @@ public abstract class AbstractTest {
public static boolean isInitialized = false;
public static IEditorPart editor = null;
-
+
public static String editorID = "org.eclipse.papyrus.infra.core.papyrusEditor";
@BeforeClass
public static void openPapyrusWithAnEmptyProject() throws Exception {
- IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ Runnable closeIntroRunnable = new Runnable() {
+
+ public void run() {
+ IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
+ PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
+ }
+ };
+ PlatformUI.getWorkbench().getDisplay().syncExec(closeIntroRunnable);
+
// Prepare new project for tests
IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
if(!testProject.exists()) {
@@ -52,7 +62,7 @@ public abstract class AbstractTest {
}
// Copy EmptyModel from bundle to the test project
- IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
+ final IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
IFile emptyModel_no = testProject.getFile("ModelWithBDD.notation");
IFile emptyModel_uml = testProject.getFile("ModelWithBDD.uml");
@@ -64,16 +74,34 @@ public abstract class AbstractTest {
emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.notation").openStream(), true, new NullProgressMonitor());
emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithBDD.uml").openStream(), true, new NullProgressMonitor());
}
-
+
// Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+ Runnable openEditorRunnable = new Runnable() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ };
+
+ Display.getDefault().syncExec(openEditorRunnable);
+ assertNotNull("Failed to open an Editor", editor);
}
@AfterClass
public static void closePapyrusAndCleanProject() throws Exception {
// Close the editor without saving content created during tests
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- page.closeEditor(editor, false);
+ Runnable closeEditorRunnable = new Runnable() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeEditor(editor, false);
+ }
+ };
+ Display.getDefault().syncExec(closeEditorRunnable);
}
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/EditorUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/EditorUtils.java
index 980d71d85f6..3cdb75c9760 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/EditorUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/EditorUtils.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.sysml.diagram.blockdefinition.tests.utils;
import java.util.Iterator;
import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Tool;
@@ -30,6 +31,7 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.BlockDefinitionDiagramForMultiEditor;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.factory.DiagramPaletteFactory;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
@@ -120,7 +122,7 @@ public class EditorUtils {
ServicesRegistry serviceRegistry = (ServicesRegistry)getEditor().getAdapter(ServicesRegistry.class);
try {
- return (TransactionalEditingDomain)ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+ return ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
} catch (ServiceException e) {
throw new Exception("Unable to retrieve service.", e);
@@ -128,7 +130,14 @@ public class EditorUtils {
}
public static IEditorPart getEditor() throws Exception {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ RunnableWithResult<IEditorPart> getEditorRunnable = new RunnableWithResult.Impl<IEditorPart>() {
+
+ public void run() {
+ setResult(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor());
+ }
+ };
+ Display.getDefault().syncExec(getEditorRunnable);
+ return getEditorRunnable.getResult();
}
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/TestUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/TestUtils.java
index e32a4e65311..a9eca5f678e 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/TestUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition.tests/src/org/eclipse/papyrus/sysml/diagram/blockdefinition/tests/utils/TestUtils.java
@@ -51,6 +51,7 @@ import org.eclipse.papyrus.sysml.diagram.blockdefinition.Activator;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -221,16 +222,35 @@ public class TestUtils {
public static Request getCreateRequest(Tool tool) throws Exception {
if(tool instanceof AspectUnspecifiedTypeCreationTool) {
- AspectUnspecifiedTypeCreationTool creationTool = (AspectUnspecifiedTypeCreationTool)tool;
+ final AspectUnspecifiedTypeCreationTool creationTool = (AspectUnspecifiedTypeCreationTool)tool;
// Don't forget to set the diagram viewer (required for preferenceHints to mimic manual creation)
- creationTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ creationTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
return creationTool.createCreateRequest();
} else if(tool instanceof AspectUnspecifiedTypeConnectionTool) {
- AspectUnspecifiedTypeConnectionTool connectionTool = (AspectUnspecifiedTypeConnectionTool)tool;
+ final AspectUnspecifiedTypeConnectionTool connectionTool = (AspectUnspecifiedTypeConnectionTool)tool;
+
// Don't forget to set the diagram viewer (required for preferenceHints to mimic manual creation)
- connectionTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ connectionTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
return connectionTool.new CreateAspectUnspecifiedTypeConnectionRequest(connectionTool.getElementTypes(), false, Activator.DIAGRAM_PREFERENCES_HINT);
}
@@ -457,28 +477,30 @@ public class TestUtils {
};
history.addOperationHistoryListener(historyChange);
- // Test execution
- historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().execute(command);
- if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
- fail("Command execution failed ()");
- }
+ try {
+ // Test execution
+ historyEventType = OperationHistoryEvent.DONE;
+ EditorUtils.getDiagramCommandStack().execute(command);
+ if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
+ fail("Command execution failed ()");
+ }
- // Test undo
- historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().undo();
- if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
- fail("Command undo failed ()");
- }
+ // Test undo
+ historyEventType = OperationHistoryEvent.DONE;
+ EditorUtils.getDiagramCommandStack().undo();
+ if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
+ fail("Command undo failed ()");
+ }
- // Test redo
- historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().redo();
- if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
- fail("Command redo failed ()");
+ // Test redo
+ historyEventType = OperationHistoryEvent.DONE;
+ EditorUtils.getDiagramCommandStack().redo();
+ if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
+ fail("Command redo failed ()");
+ }
+ } finally {
+ // Remove listener, even when the test has failed.
+ history.removeOperationHistoryListener(historyChange);
}
-
- // Remove listener.
- history.removeOperationHistoryListener(historyChange);
}
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/META-INF/MANIFEST.MF
index 419d47cdf2d..3122c86773d 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit,
+Require-Bundle: org.junit4,
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0"
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.sysml.diagram.internalblock;bundle-
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
index e6fa1215db2..3b64759234b 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/AbstractTest.java
@@ -18,12 +18,13 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.papyrus.sysml.diagram.internalblock.Activator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.part.FileEditorInput;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
/**
@@ -34,13 +35,11 @@ public abstract class AbstractTest {
public static boolean isInitialized = false;
public static IEditorPart editor = null;
-
+
public static String editorID = "org.eclipse.papyrus.infra.core.papyrusEditor";
@BeforeClass
public static void openPapyrusWithAnEmptyProject() throws Exception {
- IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
// Prepare new project for tests
IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestProject");
if(!testProject.exists()) {
@@ -52,7 +51,7 @@ public abstract class AbstractTest {
}
// Copy EmptyModel from bundle to the test project
- IFile emptyModel_di = testProject.getFile("ModelWithIBD.di");
+ final IFile emptyModel_di = testProject.getFile("ModelWithIBD.di");
IFile emptyModel_no = testProject.getFile("ModelWithIBD.notation");
IFile emptyModel_uml = testProject.getFile("ModelWithIBD.uml");
@@ -62,16 +61,33 @@ public abstract class AbstractTest {
emptyModel_no.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.notation").openStream(), true, new NullProgressMonitor());
emptyModel_uml.create(Activator.getInstance().getBundle().getResource("/model/ModelWithIBD.uml").openStream(), true, new NullProgressMonitor());
}
-
+
// Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
+
+ Assert.assertNotNull("Failed to open the editor", editor);
}
@AfterClass
public static void closePapyrusAndCleanProject() throws Exception {
- // Close the editor without saving content created during tests
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- page.closeEditor(editor, false);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // Close the editor without saving content created during tests
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeEditor(editor, false);
+ }
+ });
+ editor = null;
}
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/EditorUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/EditorUtils.java
index 4f0c40314f2..9d6187a9bce 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/EditorUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/EditorUtils.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.tests.utils;
import java.util.Iterator;
import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Tool;
@@ -30,6 +31,7 @@ import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.sysml.diagram.internalblock.InternalBlockDiagramForMultiEditor;
import org.eclipse.papyrus.sysml.diagram.internalblock.factory.DiagramPaletteFactory;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
@@ -95,7 +97,7 @@ public class EditorUtils {
return editPart;
}
}
-
+
throw new Exception("Unable to find edit part for the given view.");
}
@@ -111,24 +113,31 @@ public class EditorUtils {
public static DiagramCommandStack getDiagramCommandStack() throws Exception {
return getDiagramEditingDomain().getDiagramCommandStack();
}
-
+
public static CommandStack getCommandStack() throws Exception {
return getTransactionalEditingDomain().getCommandStack();
}
-
+
public static TransactionalEditingDomain getTransactionalEditingDomain() throws Exception {
ServicesRegistry serviceRegistry = (ServicesRegistry)getEditor().getAdapter(ServicesRegistry.class);
try {
- return (TransactionalEditingDomain)ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+ return ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
} catch (ServiceException e) {
throw new Exception("Unable to retrieve service.", e);
}
}
-
+
public static IEditorPart getEditor() throws Exception {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ RunnableWithResult<IEditorPart> getEditorRunnable = new RunnableWithResult.Impl<IEditorPart>() {
+
+ public void run() {
+ setResult(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor());
+ }
+ };
+ Display.getDefault().syncExec(getEditorRunnable);
+ return getEditorRunnable.getResult();
}
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestPrepareUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestPrepareUtils.java
index 271a3f784ba..39b1a934263 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestPrepareUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestPrepareUtils.java
@@ -84,89 +84,90 @@ public class TestPrepareUtils {
CreateElementRequest createElementRequest = new CreateElementRequest(getTransactionalEditingDomain(), container, elementType);
EObject typeOwner = EMFCoreUtil.getContainer(container, UMLPackage.eINSTANCE.getPackage());
-
- if (elementType == SysMLElementTypes.ACTOR_PART_PROPERTY) {
+
+ if(elementType == SysMLElementTypes.ACTOR_PART_PROPERTY) {
// Create type
CreateElementRequest createTypeRequest = new CreateElementRequest(getTransactionalEditingDomain(), typeOwner, UMLElementTypes.ACTOR);
ICommand createTypeCommand = ElementEditServiceUtils.getCommandProvider(typeOwner).getEditCommand(createTypeRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createTypeCommand));
-
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
}
createElementRequest.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), GMFCommandUtils.getCommandEObjectResult(createTypeCommand)));
-
- } else if (elementType == SysMLElementTypes.PART_PROPERTY) {
+
+ } else if(elementType == SysMLElementTypes.PART_PROPERTY) {
// Create type
CreateElementRequest createTypeRequest = new CreateElementRequest(getTransactionalEditingDomain(), typeOwner, SysMLElementTypes.BLOCK);
ICommand createTypeCommand = ElementEditServiceUtils.getCommandProvider(typeOwner).getEditCommand(createTypeRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createTypeCommand));
-
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
}
createElementRequest.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), GMFCommandUtils.getCommandEObjectResult(createTypeCommand)));
-
- } else if (elementType == SysMLElementTypes.REFERENCE_PROPERTY) {
+
+ } else if(elementType == SysMLElementTypes.REFERENCE_PROPERTY) {
// Create type
CreateElementRequest createTypeRequest = new CreateElementRequest(getTransactionalEditingDomain(), typeOwner, SysMLElementTypes.BLOCK);
ICommand createTypeCommand = ElementEditServiceUtils.getCommandProvider(typeOwner).getEditCommand(createTypeRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createTypeCommand));
-
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
}
createElementRequest.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), GMFCommandUtils.getCommandEObjectResult(createTypeCommand)));
-
- } else if (elementType == SysMLElementTypes.VALUE_PROPERTY) {
+
+ } else if(elementType == SysMLElementTypes.VALUE_PROPERTY) {
// Create type
CreateElementRequest createTypeRequest = new CreateElementRequest(getTransactionalEditingDomain(), typeOwner, UMLElementTypes.DATA_TYPE);
ICommand createTypeCommand = ElementEditServiceUtils.getCommandProvider(typeOwner).getEditCommand(createTypeRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createTypeCommand));
-
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
}
createElementRequest.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), GMFCommandUtils.getCommandEObjectResult(createTypeCommand)));
-
- } else if (elementType == SysMLElementTypes.FLOW_PORT_NA) {
+
+ } else if(elementType == SysMLElementTypes.FLOW_PORT_NA) {
// Create type
CreateElementRequest createTypeRequest = new CreateElementRequest(getTransactionalEditingDomain(), typeOwner, SysMLElementTypes.FLOW_SPECIFICATION);
ICommand createTypeCommand = ElementEditServiceUtils.getCommandProvider(typeOwner).getEditCommand(createTypeRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createTypeCommand));
-
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
}
createElementRequest.getParameters().put(IConfigureCommandFactory.CONFIGURE_COMMAND_FACTORY_ID, new ConfigureFeatureCommandFactory(UMLPackage.eINSTANCE.getTypedElement_Type(), GMFCommandUtils.getCommandEObjectResult(createTypeCommand)));
-
- } else if (elementType == UMLElementTypes.PROPERTY) {
-
+
+ } else if(elementType == UMLElementTypes.PROPERTY) {
+
// If container is a Property, substitute container by the Property type
- if (container instanceof Property) {
- container = ((Property) container).getType();
+ if(container instanceof Property) {
+ container = ((Property)container).getType();
createElementRequest.setContainer(container);
- }
+ }
}
-
+
ICommand createElementCommand = ElementEditServiceUtils.getCommandProvider(container).getEditCommand(createElementRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createElementCommand));
-
+
return GMFCommandUtils.getCommandEObjectResult(createElementCommand);
}
public static void setBlockIsEncapsulated(final Element block, final boolean isEncapsulated) throws Exception {
AbstractTransactionalCommand setCommand = new AbstractTransactionalCommand(getTransactionalEditingDomain(), "Set Block isEncapsulated", null) {
+
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Block blockApp = UMLUtil.getStereotypeApplication(block, Block.class);
@@ -176,42 +177,42 @@ public class TestPrepareUtils {
};
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(setCommand));
}
-
+
public static EObject createLink(IElementType elementType, EObject source, EObject target) throws Exception {
CreateRelationshipRequest createRelationshipRequest = new CreateRelationshipRequest(getTransactionalEditingDomain(), source, target, elementType);
-
+
ICommand createRelationshipCommand = ElementEditServiceUtils.getCommandProvider(elementType).getEditCommand(createRelationshipRequest);
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createRelationshipCommand));
-
+
return GMFCommandUtils.getCommandEObjectResult(createRelationshipCommand);
}
-
+
public static EObject createConnectorLink(final EncapsulatedClassifier container, final ConnectableElement sourceRole, final Property sourcePartWithPort, final ConnectableElement targetRole, final Property targetPartWithPort) throws Exception {
-
+
AbstractTransactionalCommand createConnectorCommand = new AbstractTransactionalCommand(getTransactionalEditingDomain(), "Create connector", null) {
-
+
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Connector connector = container.createOwnedConnector("ConnectorTest");
-
+
ConnectorEnd connectorEndSrc = connector.createEnd();
connectorEndSrc.setRole(sourceRole);
connectorEndSrc.setPartWithPort(sourcePartWithPort);
-
+
ConnectorEnd connectorEndTgt = connector.createEnd();
connectorEndTgt.setRole(targetRole);
connectorEndTgt.setPartWithPort(targetPartWithPort);
-
+
return CommandResult.newOKCommandResult(connector);
}
-
+
};
getTransactionalEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(createConnectorCommand));
-
+
return GMFCommandUtils.getCommandEObjectResult(createConnectorCommand);
}
-
+
public static View createGraphicalNode(IElementType elementType, String graphicalType, View containerView) throws Exception {
EObject newObject = createElement(elementType, containerView);
@@ -222,11 +223,11 @@ public class TestPrepareUtils {
EReference[] erefs = new EReference[]{ NotationPackage.eINSTANCE.getView_Element() };
@SuppressWarnings("unchecked")
- Collection<View> views = (Collection<View>)EMFCoreUtil.getReferencers(newObject, erefs);
+ Collection<View> views = EMFCoreUtil.getReferencers(newObject, erefs);
return (View)views.toArray()[0];
}
-
+
public static View createGraphicalNode(IElementType elementType, EObject semanticContainer, String graphicalType, View containerView) throws Exception {
EObject newObject = createElement(elementType, semanticContainer);
@@ -238,11 +239,11 @@ public class TestPrepareUtils {
EReference[] erefs = new EReference[]{ NotationPackage.eINSTANCE.getView_Element() };
@SuppressWarnings("unchecked")
- Collection<View> views = (Collection<View>)EMFCoreUtil.getReferencers(newObject, erefs);
+ Collection<View> views = EMFCoreUtil.getReferencers(newObject, erefs);
return (View)views.toArray()[0];
}
-
+
public static View createGraphicalLink(IElementType elementType, String graphicalType, View containerView, EditPart sourceEP, EditPart targetEP) throws Exception {
CreateConnectionViewRequest request = createConnectionRequest(elementType, sourceEP, targetEP);
@@ -258,7 +259,7 @@ public class TestPrepareUtils {
return newView;
}
-
+
public static CreateConnectionViewRequest createConnectionRequest(IElementType type, EditPart source, EditPart target) {
CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, Activator.DIAGRAM_PREFERENCES_HINT);
@@ -275,7 +276,7 @@ public class TestPrepareUtils {
connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
return connectionRequest;
}
-
+
public static View dropFromModelExplorer(IElementType elementType, View containerView) throws Exception {
EObject newObject = createElement(elementType, containerView);
@@ -300,7 +301,7 @@ public class TestPrepareUtils {
EReference[] erefs = new EReference[]{ NotationPackage.eINSTANCE.getView_Element() };
@SuppressWarnings("unchecked")
- Collection<View> views = (Collection<View>)EMFCoreUtil.getReferencers(eObject, erefs);
+ Collection<View> views = EMFCoreUtil.getReferencers(eObject, erefs);
return (View)views.toArray()[0];
}
diff --git a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
index b9842e3f4d3..d29d2468998 100644
--- a/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
+++ b/tests/junit/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock.tests/src/org/eclipse/papyrus/sysml/diagram/internalblock/tests/utils/TestUtils.java
@@ -50,6 +50,7 @@ import org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalCo
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand;
import org.eclipse.gmf.runtime.diagram.ui.menus.PopupMenu;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
@@ -64,6 +65,7 @@ import org.eclipse.jface.commands.ActionHandler;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.SelectAndExecuteCommand;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
@@ -74,6 +76,7 @@ import org.eclipse.papyrus.sysml.diagram.internalblock.Activator;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
import org.eclipse.papyrus.uml.diagram.common.service.AspectUnspecifiedTypeCreationTool;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -285,18 +288,30 @@ public class TestUtils {
}
}
- public static Request getCreateRequest(Tool tool) throws Exception {
+ public static Request getCreateRequest(final Tool tool) throws Exception {
+
+ // Don't forget to set the diagram viewer (required for preferenceHints to mimic manual creation)
+ final IDiagramGraphicalViewer viewer = getDiagramEditor().getDiagramGraphicalViewer();
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ tool.setViewer(viewer);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
+
if(tool instanceof AspectUnspecifiedTypeCreationTool) {
AspectUnspecifiedTypeCreationTool creationTool = (AspectUnspecifiedTypeCreationTool)tool;
- // Don't forget to set the diagram viewer (required for preferenceHints to mimic manual creation)
- creationTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
return creationTool.createCreateRequest();
} else if(tool instanceof AspectUnspecifiedTypeConnectionTool) {
AspectUnspecifiedTypeConnectionTool connectionTool = (AspectUnspecifiedTypeConnectionTool)tool;
- // Don't forget to set the diagram viewer (required for preferenceHints to mimic manual creation)
- connectionTool.setViewer(getDiagramEditor().getDiagramGraphicalViewer());
return connectionTool.new CreateAspectUnspecifiedTypeConnectionRequest(connectionTool.getElementTypes(), false, Activator.DIAGRAM_PREFERENCES_HINT);
}
+
throw new Exception("Unexpected kind of creation tool.");
}
@@ -398,9 +413,9 @@ public class TestUtils {
} else {
Assert.assertNotNull("Nested connector end stereotype should be applied on source.", sourceNestedConnectorEnd);
Assert.assertEquals("Nested property path is incorrect for source", nestedSourcePath, sourceNestedConnectorEnd.getPropertyPath());
-// if(!sourceNestedConnectorEnd.getPropertyPath().equals(nestedSourcePath)) {
-// fail("The nested property path is incorrect for source.");
-// }
+ // if(!sourceNestedConnectorEnd.getPropertyPath().equals(nestedSourcePath)) {
+ // fail("The nested property path is incorrect for source.");
+ // }
}
// Test target connector end
NestedConnectorEnd targetNestedConnectorEnd = UMLUtil.getStereotypeApplication(connector.getEnds().get(1), NestedConnectorEnd.class);
@@ -409,9 +424,9 @@ public class TestUtils {
} else {
Assert.assertNotNull("Nested connector end stereotype should be applied on target.", targetNestedConnectorEnd);
Assert.assertEquals("Nested property path is incorrect for target", nestedTargetPath, targetNestedConnectorEnd.getPropertyPath());
-// if(!targetNestedConnectorEnd.getPropertyPath().equals(nestedTargetPath)) {
-// fail("The nested property path is incorrect for target.");
-// }
+ // if(!targetNestedConnectorEnd.getPropertyPath().equals(nestedTargetPath)) {
+ // fail("The nested property path is incorrect for target.");
+ // }
}
}
@@ -480,12 +495,12 @@ public class TestUtils {
public static void reorientConnectorSource(View relationshipView, View newSourceView, boolean isAllowed) throws Exception {
List<Property> nestedPath = Collections.emptyList();
- reorientConnectorSource((Connector)relationshipView, newSourceView, isAllowed, nestedPath);
+ reorientConnectorSource(relationshipView, newSourceView, isAllowed, nestedPath);
}
public static void reorientConnectorTarget(View relationshipView, View newTargetView, boolean isAllowed) throws Exception {
List<Property> nestedPath = Collections.emptyList();
- reorientConnectorTarget((Connector)relationshipView, newTargetView, isAllowed, nestedPath);
+ reorientConnectorTarget(relationshipView, newTargetView, isAllowed, nestedPath);
}
public static void reorientConnectorSource(View relationshipView, View newSourceView, boolean isAllowed, List<Property> nestedPath) throws Exception {
@@ -537,25 +552,25 @@ public class TestUtils {
if(reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) { // re-orient source
// Test source connector end
Assert.assertEquals("The partWithPort is incorrect for source (re-oriented).", expectedSourcePartWithPort, modifiedConnectorEnd.getPartWithPort());
-// if(modifiedConnectorEnd.getPartWithPort() != expectedSourcePartWithPort) {
-// fail("The partWithPort is incorrect for source (re-oriented).");
-// }
+ // if(modifiedConnectorEnd.getPartWithPort() != expectedSourcePartWithPort) {
+ // fail("The partWithPort is incorrect for source (re-oriented).");
+ // }
// Test target connector end
Assert.assertEquals("The partWithPort is incorrect for target (opposite end).", expectedTargetPartWithPort, oppositeConnectorEnd.getPartWithPort());
-// if(oppositeConnectorEnd.getPartWithPort() != expectedTargetPartWithPort) {
-// fail("The partWithPort is incorrect for target (opposite end).");
-// }
+ // if(oppositeConnectorEnd.getPartWithPort() != expectedTargetPartWithPort) {
+ // fail("The partWithPort is incorrect for target (opposite end).");
+ // }
} else { // re-orient target
// Test source connector end
Assert.assertEquals("The partWithPort is incorrect for target (re-oriented).", expectedTargetPartWithPort, modifiedConnectorEnd.getPartWithPort());
-// if(modifiedConnectorEnd.getPartWithPort() != expectedTargetPartWithPort) {
-// fail("The partWithPort is incorrect for target .");
-// }
+ // if(modifiedConnectorEnd.getPartWithPort() != expectedTargetPartWithPort) {
+ // fail("The partWithPort is incorrect for target .");
+ // }
// Test target connector end
Assert.assertEquals("The partWithPort is incorrect for source (opposite end).", expectedSourcePartWithPort, oppositeConnectorEnd.getPartWithPort());
-// if(oppositeConnectorEnd.getPartWithPort() != expectedSourcePartWithPort) {
-// fail("The partWithPort is incorrect for source (opposite end).");
-// }
+ // if(oppositeConnectorEnd.getPartWithPort() != expectedSourcePartWithPort) {
+ // fail("The partWithPort is incorrect for source (opposite end).");
+ // }
}
}
@@ -712,19 +727,19 @@ public class TestUtils {
history.addOperationHistoryListener(historyChange);
// Test execution
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().execute(command);
+ EditorUtils.getCommandStack().execute(new GEFtoEMFCommandWrapper(command));
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command execution failed ()");
}
// Test undo
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().undo();
+ EditorUtils.getCommandStack().undo();
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command undo failed ()");
}
// Test redo
historyEventType = OperationHistoryEvent.DONE;
- EditorUtils.getDiagramCommandStack().redo();
+ EditorUtils.getCommandStack().redo();
if(historyEventType == OperationHistoryEvent.OPERATION_NOT_OK) {
fail("Command redo failed ()");
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/META-INF/MANIFEST.MF
index 5a247211458..e91e0f69d4f 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit;bundle-version="4.8.2",
+Require-Bundle: org.junit4;bundle-version="4.0.0",
org.eclipse.core.expressions;bundle-version="3.4.300",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0"
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
index da0baf89035..ae1c576fe7b 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/common/AbstractModelExplorerTest.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.notation.Diagram;
@@ -47,11 +48,11 @@ import org.eclipse.papyrus.views.modelexplorer.matching.IMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.LinkItemMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.ModelElementItemMatchingItem;
import org.eclipse.papyrus.views.modelexplorer.matching.ReferencableMatchingItem;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.uml2.uml.Model;
@@ -115,9 +116,6 @@ public abstract class AbstractModelExplorerTest {
*/
@BeforeClass
public static void openPapyrusWithAnEmptyProject() throws Exception {
- System.out.println("openPapyrusWithAnEmptyProject");
- IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
// Prepare new project for tests
IProject testProject = ResourcesPlugin.getWorkspace().getRoot().getProject("TestCopyPasteProject");
if(!testProject.exists()) {
@@ -129,7 +127,7 @@ public abstract class AbstractModelExplorerTest {
}
// Copy EmptyModel from bundle to the test project
- IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
+ final IFile emptyModel_di = testProject.getFile("ModelWithBDD.di");
IFile emptyModel_no = testProject.getFile("ModelWithBDD.notation");
IFile emptyModel_uml = testProject.getFile("ModelWithBDD.uml");
@@ -143,10 +141,21 @@ public abstract class AbstractModelExplorerTest {
}
// Open the EmptyModel.di file with Papyrus (assumed to be the default editor for "di" files here).
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ editor = page.openEditor(new FileEditorInput(emptyModel_di), editorID);
+
+ modelExplorerPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ModelExplorerPageBookView.VIEW_ID);
+ modelExplorerPart.setFocus();
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
- modelExplorerPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ModelExplorerPageBookView.VIEW_ID);
Assert.assertNotNull("Model explorer is null", modelExplorerPart);
prepareTest();
@@ -212,8 +221,16 @@ public abstract class AbstractModelExplorerTest {
@AfterClass
public static void closePapyrusAndCleanProject() throws Exception {
// Close the editor without saving content created during tests
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- page.closeEditor(editor, false);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeEditor(editor, false);
+ }
+ });
+
+ editor = null;
+ modelExplorerPart = null;
}
@@ -225,8 +242,17 @@ public abstract class AbstractModelExplorerTest {
* @throws Exception
* exception thrown in case element could not be selected
*/
- public static void selectAndReveal(EObject object) throws Exception {
- selectAndReveal(Arrays.asList(object));
+ public static void selectAndReveal(final EObject object) throws Exception {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ selectAndReveal(Arrays.asList(object));
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
}
/**
@@ -263,7 +289,7 @@ public abstract class AbstractModelExplorerTest {
* the current editing domain
*/
protected TransactionalEditingDomain getEditingDomain() throws Exception {
- return org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ return (TransactionalEditingDomain)editor.getAdapter(TransactionalEditingDomain.class);
}
/**
@@ -274,7 +300,15 @@ public abstract class AbstractModelExplorerTest {
* exception thrown in case of problem (NPE, etc.)
*/
protected boolean isEditorDirty() throws Exception {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().isDirty();
+ RunnableWithResult<Boolean> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<Boolean>() {
+
+ public void run() {
+ setResult(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().isDirty());
+ }
+ });
+
+ return runnable.getResult();
}
/**
@@ -285,8 +319,17 @@ public abstract class AbstractModelExplorerTest {
* @throws Exception
* exception thrown in case element could not be selected
*/
- public static void selectAndRevealDiagram(Diagram object) throws Exception {
- selectAndRevealDiagram(Arrays.asList(object));
+ public static void selectAndRevealDiagram(final Diagram object) throws Exception {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ selectAndRevealDiagram(Arrays.asList(object));
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
}
/**
@@ -323,7 +366,7 @@ public abstract class AbstractModelExplorerTest {
* @param commonViewer
* The CommonViewer they are to be revealed in
*/
- public static void reveal(Iterable<Diagram> elementList, CommonViewer commonViewer) {
+ public static void reveal(final Iterable<Diagram> elementList, final CommonViewer commonViewer) {
ArrayList<IMatchingItem> matchingItemsToSelect = new ArrayList<IMatchingItem>();
// filter out non EMF objects
for(Diagram currentEObject : elementList) {
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
index 47774fa43e9..b47c7832246 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlock2Test.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -43,7 +44,12 @@ public class CopyPasteSimpleBlock2Test extends AbstractCopyPasteBlockTest {
public void testPrepare() throws Exception {
// check editor state (should be non dirty)
//FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
// retrieve elements in the model explorer
selectAndReveal(b1P1_P1_EObject);
@@ -61,7 +67,12 @@ public class CopyPasteSimpleBlock2Test extends AbstractCopyPasteBlockTest {
// NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
Assert.assertTrue("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
// END NOTE
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
index cf437c6e37b..5c212edeb2c 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleBlockTest.java
@@ -20,6 +20,8 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -43,12 +45,27 @@ public class CopyPasteSimpleBlockTest extends AbstractCopyPasteBlockTest {
public void testPrepare() throws Exception {
// check editor state (should be non dirty)
//FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
// retrieve elements in the model explorer
selectAndReveal(b1_EObject);
// copy Paste
- ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ RunnableWithResult<ICommandService> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<ICommandService>() {
+
+ public void run() {
+ ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
+ setResult(commandService);
+ }
+ });
+
+ ICommandService commandService = runnable.getResult();
+
commandService.refreshElements(IWorkbenchCommandConstants.EDIT_COPY, null);
org.eclipse.core.commands.Command copyCommand = commandService.getCommand(IWorkbenchCommandConstants.EDIT_COPY);
Assert.assertNotNull("Impossible to find copy command", copyCommand);
@@ -61,7 +78,13 @@ public class CopyPasteSimpleBlockTest extends AbstractCopyPasteBlockTest {
// NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
Assert.assertTrue("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+
Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
// END NOTE
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
index d5fe529e620..34f020c2250 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimplePartTest.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -43,7 +44,12 @@ public class CopyPasteSimplePartTest extends AbstractCopyPastePartTest {
public void testPrepare() throws Exception {
// check editor state (should be non dirty)
//FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
// retrieve elements in the model explorer
selectAndReveal(pB2_B1_EObject);
@@ -61,7 +67,12 @@ public class CopyPasteSimplePartTest extends AbstractCopyPastePartTest {
// NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
Assert.assertTrue("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
// END NOTE
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
index 2d5708b0d08..982bf214bf1 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test-gen/org/eclipse/papyrus/sysml/modelexplorer/tests/copypaste/CopyPasteSimpleReferenceTest.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
@@ -43,7 +44,13 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
public void testPrepare() throws Exception {
// check editor state (should be non dirty)
//FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+
Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty());
// retrieve elements in the model explorer
selectAndReveal(rB2_B1_EObject);
@@ -62,7 +69,13 @@ public class CopyPasteSimpleReferenceTest extends AbstractCopyPasteReferenceTest
// NOTE: save editor. The copy command should not dirty the model, the implementation of the copy command or the editor should be modified
Assert.assertFalse("Copy command is dirtying the model, whereas it should not. This assert is here to remember that the test code should be modified: Isdirty = false after copy...", isEditorDirty());
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+
Assert.assertFalse("Save command is non-dirtying the model, whereas it should. ", isEditorDirty());
// END NOTE
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
index 03cf6e0f5db..e8525c958c9 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/dragdrop/AbstractDragDropTest.java
@@ -34,6 +34,7 @@ import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
import org.eclipse.papyrus.views.modelexplorer.NavigatorUtils;
import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
import org.eclipse.ui.navigator.CommonDropAdapter;
@@ -56,7 +57,13 @@ public class AbstractDragDropTest extends AbstractModelExplorerTest {
public void testPrepare() throws Exception {
// check editor state (should be non dirty)
//FIXME: In Papyrus, the editor may be dirty at initialization. This should not be tested here. We simply save the editor as soon as it is opened.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+
Assert.assertFalse("Editor should not be dirty at initialization", isEditorDirty());
}
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
index 61a34f38353..b6ff508f5c3 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.modelexplorer.tests/test/org/eclipse/papyrus/sysml/modelexplorer/tests/utils/EditorUtils.java
@@ -12,11 +12,13 @@
*****************************************************************************/
package org.eclipse.papyrus.sysml.modelexplorer.tests.utils;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
@@ -34,7 +36,17 @@ public class EditorUtils {
* exception thrown in case of issue
*/
public static IEditorPart getEditor() throws Exception {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ RunnableWithResult<IEditorPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IEditorPart>() {
+
+ public void run() {
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ setResult(editor);
+ }
+ });
+
+ return runnable.getResult();
}
public static DiagramEditor getDiagramEditor() throws Exception {
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF
index 845b0dc88d0..c4eb38319f5 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.service.types.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit
+Require-Bundle: org.junit4
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.sysml.service.types;bundle-version=
"0.10.0"
diff --git a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/META-INF/MANIFEST.MF
index 742aa3db86c..809ffaa49d2 100644
--- a/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/sysml/org.eclipse.papyrus.sysml.tests/META-INF/MANIFEST.MF
@@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.uml2.uml;visibility:=reexport,
org.eclipse.emf.ecore.xmi;visibility:=reexport,
- org.junit;visibility:=reexport,
+ org.junit4;visibility:=reexport,
org.eclipse.uml2.uml.profile.l2;bundle-version="1.0.0",
org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.0"
Bundle-Vendor: %providerName
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
index c87903d92e9..194a5c8a46e 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/META-INF/MANIFEST.MF
@@ -6,7 +6,7 @@ Bundle-Version: 0.10.0.qualifier
Bundle-Activator: org.eclipse.papyrus.uml.diagram.activity.tests.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityAffixedChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityAffixedChildNode.java
index 181016f3a5c..dfe3eba47d7 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityAffixedChildNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestActivityAffixedChildNode.java
@@ -70,16 +70,16 @@ public class AbstractTestActivityAffixedChildNode extends AbstractPapyrusTestCas
CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, containerEditPart.getDiagramPreferencesHint());
Command command = containerEditPart.getCommand(requestcreation);
assertNotNull(CREATION + COMMAND_NULL, command);
- assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ assertNotSame(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command, UnexecutableCommand.INSTANCE);
+ assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
containerEditPart.refresh();
- assertTrue(CREATION + TEST_THE_EXECUTION, containerEditPart.getChildren().size() == subElementNumberGN + 2);
+ assertEquals(CREATION + TEST_THE_EXECUTION, containerEditPart.getChildren().size(), subElementNumberGN + 2);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(CREATION + TEST_THE_UNDO, containerEditPart.getChildren().size() == subElementNumberGN);//strange!!
- assertTrue(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 0);
+ assertEquals(CREATION + TEST_THE_UNDO, containerEditPart.getChildren().size(), subElementNumberGN);//strange!!
+ assertEquals(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size(), 0);
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue("CREATION: " + TEST_THE_REDO, containerEditPart.getChildren().size() == subElementNumberGN + 1);
+ assertEquals("CREATION: " + TEST_THE_REDO, containerEditPart.getChildren().size(), subElementNumberGN + 1);
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestCaseIntoStructureActivity.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestCaseIntoStructureActivity.java
index 0e871490574..9563ba1477d 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestCaseIntoStructureActivity.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity.tests/src/org/eclipse/papyrus/uml/diagram/activity/tests/canonical/AbstractTestCaseIntoStructureActivity.java
@@ -39,8 +39,7 @@ public abstract class AbstractTestCaseIntoStructureActivity extends TestChildNod
@Override
protected void setUp() throws Exception {
projectCreation();
-
- assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 1);
+ assertEquals(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size(), 1);
GraphicalEditPart containerEditPart = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
rootCompartment = null;
int index = 0;
@@ -56,10 +55,10 @@ public abstract class AbstractTestCaseIntoStructureActivity extends TestChildNod
requestcreation.setSize(new Dimension(500, 500));
Command command = rootCompartment.getCommand(requestcreation);
assertNotNull(CONTAINER_CREATION + COMMAND_NULL, command);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ assertNotSame(CONTAINER_CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command, UnexecutableCommand.INSTANCE);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(CREATION + INITIALIZATION_TEST, rootCompartment.getChildren().size() == 1);
+ assertEquals(CREATION + INITIALIZATION_TEST, rootCompartment.getChildren().size(), 1);
containerEditPart = (GraphicalEditPart)rootCompartment.getChildren().get(0);
rootCompartment = null;
index = 0;
@@ -72,5 +71,4 @@ public abstract class AbstractTestCaseIntoStructureActivity extends TestChildNod
}
-
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/META-INF/MANIFEST.MF
index b9370c79c58..a19d648c0d1 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
org.eclipse.ui,
org.eclipse.emf.ecore;bundle-version="2.8.0",
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/src/org/eclipse/papyrus/uml/diagram/dnd/tests/tests/InstanceSpecificationTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/src/org/eclipse/papyrus/uml/diagram/dnd/tests/tests/InstanceSpecificationTest.java
index c84d538c28e..853681ea1f8 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/src/org/eclipse/papyrus/uml/diagram/dnd/tests/tests/InstanceSpecificationTest.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.dnd.tests/src/org/eclipse/papyrus/uml/diagram/dnd/tests/tests/InstanceSpecificationTest.java
@@ -44,6 +44,7 @@ import org.eclipse.papyrus.infra.widgets.providers.TreeToFlatContentProvider;
import org.eclipse.papyrus.uml.diagram.dnd.strategy.instancespecification.ui.ClassifierPropertiesContentProvider;
import org.eclipse.papyrus.uml.diagram.dnd.tests.Activator;
import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@@ -113,13 +114,23 @@ public class InstanceSpecificationTest {
copyToWorkspace(sourceURL, targetFile);
}
- IFile modelFile = project.getFile(modelName + ".di");
+ final IFile modelFile = project.getFile(modelName + ".di");
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(modelFile.getName());
- papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(modelFile), desc.getId());
- diagram = (Diagram)papyrusEditor.getAdapter(Diagram.class);
- Assert.assertTrue("Cannot load the test diagram", diagram != null);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(modelFile.getName());
+ papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(modelFile), desc.getId());
+ diagram = (Diagram)papyrusEditor.getAdapter(Diagram.class);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
+
+ Assert.assertNotNull("Cannot load the test diagram", diagram);
}
protected static void copyToWorkspace(URL sourceURL, IFile targetFile) throws CoreException, IOException {
@@ -130,14 +141,20 @@ public class InstanceSpecificationTest {
}
@AfterClass
- public static void dispose() {
- papyrusEditor.getSite().getPage().closeEditor(papyrusEditor, false);
- for(IFile modelFile : model) {
- try {
- modelFile.delete(true, false, new NullProgressMonitor());
- } catch (CoreException ex) {
- Assert.fail("Cannot delete the model");
+ public static void dispose() throws Exception {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ papyrusEditor.getSite().getPage().closeEditor(papyrusEditor, false);
}
+ });
+
+ papyrusEditor = null;
+ diagram = null;
+ strategy = null;
+
+ for(IFile modelFile : model) {
+ modelFile.delete(true, false, new NullProgressMonitor());
}
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
index e2cb331d16a..0b9e3397681 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/META-INF/MANIFEST.MF
index 2a72bda5fee..a3a47c3a507 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestSpecificTopNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestSpecificTopNode.java
index bc3a4e8ec5f..598a19a3601 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestSpecificTopNode.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestSpecificTopNode.java
@@ -224,24 +224,24 @@ public abstract class TestSpecificTopNode extends org.eclipse.papyrus.diagram.te
public void testToCreateANode(IElementType type) {
//CREATION
- assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
- assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 0);
+ assertEquals(CREATION + INITIALIZATION_TEST, 0, getDiagramEditPart().getChildren().size());
+ assertEquals(CREATION + INITIALIZATION_TEST, 0, getRootSemanticModel().getOwnedElements().size());
ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(new CreateElementRequestAdapter(new CreateElementRequest(type)), Node.class, ((IHintedType)type).getSemanticHint(), getDiagramEditPart().getDiagramPreferencesHint());
CreateViewRequest requestcreation = new CreateViewAndElementRequest(viewDescriptor);
//CreateViewRequest requestcreation=CreateViewRequestFactory.getCreateShapeRequest(type, getDiagramEditPart().getDiagramPreferencesHint());
Command command = getDiagramEditPart().getCommand(requestcreation);
assertNotNull(CREATION + COMMAND_NULL, command);
- assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
- assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ assertNotSame(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, UnexecutableCommand.INSTANCE, command);
+ assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
- assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
+ assertEquals(CREATION + TEST_THE_EXECUTION, 1, getRootView().getChildren().size());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().undo();
- assertTrue(CREATION + TEST_THE_UNDO, getRootView().getChildren().size() == 0);
- assertTrue(CREATION + TEST_THE_UNDO, getRootSemanticModel().getOwnedElements().size() == 0);
+ assertEquals(CREATION + TEST_THE_UNDO, 0, getRootView().getChildren().size());
+ assertEquals(CREATION + TEST_THE_UNDO, 0, getRootSemanticModel().getOwnedElements().size());
diagramEditor.getDiagramEditDomain().getDiagramCommandStack().redo();
- assertTrue("CREATION: " + TEST_THE_REDO, getDiagramEditPart().getChildren().size() == 1);
+ assertEquals("CREATION: " + TEST_THE_REDO, 1, getDiagramEditPart().getChildren().size());
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestUseCaseLinkOwnedBySource.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestUseCaseLinkOwnedBySource.java
index 58c7210b14f..6e43f6f94ea 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestUseCaseLinkOwnedBySource.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase.tests/src/org/eclipse/papyrus/uml/diagram/usecase/tests/canonical/TestUseCaseLinkOwnedBySource.java
@@ -27,30 +27,35 @@ public class TestUseCaseLinkOwnedBySource extends TestLinkOwnedBySource {
@Override
protected ICreationCommand getDiagramCommandCreation() {
- return new CreateUseCaseDiagramCommand();
+ return new CreateUseCaseDiagramCommand();
}
-
+
/**
* Test to manage Association.
*/
@Test
public void testToManageGeneralization() {
- testToManageLink(UMLElementTypes.Actor_2011,UMLElementTypes.Actor_2011,UMLElementTypes.Generalization_4010,UMLElementTypes.Package_2016,true);
+ testToManageLink(UMLElementTypes.Actor_2011, UMLElementTypes.Actor_2011, UMLElementTypes.Generalization_4010, UMLElementTypes.Package_2016, true);
}
-
+
@Test
public void testToManagePackageMerge() {
- testToManageLink(UMLElementTypes.Package_2016,UMLElementTypes.Package_2016,UMLElementTypes.PackageMerge_4018,UMLElementTypes.Package_2016,true);
+ testToManageLink(UMLElementTypes.Package_2016, UMLElementTypes.Package_2016, UMLElementTypes.PackageMerge_4018, UMLElementTypes.Package_2016, true);
}
+
@Test
public void testToManagePackageImport() {
- testToManageLink(UMLElementTypes.Package_2016,UMLElementTypes.Package_2016,UMLElementTypes.PackageImport_4019,UMLElementTypes.Package_2016,true);
+ testToManageLink(UMLElementTypes.Package_2016, UMLElementTypes.Package_2016, UMLElementTypes.PackageImport_4019, UMLElementTypes.Package_2016, true);
}
+
+ @Test
public void testToManageExtend() {
- testToManageLink(UMLElementTypes.UseCase_2013,UMLElementTypes.UseCase_2013,UMLElementTypes.Extend_4009,UMLElementTypes.Package_2016,true);
+ testToManageLink(UMLElementTypes.UseCase_2013, UMLElementTypes.UseCase_2013, UMLElementTypes.Extend_4009, UMLElementTypes.Package_2016, true);
}
+
+ @Test
public void testToManageInclude() {
- testToManageLink(UMLElementTypes.UseCase_2013,UMLElementTypes.UseCase_2013,UMLElementTypes.Include_4008,UMLElementTypes.Package_2016,true);
+ testToManageLink(UMLElementTypes.UseCase_2013, UMLElementTypes.UseCase_2013, UMLElementTypes.Include_4008, UMLElementTypes.Package_2016, true);
}
-
+
}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
index 3fb6e98f1cb..09fa085ed1b 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.papyrus.views.modelexplorer.tests;bundle-version="0.10.0",
org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.0",
org.eclipse.emf.ecore,
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
- org.eclipse.papyrus.views.modelexplorer;bundle-version="0.10.0"
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="0.10.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0"
Export-Package: org.eclipse.papyrus.uml.modelexplorer.tests
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
index f2b9d0a9e9e..22b5f156e68 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/DeleteHandlerTest.java
@@ -13,23 +13,27 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.modelexplorer.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Model;
+import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -64,21 +68,34 @@ public class DeleteHandlerTest extends AbstractHandlerTest {
final List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(getRootOfTheModel());
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == getRootOfTheModel());
+ assertEquals(getRootOfTheModel(), obj);
final IHandler currentHandler = getActiveHandler();
if(currentHandler == null) {
// not a problem in this case
} else {
- Assert.isTrue(currentHandler.isEnabled() == false, "We can delete the root of the model. It is not the wanted behavior"); //$NON-NLS-1$
+ Assert.assertFalse("We can delete the root of the model. It is not the wanted behavior", currentHandler.isEnabled()); //$NON-NLS-1$
}
}
@@ -86,51 +103,56 @@ public class DeleteHandlerTest extends AbstractHandlerTest {
* We test if we can delete other uml elements
*/
@Test
- public void deleteUMLElementsTest() {
+ public void deleteUMLElementsTest() throws Exception {
testIsModelExplorerActivePart();
int size = ((Model)getRootOfTheModel()).getPackagedElements().size();
EObject elementToDelete;
while(((Model)getRootOfTheModel()).getPackagedElements().size() != 0) {
//we need to clean the selection
- getCommonViewer().setSelection(new StructuredSelection());
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ getCommonViewer().setSelection(new StructuredSelection());
+ }
+ });
+
IStructuredSelection currentSelection = getCurrentSelection();
elementToDelete = ((Model)getRootOfTheModel()).getPackagedElements().get(0);
List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(elementToDelete);
getModelExplorerView().revealSemanticElement(selectedElement);
currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected");
+ assertEquals("Only one element should be selected", 1, currentSelection.size());
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == elementToDelete);
+ Assert.assertEquals(elementToDelete, obj);
IHandler currentHandler = getActiveHandler();
- Assert.isTrue(currentHandler.isEnabled(), "We can't delete the following element" + elementToDelete);
- try {
- currentHandler.execute(new ExecutionEvent());
- } catch (ExecutionException e) {
- Assert.isTrue(false);
- }
+ Assert.assertTrue("We can't delete the following element" + elementToDelete, currentHandler.isEnabled());
+
+ currentHandler.execute(new ExecutionEvent());
int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.isTrue(newSize == (size - 1));
+ Assert.assertEquals(size - 1, newSize);
//We test the undo
- Assert.isTrue(getCommandStack().canUndo());
+ Assert.assertTrue(getCommandStack().canUndo());
getCommandStack().undo();
newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.isTrue(newSize == size);
+ Assert.assertEquals(size, newSize);
//we test the redo
- Assert.isTrue(getCommandStack().canRedo());
+ Assert.assertTrue(getCommandStack().canRedo());
getCommandStack().redo();
newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.isTrue(newSize == size - 1);
+ Assert.assertEquals(size - 1, newSize);
size = newSize;
}
+
int newSize = ((Model)getRootOfTheModel()).getPackagedElements().size();
- Assert.isTrue(newSize == 0);
+ Assert.assertEquals(0, newSize);
undoRedo(10);
}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
index 44a2840ea1a..fdc3d8e32ba 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/ModelExplorerViewTests.java
@@ -16,18 +16,20 @@ package org.eclipse.papyrus.uml.modelexplorer.tests;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
+import org.junit.Assert;
import org.junit.Test;
@@ -50,18 +52,27 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(getRootOfTheModel());
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == getRootOfTheModel(), "The function revealSemanticElement seems doesn't work on the root of the model");
+
+ Assert.assertEquals("The function revealSemanticElement seems doesn't work on the root of the model", getRootOfTheModel(), obj);
}
-
+
/**
* tests the method reveal semantic element selects the correct element
@@ -72,21 +83,33 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final Package pack = (Package)getRootOfTheModel();
final List<NamedElement> members = pack.getOwnedMembers();
final int size = members.size();
- Assert.isTrue(size != 0);//to be sure that the tested model is correct
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
for(NamedElement current : members) {
selectedElement.clear();
selectedElement.add(current);
- getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Assert.assertTrue("Only one element should be selected", currentSelection.size() == 1); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == current, "The function revealSemanticElement seems doesn't work with children");
+ Assert.assertTrue("The function revealSemanticElement seems doesn't work with children", obj == current);
}
}
@@ -99,14 +122,27 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final Package pack = (Package)getRootOfTheModel();
final List<NamedElement> members = pack.getOwnedMembers();
final int size = members.size();
- Assert.isTrue(size != 0);//to be sure that the tested model is correct
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
selectedElement.addAll(members);
- getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ getModelExplorerView().revealSemanticElement(selectedElement);
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final IWorkbenchPart activePart = activePage.getActivePart();
+
+ setResult(activePart);
+ }
+ });
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == size, "Multi selction doesn't work with the method revealSemanticElement"); //$NON-NLS-1$
+ Assert.assertTrue("Multi selction doesn't work with the method revealSemanticElement", currentSelection.size() == size); //$NON-NLS-1$
}
/**
@@ -118,36 +154,53 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final Package pack = (Package)getRootOfTheModel();
final EList<Package> importedPackage = pack.getImportedPackages();
final int size = importedPackage.size();
- Assert.isTrue(size != 0);//to be sure that the tested model is correct
+ Assert.assertTrue(size != 0);//to be sure that the tested model is correct
for(NamedElement current : importedPackage) {
selectedElement.clear();
selectedElement.add(current);
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "I don't get the correct selection"); //$NON-NLS-1$
+ Assert.assertEquals("I don't get the correct selection", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == current, "The function revealSemanticElement seems doesn't work with importedPackage");
+ Assert.assertEquals("The function revealSemanticElement seems doesn't work with importedPackage", current, obj);
}
}
+
@Test
public void revealSemanticElement_selectImportedPackageList() {
final List<EObject> selectedElement = new ArrayList<EObject>();
final Package pack = (Package)getRootOfTheModel();
final EList<Package> importedPackage = pack.getImportedPackages();
final int size = importedPackage.size();
- Assert.isTrue(size != 0);//to be sure that the tested model is correct
+ Assert.assertNotSame(0, size);//to be sure that the tested model is correct
selectedElement.addAll(importedPackage);
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == size, "I don't get the current selection for revealSemanticElement_importedPackageList"); //$NON-NLS-1$
+ Assert.assertEquals("I don't get the current selection for revealSemanticElement_importedPackageList", 1, currentSelection.size()); //$NON-NLS-1$
}
}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
index b67727d12a7..bec108c7d6a 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/RenameHandlerTest.java
@@ -16,10 +16,10 @@ package org.eclipse.papyrus.uml.modelexplorer.tests;
import java.util.List;
import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.papyrus.views.modelexplorer.tests.AbstractHandlerTest;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Model;
+import org.junit.Assert;
import org.junit.Test;
@@ -43,12 +43,12 @@ public class RenameHandlerTest extends AbstractHandlerTest {
@Test
public void renameUMLUnnamedElementTest() {
List<Comment> comments = ((Model)getRootOfTheModel()).getOwnedComments();
- Assert.isTrue(comments.size() != 0);
+ Assert.assertFalse(comments.isEmpty());
for(int i = 0; i < ((Model)getRootOfTheModel()).getOwnedComments().size(); i++) {
selectElementInTheModelexplorer(((Model)getRootOfTheModel()).getOwnedComments().get(i));
IHandler handler = getActiveHandler();
if(handler != null) {
- Assert.isTrue(handler.isEnabled() == false, "Rename handler is not disabled on UnnamedElement");
+ Assert.assertFalse("Rename handler is not disabled on UnnamedElement", handler.isEnabled());
}
}
}
@@ -57,6 +57,6 @@ public class RenameHandlerTest extends AbstractHandlerTest {
public void renameUMLNamedElementTest() {
selectElementInTheModelexplorer(getRootOfTheModel());
IHandler handler = getActiveHandler();
- Assert.isTrue(handler.isEnabled());
+ Assert.assertTrue(handler.isEnabled());
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/META-INF/MANIFEST.MF
index 2d101dd2ceb..c3400a54979 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.papyrus.uml.diagram.clazz;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
index 93bd812d51f..94f7449b562 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildLabel.java
@@ -40,84 +40,97 @@ public class TestClassDiagramChildLabel extends TestChildLabel {
@Override
protected ICreationCommand getDiagramCommandCreation() {
- return new CreateClassDiagramCommand();
+ return new CreateClassDiagramCommand();
}
+
@Test
public void testToManageinstanceSlot() {
//instance specification
testToManageTopNode(UMLElementTypes.InstanceSpecification_2001, UMLElementTypes.Slot_3030, InstanceSpecificationSlotCompartmentEditPart.VISUAL_ID);
}
+
@Test
public void testToManageComponentProperty() {
//instance specification
testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Property_3002, ComponentAttributeCompartmentEditPart.VISUAL_ID);
}
-
+
@Test
public void testToManageComponentNestedClass() {
//instance specification
testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Class_3004, ComponentNestedClassifierCompartmentEditPart.VISUAL_ID);
}
+
@Test
public void testToManageComponentOperation() {
//instance specification
testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Operation_3003, ComponentOperationCompartmentEditPart.VISUAL_ID);
}
-
+
@Test
public void testToManageSignalProperty() {
//instance specification
testToManageTopNode(UMLElementTypes.Signal_2003, UMLElementTypes.Property_3005, SignalAttributeCompartmentEditPart.VISUAL_ID);
}
-
+
+ @Test
public void testToManageInterfaceProperty() {
//interface
testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Property_3006, InterfaceAttributeCompartmentEditPart.VISUAL_ID);
- }
+ }
+
+ @Test
public void testToManageInterfaceOperation() {
//interface
testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Operation_3007, InterfaceOperationCompartmentEditPart.VISUAL_ID);
}
-
+
+ @Test
public void testToManageInterfaceNestedClass() {
//interface
testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Class_3008, InterfaceNestedClassifierCompartmentEditPart.VISUAL_ID);
- }
-
+ }
+
+ @Test
public void testToManageEnumerationLiteralEnumeration() {
//Enumeration
testToManageTopNode(UMLElementTypes.Enumeration_2006, UMLElementTypes.EnumerationLiteral_3017, EnumerationEnumerationLiteralCompartmentEditPart.VISUAL_ID);
- }
-
+ }
+
+ @Test
public void testToManageClassProperty() {
//Enumeration
testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Property_3012, ClassAttributeCompartmentEditPart.VISUAL_ID);
- }
-
+ }
+
+ @Test
public void testToManageClassReception() {
//Enumeration
testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Reception_3011, ClassOperationCompartmentEditPart.VISUAL_ID);
- }
-
+ }
+
+ @Test
public void testToManageClassOperation() {
//Enumeration
testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Operation_3013, ClassOperationCompartmentEditPart.VISUAL_ID);
- }
+ }
+
@Test
public void testToManageClassNestedClass() {
//class
testToManageTopNode(UMLElementTypes.Class_2008, UMLElementTypes.Class_3014, ClassNestedClassifierCompartmentEditPart.VISUAL_ID);
}
-
-
+
+
@Test
public void testToManageComponentReception() {
//class
- testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Reception_3011,ComponentOperationCompartmentEditPart.VISUAL_ID );
+ testToManageTopNode(UMLElementTypes.Component_2002, UMLElementTypes.Reception_3011, ComponentOperationCompartmentEditPart.VISUAL_ID);
}
+
@Test
public void testToManageInterfaceReception() {
//class
- testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Reception_3039,InterfaceOperationCompartmentEditPart.VISUAL_ID );
+ testToManageTopNode(UMLElementTypes.Interface_2004, UMLElementTypes.Reception_3039, InterfaceOperationCompartmentEditPart.VISUAL_ID);
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
index 9706e98bfce..3831858ed21 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.clazz.tests/test/org/eclipse/papyrus/diagram/clazz/test/canonical/TestClassDiagramChildNode.java
@@ -28,11 +28,12 @@ import org.junit.Test;
*/
public class TestClassDiagramChildNode extends TestChildNode {
-
+
@Override
protected CreateViewRequest createViewRequestShapeContainer() {
return CreateViewRequestFactory.getCreateShapeRequest(UMLElementTypes.Package_2007, getDiagramEditPart().getDiagramPreferencesHint());
}
+
/**
* Test to manage component.
*/
@@ -40,7 +41,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageComponent() {
testToManageChildNode(UMLElementTypes.Component_3021, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage instance specification.
*/
@@ -48,7 +49,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageInstanceSpecification() {
testToManageChildNode(UMLElementTypes.InstanceSpecification_3020, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage signal.
*/
@@ -56,7 +57,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageSignal() {
testToManageChildNode(UMLElementTypes.Signal_3022, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage model.
*/
@@ -64,7 +65,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageModel() {
testToManageChildNode(UMLElementTypes.Model_3024, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage enumeration.
*/
@@ -72,7 +73,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageEnumeration() {
testToManageChildNode(UMLElementTypes.Enumeration_3025, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage i package.
*/
@@ -80,7 +81,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageIPackage() {
testToManageChildNode(UMLElementTypes.Package_3009, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage class.
*/
@@ -88,7 +89,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageClass() {
testToManageChildNode(UMLElementTypes.Class_3010, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage InforamtionItem.
*/
@@ -96,7 +97,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageInformationItem() {
testToManageChildNode(UMLElementTypes.InformationItem_3040, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage primitive type.
*/
@@ -104,7 +105,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManagePrimitiveType() {
testToManageChildNode(UMLElementTypes.PrimitiveType_3026, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage data type.
*/
@@ -112,7 +113,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageDataType() {
testToManageChildNode(UMLElementTypes.DataType_3027, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage constraint.
*/
@@ -120,7 +121,7 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageConstraint() {
testToManageChildNode(UMLElementTypes.Constraint_3029, UMLElementTypes.Package_3009, true);
}
-
+
/**
* Test to manage comment.
*/
@@ -128,9 +129,10 @@ public class TestClassDiagramChildNode extends TestChildNode {
public void testToManageComment() {
testToManageChildNode(UMLElementTypes.Comment_3028, UMLElementTypes.Package_3009, true);
}
+
@Override
protected ICreationCommand getDiagramCommandCreation() {
- return new CreateClassDiagramCommand();
+ return new CreateClassDiagramCommand();
}
-
+
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.common.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.common.tests/META-INF/MANIFEST.MF
index 9c427b5f22c..a9217f038d4 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.common.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.common.tests/META-INF/MANIFEST.MF
@@ -13,4 +13,3 @@ Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.diagram.common.tests;singleto
n:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
index 21b9b412fbc..b817f160452 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.papyrus.uml.diagram.clazz;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AbstractPapyrusTestCase.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AbstractPapyrusTestCase.java
index 225962e084e..ce339dbce83 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AbstractPapyrusTestCase.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/AbstractPapyrusTestCase.java
@@ -33,12 +33,14 @@ import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor;
import org.eclipse.papyrus.uml.diagram.clazz.part.UMLDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.uml2.uml.Element;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
@@ -160,7 +162,13 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
//diResourceSet.save( new NullProgressMonitor());
//diagramEditor.close(true);
papyrusEditor = null;
- page.closeAllEditors(true);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ page.closeAllEditors(true);
+ }
+ });
+
project.delete(true, new NullProgressMonitor());
super.tearDown();
@@ -182,43 +190,49 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
/**
* Project creation.
*/
- protected void projectCreation() {
+ protected void projectCreation() throws Exception {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
root = workspace.getRoot();
project = root.getProject("ClazzDiagramTestProject");
file = project.getFile("ClazzDiagramTest.di");
this.diResourceSet = new DiResourceSet();
- try {
- //at this point, no resources have been created
- if(!project.exists()) {
- project.create(null);
- }
- if(!project.isOpen()) {
- project.open(null);
- }
- if(file.exists()) {
- file.delete(true, new NullProgressMonitor());
- }
+ //at this point, no resources have been created
+ if(!project.exists()) {
+ project.create(null);
+ }
+ if(!project.isOpen()) {
+ project.open(null);
+ }
- if(!file.exists()) {
- file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
- diResourceSet.createsModels(file);
- new CreateUMLModelCommand().createModel(this.diResourceSet);
- // diResourceSet.createsModels(file);
- ICreationCommand command = new CreateClassDiagramCommand();
- command.createDiagram(diResourceSet, null, "ClazzDiagram");
- diResourceSet.save(new NullProgressMonitor());
+ if(file.exists()) {
+ file.delete(true, new NullProgressMonitor());
+ }
- }
- page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
- papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(file), desc.getId());
- } catch (Exception e) {
- System.err.println("error " + e);
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel(this.diResourceSet);
+ // diResourceSet.createsModels(file);
+ ICreationCommand command = new CreateClassDiagramCommand();
+ command.createDiagram(diResourceSet, null, "ClazzDiagram");
+ diResourceSet.save(new NullProgressMonitor());
}
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ });
+ Assert.assertNotNull(papyrusEditor);
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/META-INF/MANIFEST.MF
index 0eaa411056d..c35c6615ace 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit4;bundle-version="4.5.0",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.editor;bundle-version="0.10.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
index 56d01912a8b..5722e1fe5ee 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.tests/src/org/eclipse/papyrus/diagram/tests/canonical/AbstractPapyrusTestCase.java
@@ -23,6 +23,7 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.commands.ICreationCommand;
@@ -31,6 +32,7 @@ import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
import org.eclipse.papyrus.uml.diagram.common.part.UmlGmfDiagramEditor;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@@ -111,7 +113,6 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
/** The clazzdiagramedit part. */
protected DiagramEditPart clazzdiagrameditPart;
-
/**
* @see junit.framework.TestCase#setUp()
*
@@ -120,7 +121,6 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
@Before
@Override
protected void setUp() throws Exception {
-
super.setUp();
projectCreation();
}
@@ -151,14 +151,32 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
@After
@Override
protected void tearDown() throws Exception {
- papyrusEditor.doSave(new NullProgressMonitor());
- //diResourceSet.save( new NullProgressMonitor());
- //diagramEditor.close(true);
- papyrusEditor = null;
- page.closeAllEditors(true);
- project.delete(true, new NullProgressMonitor());
-
- super.tearDown();
+ RunnableWithResult<Boolean> runnable = new RunnableWithResult.Impl<Boolean>() {
+
+ public void run() {
+ try {
+ papyrusEditor.doSave(new NullProgressMonitor());
+ //diResourceSet.save( new NullProgressMonitor());
+ //diagramEditor.close(true);
+ papyrusEditor = null;
+ clazzdiagrameditPart = null;
+ diagramEditor = null;
+ page.closeAllEditors(true);
+ project.delete(true, new NullProgressMonitor());
+
+ setResult(true);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ setResult(false);
+ }
+ }
+
+ };
+
+ Display.getDefault().syncExec(runnable);
+ if(!runnable.getResult()) {
+ fail("Cannot close the editor and delete the project");
+ }
}
/**
@@ -208,15 +226,26 @@ public abstract class AbstractPapyrusTestCase extends TestCase {
diResourceSet.save(new NullProgressMonitor());
}
- page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
- papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(file), desc.getId());
+
+ Runnable runnable = new Runnable() {
+
+ public void run() {
+ try {
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ papyrusEditor = (IMultiDiagramEditor)page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception ex) {
+ ex.printStackTrace(System.out);
+ }
+ }
+ };
+
+ Display.getDefault().syncExec(runnable);
+ Assert.assertNotNull("Failed to open the editor", papyrusEditor);
} catch (Exception e) {
e.printStackTrace(System.out);
- Assert.fail("Project creation failed");
+ fail("Project creation failed: " + e.getMessage());
}
-
-
}
}
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF
index 3c17a84e556..72c96b56e11 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.uml.service.types.tests/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.junit
+Require-Bundle: org.junit4
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.papyrus.uml.service.types;bundle-version="0
.9.0"
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
index e132f7d9907..3a8a9a6c54f 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit,
+ org.junit4,
org.eclipse.papyrus.uml.tools;bundle-version="0.10.0",
org.eclipse.emf.ecore;bundle-version="2.8.0",
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/ContentProviderTest.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/ContentProviderTest.java
index 7d3ee5d18f4..25c463ba1d5 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/ContentProviderTest.java
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/ContentProviderTest.java
@@ -31,6 +31,7 @@ import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
import org.eclipse.papyrus.uml.tools.tests.Activator;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
//TODO : Test TreeToFlatContentProvider (Number of elements displayed, isValid...)
@@ -146,9 +147,10 @@ public class ContentProviderTest {
return isValid;
}
+ @Ignore("Not implemented yet")
@Test
public void multipleValuePropertyTest() {
-
+ throw new UnsupportedOperationException("Not implemtend yet");
}
private EStructuralFeature getFeature(String className, String featureName) {
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/.settings/org.eclipse.jdt.ui.prefs b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index b90eafc349c..00000000000
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,54 +0,0 @@
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=true
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=true
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=true
-sp_cleanup.always_use_this_for_non_static_field_access=true
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=true
-sp_cleanup.format_source_code=true
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.make_local_variable_final=true
-sp_cleanup.make_parameters_final=true
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=true
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=false
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=true
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=true
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=true
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=true
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_blocks=true
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_parentheses_in_expressions=false
-sp_cleanup.use_this_for_non_static_field_access=true
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
-sp_cleanup.use_this_for_non_static_method_access=false
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
index 03ca0b3a908..b9ce7d0a490 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.junit;bundle-version="4.8.2",
+ org.junit4;bundle-version="4.0.0",
org.eclipse.core.resources,
org.eclipse.emf.facet.util.core,
org.eclipse.ui.ide,
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
index 73ef9834434..a700e2a5271 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/AbstractHandlerTest.java
@@ -23,14 +23,16 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
import org.eclipse.emf.facet.util.core.internal.exported.FileUtils;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -39,6 +41,7 @@ import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPage;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IViewPart;
@@ -50,11 +53,12 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.handlers.HandlerProxy;
-import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.part.IPage;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
+import org.junit.internal.runners.statements.RunAfters;
import org.osgi.framework.Bundle;
//TODO a part of this plugin should be moved in an upper test plugin
@@ -83,7 +87,7 @@ public abstract class AbstractHandlerTest {
private ModelExplorerView modelExplorerView;
- private Command testedCommand;
+ protected Command testedCommand;
private CommonViewer commonViewer;
@@ -105,10 +109,8 @@ public abstract class AbstractHandlerTest {
* @param bundle
* the bundle used to load the model
*/
- public AbstractHandlerTest(final Bundle bundle) {
- Assert.isNotNull(bundle, "Bundle can't be null to do the test.");
- this.bundle = bundle;
- this.commandId = null;
+ public AbstractHandlerTest(Bundle bundle) {
+ this(null, bundle);
}
/**
@@ -118,8 +120,8 @@ public abstract class AbstractHandlerTest {
* @param commandId
* the id of the command to test
*/
- public AbstractHandlerTest(final String commandId, final Bundle bundle) {
- Assert.isNotNull(bundle, "Bundle can't be null to do the test.");
+ public AbstractHandlerTest(String commandId, Bundle bundle) {
+ Assert.assertNotNull("Bundle can't be null to do the test.", bundle);
this.commandId = commandId;
this.bundle = bundle;
}
@@ -133,21 +135,40 @@ public abstract class AbstractHandlerTest {
*/
// TODO should be moved in an upper plugin test
protected IEditorPart openEditor(final IFile file) throws PartInitException {
- final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
-
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IEditorPart editor = IDE.openEditor(activePage, file);
- return editor;
+ RunnableWithResult<IEditorPart> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IEditorPart>() {
+
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IEditorPart editor = IDE.openEditor(activePage, file);
+ setResult(editor);
+ setStatus(Status.OK_STATUS);
+ } catch (Exception ex) {
+ setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), "Cannot open the editor"));
+ }
+ }
+ });
+
+ Assert.assertEquals(runnable.getStatus().getMessage(), IStatus.OK, runnable.getStatus().getSeverity());
+
+ return runnable.getResult();
}
/**
* This method tests if the active part is the model explorer
*/
protected void testIsModelExplorerActivePart() {
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+ RunnableWithResult<IWorkbenchPart> activePartRunnable;
+ Display.getDefault().syncExec(activePartRunnable = new RunnableWithResult.Impl<IWorkbenchPart>(){
+ public void run(){
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ }
+ });
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePartRunnable.getResult() instanceof ModelExplorerPageBookView); //$NON-NLS-1$
}
/**
@@ -157,17 +178,23 @@ public abstract class AbstractHandlerTest {
* @param elementToSelect
* the element to select
*/
- protected void selectElementInTheModelexplorer(final EObject elementToSelect) {
+ protected void selectElementInTheModelexplorer(EObject elementToSelect) {
final List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(elementToSelect);
- this.modelExplorerView.revealSemanticElement(selectedElement);
- final IStructuredSelection currentSelection = (IStructuredSelection)this.selectionService.getSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ modelExplorerView.revealSemanticElement(selectedElement);
+ }
+ });
+
+ IStructuredSelection currentSelection = (IStructuredSelection)selectionService.getSelection();
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == elementToSelect, "the current selected element is not the wanted element"); //$NON-NLS-1$
+ Assert.assertSame("the current selected element is not the wanted element", elementToSelect, obj); //$NON-NLS-1$
}
/**
@@ -178,15 +205,21 @@ public abstract class AbstractHandlerTest {
* the element to select
*/
protected void selectElementInTheModelexplorer(final ITreeElement elementToSelect) {
- this.commonViewer.setSelection(new StructuredSelection(elementToSelect));
- final IStructuredSelection currentSelection = (IStructuredSelection)this.selectionService.getSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
- final Object obj = currentSelection.getFirstElement();
- Assert.isTrue(obj == elementToSelect, "the current selected element is not the wanted element"); //$NON-NLS-1$
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ commonViewer.setSelection(new StructuredSelection(elementToSelect));
+ }
+ });
+
+ IStructuredSelection currentSelection = (IStructuredSelection)selectionService.getSelection();
+ Assert.assertEquals("Only one element should be selected", 1, currentSelection.size()); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ Assert.assertSame("the current selected element is not the wanted element", elementToSelect, obj); //$NON-NLS-1$
}
protected IStructuredSelection getCurrentSelection() {
- return (IStructuredSelection)this.selectionService.getSelection();
+ return (IStructuredSelection)selectionService.getSelection();
}
/**
@@ -194,7 +227,7 @@ public abstract class AbstractHandlerTest {
* @return the current handler for the command
*/
protected IHandler getActiveHandler() {
- IHandler currentHandler = this.testedCommand.getHandler();
+ IHandler currentHandler = testedCommand.getHandler();
if(currentHandler instanceof HandlerProxy) {
currentHandler = ((HandlerProxy)currentHandler).getHandler();
}
@@ -203,62 +236,78 @@ public abstract class AbstractHandlerTest {
@Before
public void initTests() throws CoreException, IOException {
- final IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
- PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
-
// we clean the workspace and create a new project to test the handlers
- final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- for(final IProject project : workspace.getRoot().getProjects()) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ for(IProject project : workspace.getRoot().getProjects()) {
project.delete(true, new NullProgressMonitor());
}
- final IProject testProject = workspace.getRoot().getProject(AbstractHandlerTest.PROJECT_NAME);
+ IProject testProject = workspace.getRoot().getProject(AbstractHandlerTest.PROJECT_NAME);
testProject.create(new NullProgressMonitor());
testProject.open(new NullProgressMonitor());
// we copy the file of the tested model in the new project
FileUtils.copyFileFromBundle("/resources/" + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_UML, //$NON-NLS-1$
- testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_UML, this.bundle);
+ testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_UML, bundle);
FileUtils.copyFileFromBundle("/resources/" + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_NOTATION, //$NON-NLS-1$
- testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_NOTATION, this.bundle);
+ testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_NOTATION, bundle);
FileUtils.copyFileFromBundle("/resources/" + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_DI, //$NON-NLS-1$
- testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_DI, this.bundle);
- final IFile file = testProject.getFile(AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_DI);
+ testProject, '/' + AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_DI, bundle);
+ IFile file = testProject.getFile(AbstractHandlerTest.FILE_NAME + AbstractHandlerTest.EXTENSION_DI);
// we open the editor
- this.editor = (CoreMultiDiagramEditor)openEditor(file);
- final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
- // we look for the modelexplorer
- final IViewPart modelexplorer = activeWorkbenchWindow.getActivePage().showView(AbstractHandlerTest.viewId);
- final ModelExplorerPageBookView view = (ModelExplorerPageBookView)modelexplorer;
- final IPage currentPage = view.getCurrentPage();
- final ModelExplorerPage page = (ModelExplorerPage)currentPage;
- final IViewPart viewer = page.getViewer();
- this.modelExplorerView = (ModelExplorerView)viewer;
- this.modelExplorerView.setFocus();
-
- // we look for the common viewer
- this.commonViewer = this.modelExplorerView.getCommonViewer();
-
- // we look for the selection service
- this.selectionService = activeWorkbenchWindow.getSelectionService();
-
- // we look for the testedCommand
- final ICommandService commandService = (ICommandService)activeWorkbenchWindow.getService(ICommandService.class);
- if(this.commandId != null) {
- this.testedCommand = commandService.getCommand(this.commandId);
- }
-
- this.commonViewer.expandToLevel(2);
-
- // store the root of the model
- final Object[] visibleElement = this.commonViewer.getVisibleExpandedElements();
- if(visibleElement[0] instanceof IAdaptable) {
- this.modelRoot = (EObject)((IAdaptable)visibleElement[0]).getAdapter(EObject.class);
- }
-
- while(this.modelRoot.eContainer() != null) {
- this.modelRoot = this.modelRoot.eContainer();
+ editor = (CoreMultiDiagramEditor)openEditor(file);
+
+ RunnableWithResult runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl() {
+
+ public void run() {
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ // we look for the modelexplorer
+ IViewPart modelexplorer;
+ try {
+ modelexplorer = activeWorkbenchWindow.getActivePage().showView(AbstractHandlerTest.viewId);
+ } catch (PartInitException ex) {
+ ex.printStackTrace(System.out);
+ setStatus(new Status(IStatus.ERROR, bundle.getSymbolicName(), ex.getMessage()));
+ return;
+ }
+ ModelExplorerPageBookView view = (ModelExplorerPageBookView)modelexplorer;
+ IPage currentPage = view.getCurrentPage();
+ ModelExplorerPage page = (ModelExplorerPage)currentPage;
+ IViewPart viewer = page.getViewer();
+ modelExplorerView = (ModelExplorerView)viewer;
+ modelExplorerView.setFocus();
+
+ // we look for the common viewer
+ commonViewer = modelExplorerView.getCommonViewer();
+
+ // we look for the selection service
+ selectionService = activeWorkbenchWindow.getSelectionService();
+
+ // we look for the testedCommand
+ ICommandService commandService = (ICommandService)activeWorkbenchWindow.getService(ICommandService.class);
+ if(commandId != null) {
+ testedCommand = commandService.getCommand(commandId);
+ }
+
+ commonViewer.expandToLevel(2);
+
+ // store the root of the model
+ Object[] visibleElement = commonViewer.getVisibleExpandedElements();
+ if(visibleElement[0] instanceof IAdaptable) {
+ modelRoot = (EObject)((IAdaptable)visibleElement[0]).getAdapter(EObject.class);
+ }
+
+ setStatus(Status.OK_STATUS);
+ }
+ });
+
+ Assert.assertEquals(runnable.getStatus().getMessage(), IStatus.OK, runnable.getStatus().getSeverity());
+
+ while(modelRoot.eContainer() != null) {
+ modelRoot = modelRoot.eContainer();
}
}
@@ -267,7 +316,7 @@ public abstract class AbstractHandlerTest {
* @return the root of the model
*/
public EObject getRootOfTheModel() {
- return this.modelRoot;
+ return modelRoot;
}
/**
@@ -275,7 +324,7 @@ public abstract class AbstractHandlerTest {
* @return the model explorer view
*/
public ModelExplorerView getModelExplorerView() {
- return this.modelExplorerView;
+ return modelExplorerView;
}
/**
@@ -283,7 +332,7 @@ public abstract class AbstractHandlerTest {
* @return the common viewer
*/
public CommonViewer getCommonViewer() {
- return this.commonViewer;
+ return commonViewer;
}
public TransactionalEditingDomain getEditingDomain() {
@@ -295,13 +344,13 @@ public abstract class AbstractHandlerTest {
}
public void undoRedoTest() {
- Assert.isTrue(getCommandStack().canUndo(), "I can't undo the command!");
+ Assert.assertTrue("I can't undo the command!", getCommandStack().canUndo());
getCommandStack().undo();
- Assert.isTrue(getCommandStack().canRedo(), "I can't Redo the command!");
+ Assert.assertTrue("I can't Redo the command!", getCommandStack().canRedo());
getCommandStack().redo();
}
- public void undoRedo(final int time) {
+ public void undoRedo(int time) {
for(int i = 0; i < time; i++) {
undoRedoTest();
}
@@ -309,7 +358,12 @@ public abstract class AbstractHandlerTest {
@After
public void endOfTests() {
- // So that the Workbench can be closed.
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // So that the Workbench can be closed.
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false);
+ }
+ });
}
}
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/DeleteHandlerTest.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/DeleteHandlerTest.java
index 4b5232d3c5f..ab04aafea6c 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/DeleteHandlerTest.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/DeleteHandlerTest.java
@@ -17,16 +17,20 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonViewer;
+import org.junit.Assert;
import org.junit.Test;
/**
@@ -60,35 +64,65 @@ public class DeleteHandlerTest extends AbstractHandlerTest {
final List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(getRootOfTheModel());
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ try {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ setStatus(Status.OK_STATUS);
+ } catch (Exception ex) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage()));
+ }
+ }
+ });
+
+ Assert.assertEquals(runnable.getStatus().getMessage(), IStatus.OK, runnable.getStatus().getSeverity());
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
+
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Assert.assertEquals("Only one element should be selected", currentSelection.size(), 1); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == getRootOfTheModel());
+ Assert.assertSame(getRootOfTheModel(), obj);
final IHandler currentHandler = getActiveHandler();
if(currentHandler == null) {
// not a problem in this case
} else {
- Assert.isTrue(currentHandler.isEnabled() == false, "We can delete the root of the model. It is not the wanted behavior"); //$NON-NLS-1$
+ Assert.assertFalse("We can delete the root of the model. It is not the wanted behavior", currentHandler.isEnabled()); //$NON-NLS-1$
}
}
@Test
public void deleteLinkItemTest() {
final CommonViewer commonViewer = getCommonViewer();
- commonViewer.expandToLevel(3);
- final Object[] expandedElement = commonViewer.getExpandedElements();
+
+ RunnableWithResult<Object[]> runnable;
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<Object[]>() {
+
+ public void run() {
+ commonViewer.expandToLevel(3);
+ setResult(commonViewer.getExpandedElements());
+ setStatus(Status.OK_STATUS);
+ }
+ });
+
+ final Object[] expandedElement = runnable.getResult();
for(final Object object : expandedElement) {
if(object instanceof org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem) {
selectElementInTheModelexplorer((ITreeElement)object);
final IHandler handler = getActiveHandler();
if(handler != null) {
- Assert.isTrue(handler.isEnabled() == false, "The handler " + handler + " is active on LinkItem, it is not the wanted behavior"); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertFalse("The handler " + handler + " is active on LinkItem, it is not the wanted behavior", handler.isEnabled()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
diff --git a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/ModelExplorerViewTests.java b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/ModelExplorerViewTests.java
index 15ab529b336..cf8c7180bc9 100644
--- a/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/ModelExplorerViewTests.java
+++ b/tests/junit/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.tests/src/org/eclipse/papyrus/views/modelexplorer/tests/ModelExplorerViewTests.java
@@ -16,14 +16,18 @@ package org.eclipse.papyrus.views.modelexplorer.tests;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
+import org.junit.Assert;
import org.junit.Test;
@@ -46,16 +50,36 @@ public class ModelExplorerViewTests extends AbstractHandlerTest {
final List<EObject> selectedElement = new ArrayList<EObject>();
selectedElement.add(getRootOfTheModel());
getModelExplorerView().revealSemanticElement(selectedElement);
- final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- final IWorkbenchPart activePart = activePage.getActivePart();
- Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+
+
+ RunnableWithResult<IWorkbenchPart> runnable;
+
+ Display.getDefault().syncExec(runnable = new RunnableWithResult.Impl<IWorkbenchPart>() {
+
+ public void run() {
+ try {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ setResult(activePart);
+ setStatus(Status.OK_STATUS);
+ } catch (Exception ex) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage()));
+ }
+ }
+ });
+
+ Assert.assertEquals(runnable.getStatus().getMessage(), IStatus.OK, runnable.getStatus().getSeverity());
+
+ IWorkbenchPart activePart = runnable.getResult();
+
+ Assert.assertTrue("The active part is not the ModelExplorer", activePart instanceof ModelExplorerPageBookView); //$NON-NLS-1$
final IStructuredSelection currentSelection = getCurrentSelection();
- Assert.isTrue(currentSelection.size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Assert.assertEquals("Only one element should be selected", currentSelection.size(), 1); //$NON-NLS-1$
Object obj = currentSelection.getFirstElement();
if(obj instanceof IAdaptable) {
obj = ((IAdaptable)obj).getAdapter(EObject.class);
}
- Assert.isTrue(obj == getRootOfTheModel(), "The function revealSemanticElement seems doesn't work on the root of the model");
+ Assert.assertSame("The function revealSemanticElement seems doesn't work on the root of the model", obj, getRootOfTheModel()); //$NON-NLS-1$
}
}

Back to the top