Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java54
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.di12
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.notation58
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.uml28
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AdvancedModeTest.java135
-rw-r--r--tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java13
7 files changed, 252 insertions, 51 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java
index abd94f120ee..df6273808ed 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedTreeContentProvider.java
@@ -10,6 +10,7 @@
* Gregoire Dupe (Mia-Software) - Bug 385292 - [CustomizedTreeContentProvider] StackOverFlow when refreshing a TreeViewer with ICustomizedTreeContentProvider
* Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements()
* Christian W. Damus (CEA) - bug 430700
+ * Christian W. Damus (CEA) - bug 440795
*
*******************************************************************************/
package org.eclipse.papyrus.emf.facet.custom.ui.internal;
@@ -43,7 +44,6 @@ import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationExceptio
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.TreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.TreeproxyFactory;
@@ -169,7 +169,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
// Just add it
elementList.add(existing);
} else if(element instanceof EObject) {
- final EObjectTreeElement eObjectProxy = createEObjectProxy(element, null);
+ final EObjectTreeElement eObjectProxy = getEObjectProxy(element, null);
elementList.add(eObjectProxy);
} else {
elementList.add(element);
@@ -232,7 +232,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
for (final Object object : result) {
if (object instanceof EObject) {
final EObject childEObject = (EObject) object;
- children.add(createEObjectProxy(childEObject, attributeProxy));
+ children.add(getEObjectProxy(childEObject, attributeProxy));
}
children.add(object);
}
@@ -275,7 +275,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
final EObject referedEObject = facetManager.getOrInvoke(
eObject, eReference, EObject.class);
if (referedEObject != null) {
- child = createEObjectProxy(referedEObject, parent);
+ child = getEObjectProxy(referedEObject, parent);
}
} catch (final FacetManagerException e) {
Logger.logError(e, Activator.getDefault());
@@ -299,7 +299,7 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
for (final Object object : result) {
if (object instanceof EObject) {
final EObject childEObject = (EObject) object;
- children.add(createEObjectProxy(childEObject, parent));
+ children.add(getEObjectProxy(childEObject, parent));
}
}
} catch (final FacetManagerException e) {
@@ -311,44 +311,6 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
return children;
}
-
-
- private Collection<EAttributeTreeElement> createAttributeProxies(final List<EAttribute> allAttributes, final EObjectTreeElement parent) {
- final EObject eObject = parent.getEObject();
- final List<EAttributeTreeElement> result = new ArrayList<EAttributeTreeElement>();
- for (final EAttribute eAttribute : allAttributes) {
- if (isVisible(eObject, eAttribute)) {
- final EAttributeTreeElement attributeProxy = TreeproxyFactory.eINSTANCE.createEAttributeTreeElement();
- attributeProxy.setEAttribute(eAttribute);
- attributeProxy.setParent(parent);
- result.add(attributeProxy);
- }
- }
- return result;
- }
-
-
-
- private Collection<? extends Object> createReferenceProxies(final List<EReference> allReferences, final EObjectTreeElement parent) {
- final EObject eObject = parent.getEObject();
- final List<EReferenceTreeElement> result = new ArrayList<EReferenceTreeElement>();
- for (final EReference eReference : allReferences) {
- if (isVisible(eObject, eReference)) {
- if(!(collapseLink(eObject, eReference))) {
- final EReferenceTreeElement referenceProxy = TreeproxyFactory.eINSTANCE.createEReferenceTreeElement();
- referenceProxy.setEReference(eReference);
- referenceProxy.setParent(parent);
- result.add(referenceProxy);
- }
- else{
- System.err.println("Do not Create an eReference"+ eReference+" create directly its childreen");
- }
-
- }
- }
- return result;
- }
-
public Object getParent(final Object element) {
Object result = null;
if (element instanceof TreeElement) {
@@ -365,7 +327,9 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
- // nothing to do
+ if(oldInput != newInput) {
+ cache.clear();
+ }
}
public ICustomizationManager getCustomizationManager() {
@@ -544,4 +508,4 @@ public class CustomizedTreeContentProvider implements ICustomizedTreeContentProv
public void dispose() {
cache.clear();
}
-}
+} \ No newline at end of file
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 35d566198ae..b39db9c47da 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
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.junit.utils;bundle-version="1.0.0",
org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
org.eclipse.gmf.runtime.notation.edit,
- org.eclipse.papyrus.infra.nattable.model;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="1.0.0",
+ org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.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/resources/adv_mode.di b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.di
new file mode 100644
index 00000000000..a8413be6008
--- /dev/null
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.di
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="adv_mode.notation#_IX06UBf8EeSLM5AVoLTKwA"/>
+ </children>
+ </children>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.notation b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.notation
new file mode 100644
index 00000000000..80774e677a5
--- /dev/null
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.notation
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_IX06UBf8EeSLM5AVoLTKwA" type="PapyrusUMLClassDiagram" name="classes" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_JPPqgBf8EeSLM5AVoLTKwA" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="_JPQRkBf8EeSLM5AVoLTKwA" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_JPQRkRf8EeSLM5AVoLTKwA" type="7017">
+ <children xmi:type="notation:Shape" xmi:id="_dG2uIBf8EeSLM5AVoLTKwA" type="3012">
+ <element xmi:type="uml:Property" href="adv_mode.uml#_dG048Bf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_dG2uIRf8EeSLM5AVoLTKwA"/>
+ </children>
+ <styles xmi:type="notation:TitleStyle" xmi:id="_JPQRkhf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_JPQRkxf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_JPQRlBf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JPQRlRf8EeSLM5AVoLTKwA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_JPQRlhf8EeSLM5AVoLTKwA" type="7018">
+ <children xmi:type="notation:Shape" xmi:id="_qsxKMBf8EeSLM5AVoLTKwA" type="3013">
+ <element xmi:type="uml:Operation" href="adv_mode.uml#_qsvVABf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qsxKMRf8EeSLM5AVoLTKwA"/>
+ </children>
+ <styles xmi:type="notation:TitleStyle" xmi:id="_JPQRlxf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_JPQRmBf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_JPQRmRf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JPQRmhf8EeSLM5AVoLTKwA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_JPQ4oBf8EeSLM5AVoLTKwA" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_JPQ4oRf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_JPQ4ohf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_JPQ4oxf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JPQ4pBf8EeSLM5AVoLTKwA"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_JPXmUBf8EeSLM5AVoLTKwA" type="compartment_shape_display">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_JPXmURf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JPXmUhf8EeSLM5AVoLTKwA"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_LkecgBf8EeSLM5AVoLTKwA" type="3015">
+ <children xmi:type="notation:DecorationNode" xmi:id="_Lkecghf8EeSLM5AVoLTKwA" type="7014">
+ <children xmi:type="notation:Shape" xmi:id="_U_JnMBf8EeSLM5AVoLTKwA" type="3031">
+ <element xmi:type="uml:ClassifierTemplateParameter" href="adv_mode.uml#_T3jF8Bf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_U_JnMRf8EeSLM5AVoLTKwA"/>
+ </children>
+ <styles xmi:type="notation:TitleStyle" xmi:id="_Lkecgxf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_LkechBf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_LkechRf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Lkechhf8EeSLM5AVoLTKwA"/>
+ </children>
+ <element xmi:type="uml:RedefinableTemplateSignature" href="adv_mode.uml#_LkcAQBf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LkecgRf8EeSLM5AVoLTKwA" x="101" y="-11" width="60" height="30"/>
+ </children>
+ <element xmi:type="uml:Class" href="adv_mode.uml#_JOhRwBf8EeSLM5AVoLTKwA"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JPPqgRf8EeSLM5AVoLTKwA" x="54" y="68"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_IX06URf8EeSLM5AVoLTKwA" name="diagram_compatibility_version" stringValue="1.0.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_IX06Uhf8EeSLM5AVoLTKwA"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_IX06Uxf8EeSLM5AVoLTKwA">
+ <owner xmi:type="uml:Model" href="adv_mode.uml#_IXDeQBf8EeSLM5AVoLTKwA"/>
+ </styles>
+ <element xmi:type="uml:Model" href="adv_mode.uml#_IXDeQBf8EeSLM5AVoLTKwA"/>
+</notation:Diagram>
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.uml b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.uml
new file mode 100644
index 00000000000..2f74f16776f
--- /dev/null
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/resources/adv_mode.uml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ActionLanguage="http://www.omg.org/spec/ALF/20120827/ActionLanguage-Profile" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.omg.org/spec/ALF/20120827/ActionLanguage-Profile pathmap://PAPYRUS_ACTIONLANGUAGE_PROFILE/ActionLanguage-Profile.profile.uml#_sYse0YZLEeKyw49uR6nx3g">
+ <uml:Model xmi:id="_IXDeQBf8EeSLM5AVoLTKwA" name="Model">
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_IXEFUBf8EeSLM5AVoLTKwA">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="_JOhRwBf8EeSLM5AVoLTKwA" name="Container">
+ <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature" xmi:id="_LkcAQBf8EeSLM5AVoLTKwA" name="RedefinableTemplateSignature1" parameter="_T3jF8Bf8EeSLM5AVoLTKwA">
+ <ownedParameter xmi:type="uml:ClassifierTemplateParameter" xmi:id="_T3jF8Bf8EeSLM5AVoLTKwA" parameteredElement="_WiCWQBf8EeSLM5AVoLTKwA">
+ <ownedParameteredElement xmi:type="uml:Class" xmi:id="_WiCWQBf8EeSLM5AVoLTKwA" name="T" templateParameter="_T3jF8Bf8EeSLM5AVoLTKwA"/>
+ </ownedParameter>
+ </ownedTemplateSignature>
+ <ownedAttribute xmi:type="uml:Property" xmi:id="_dG048Bf8EeSLM5AVoLTKwA" name="size" isReadOnly="true" isDerived="true">
+ <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
+ </ownedAttribute>
+ <ownedOperation xmi:type="uml:Operation" xmi:id="_qsvVABf8EeSLM5AVoLTKwA" name="add">
+ <ownedParameter xmi:type="uml:Parameter" xmi:id="_29UV0Bf8EeSLM5AVoLTKwA" name="element" type="_WiCWQBf8EeSLM5AVoLTKwA" effect="read"/>
+ </ownedOperation>
+ </packagedElement>
+ <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_ex7I0Bf8EeSLM5AVoLTKwA">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_eyRHEBf8EeSLM5AVoLTKwA" source="http://www.eclipse.org/uml2/2.0.0/UML">
+ <references xmi:type="ecore:EPackage" href="pathmap://PAPYRUS_ACTIONLANGUAGE_PROFILE/ActionLanguage-Profile.profile.uml#_sYse0YZLEeKyw49uR6nx3g"/>
+ </eAnnotations>
+ <appliedProfile xmi:type="uml:Profile" href="pathmap://PAPYRUS_ACTIONLANGUAGE_PROFILE/ActionLanguage-Profile.profile.uml#ActionLanguage"/>
+ </profileApplication>
+ </uml:Model>
+ <ActionLanguage:TextualRepresentation xmi:id="_e56nMBf8EeSLM5AVoLTKwA" language="org.eclipse.papyrus.uml.textedit.property.xtext.UmlProperty"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AdvancedModeTest.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AdvancedModeTest.java
new file mode 100644
index 00000000000..913f23cd69e
--- /dev/null
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AdvancedModeTest.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.modelexplorer.tests;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory;
+import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture;
+import org.eclipse.papyrus.junit.utils.rules.PluginResource;
+import org.eclipse.papyrus.junit.utils.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.uml2.uml.ParameterableElement;
+import org.eclipse.uml2.uml.TemplateableElement;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+
+/**
+ * Automated tests for the <em>Advanced Mode</em> of the Model Explorer view.
+ */
+@PluginResource("resources/adv_mode.di")
+public class AdvancedModeTest extends AbstractPapyrusTest {
+
+ private static final String SIMPLE_UML_CUSTOMIZATION = "SimpleUML"; //$NON-NLS-1$
+
+ @Rule
+ public final PapyrusEditorFixture editor = new PapyrusEditorFixture();
+
+ private boolean wasAdvancedMode;
+
+ public AdvancedModeTest() {
+ super();
+ }
+
+ @Test
+ public void advancedModeDoesNotCollapseItself() {
+ ParameterableElement parameteredClass = ((TemplateableElement)editor.getModel().getOwnedType("Container")).getOwnedTemplateSignature().getOwnedParameters().get(0).getOwnedParameteredElement();
+
+ // "reveal" actually does a "select and reveal"
+ ModelExplorerView.reveal(new StructuredSelection(parameteredClass), editor.getModelExplorerView().getCommonViewer());
+
+ editor.flushDisplayEvents();
+
+ // Rename the parametered class
+ EditingDomain domain = TransactionUtil.getEditingDomain(parameteredClass);
+ domain.getCommandStack().execute(SetCommand.create(domain, parameteredClass, UMLPackage.Literals.NAMED_ELEMENT__NAME, "E"));
+
+ editor.flushDisplayEvents();
+
+ // Verify that the class is still selected
+ IStructuredSelection selection = (IStructuredSelection)editor.getModelExplorerView().getSite().getSelectionProvider().getSelection();
+ assertThat(selection.size(), is(1));
+ assertThat(EMFHelper.getEObject(selection.getFirstElement()), is((EObject)parameteredClass));
+ }
+
+ //
+ // Test framework
+ //
+
+ @Before
+ public void ensureAdvancedMode() {
+ setAdvancedMode(true);
+ }
+
+ @After
+ public void restoreAdvancedMode() {
+ setAdvancedMode(wasAdvancedMode);
+ }
+
+ private void setAdvancedMode(boolean advancedMode) {
+ ICustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
+ if(customizationManager != null) {
+ ICustomizationCatalogManager customCatalog = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(customizationManager.getResourceSet());
+ Customization simpleUMLCustomization = null;
+
+ //look for SIMPLE UML Customization
+ for(Customization customization : customCatalog.getRegisteredCustomizations()) {
+ if(SIMPLE_UML_CUSTOMIZATION.equals(customization.getName())) {
+ simpleUMLCustomization = customization;
+ break;
+ }
+ }
+
+ if(simpleUMLCustomization != null) {
+ List<Customization> registeredCustomizations = new ArrayList<Customization>(customizationManager.getManagedCustomizations());
+ wasAdvancedMode = !registeredCustomizations.contains(simpleUMLCustomization);
+
+ if(advancedMode) {
+ if(registeredCustomizations.remove(simpleUMLCustomization)) {
+ customizationManager.getManagedCustomizations().clear();
+ for(Customization customization : registeredCustomizations) {
+ customizationManager.getManagedCustomizations().add(customization);
+ }
+ }
+ } else {
+ if(!customizationManager.getManagedCustomizations().contains(simpleUMLCustomization)) {
+ customizationManager.getManagedCustomizations().add(0, simpleUMLCustomization);
+ }
+ }
+ }
+
+ editor.getModelExplorerView().getCommonViewer().refresh();
+ editor.flushDisplayEvents();
+ }
+ }
+}
diff --git a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
index 087ca0a8ca5..3193cc874fa 100644
--- a/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
+++ b/tests/junit/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer.tests/src/org/eclipse/papyrus/uml/modelexplorer/tests/AllTests.java
@@ -1,5 +1,6 @@
/*******************************************************************************
- * Copyright (c) 2011 Mia-Software.
+ * Copyright (c) 2011, 2014 Mia-Software, CEA, and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +13,8 @@
* Nicolas Guyomar (Mia-Software) - Bug 346465 - [EMF Facet Table] Remove line does not remove obsolete column
* Gregoire Dupe (Mia-Software) - Bug 350700 - TableWidget: Wrong cell label in multi-valued facet reference columns
* Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
+ * Christian W. Damus (CEA) - bug 440795
+ *
*******************************************************************************/
package org.eclipse.papyrus.uml.modelexplorer.tests;
@@ -25,10 +28,10 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({
- DeleteModelExplorerTest.class, RenameHandlerTest.class, ModelExplorerViewTests.class, CutPasteModelExplorerTest.class, CopyPasteModelExplorerTest.class,
- DiagramCopyPasteModelExplorerTest.class,TableCopyPasteModelExplorerTest.class
-})
+@SuiteClasses({ //
+DeleteModelExplorerTest.class, RenameHandlerTest.class, ModelExplorerViewTests.class, CutPasteModelExplorerTest.class, CopyPasteModelExplorerTest.class, //
+DiagramCopyPasteModelExplorerTest.class, TableCopyPasteModelExplorerTest.class, //
+AdvancedModeTest.class })
public class AllTests {
// JUnit for test suite
}

Back to the top