Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-04-03 15:46:59 +0000
committerptessier2014-04-03 15:46:59 +0000
commit5fd07e9f732256b72115a9ae91f24c7626f58e01 (patch)
tree0fdc991e561dc6f04e8da7f62649a28cc994ba7c
parent46940c8b6c5517e3e7abdfb30de83411b80340fb (diff)
downloadorg.eclipse.papyrus-5fd07e9f732256b72115a9ae91f24c7626f58e01.tar.gz
org.eclipse.papyrus-5fd07e9f732256b72115a9ae91f24c7626f58e01.tar.xz
org.eclipse.papyrus-5fd07e9f732256b72115a9ae91f24c7626f58e01.zip
431216: [All Diagrams] Layout issues in Compartments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=431216
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/command/CreateAppliedStereotypeViewCommand.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeConpartmentEditPart.java)6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java4
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestLayoutWithStereotype.java368
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestProfileApplication.java2
-rw-r--r--tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java127
9 files changed, 506 insertions, 21 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
index 20c2f3c77cf..5e0f438e42d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
@@ -183,7 +183,13 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
bound.width = container.width;
} else {
bound.x = container.x + 3;
- bound.y = container.y + ((container.height - totalHeight) / 2);
+ // in the case where the content is grater than the container
+ // it is forbidden to change the y coordinate
+ if(((container.height - totalHeight) / 2)>0 ){
+ bound.y = container.y + ((container.height - totalHeight) / 2);}
+ else{
+ bound.y = container.y;
+ }
bound.width = container.width;
}
child.setBounds(bound);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
index 8588ff9bb04..da422aeaec1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
@@ -20,7 +20,7 @@
<object
class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)"
id="StereotypePropertiesEditPartProvider">
- <method name="getType()" value="AppliedStereotypeContainer,AppliedStereotypeProperty,AppliedStereotypesComment,AppliedStereotypesCommentLink"/>
+ <method name="getType()" value="AppliedStereotypeCompartment,AppliedStereotypeProperty,AppliedStereotypesComment,AppliedStereotypesCommentLink"/>
</object>
</editpartProvider>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/command/CreateAppliedStereotypeViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/command/CreateAppliedStereotypeViewCommand.java
index ce489a3e042..170adacc280 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/command/CreateAppliedStereotypeViewCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/command/CreateAppliedStereotypeViewCommand.java
@@ -21,7 +21,7 @@ import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.TitleStyle;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
/**
* the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes
@@ -62,7 +62,7 @@ public class CreateAppliedStereotypeViewCommand extends RecordingCommand {
ts.setShowTitle(true);
compartment.getStyles().add(ts);
compartment.setElement(StereotypeApplication);
- compartment.setType(AppliedStereotypeConpartmentEditPart.ID);
+ compartment.setType(AppliedStereotypeCompartmentEditPart.ID);
ViewUtil.insertChildView(owner, compartment, ViewUtil.APPEND, false);
compartment.setMutable(true);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeConpartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java
index bfdc311036c..fcf2508871a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeConpartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java
@@ -38,11 +38,11 @@ import org.eclipse.uml2.uml.util.UMLUtil;
* this compartment is the an editpart associated to an applied stereotype
*/
-public class AppliedStereotypeConpartmentEditPart extends ResizeableListCompartmentEditPart {
+public class AppliedStereotypeCompartmentEditPart extends ResizeableListCompartmentEditPart {
- public static String ID = "AppliedStereotypeCompartement";
+ public static String ID = "AppliedStereotypeCompartment";
- public AppliedStereotypeConpartmentEditPart(View view) {
+ public AppliedStereotypeCompartmentEditPart(View view) {
super(view);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
index c53aa2a17fc..5aa0fb7a0bc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
@@ -35,7 +35,7 @@ import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.command.CreateAppliedStereotypeViewCommand;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
import org.eclipse.papyrus.uml.tools.listeners.PapyrusStereotypeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
@@ -299,7 +299,7 @@ public class AppliedStereotypeCompartmentEditPolicy extends AppliedStereotypeNod
});
}
// the sub nodes has the type appliedStereotypeCompartment but does not references a application of stereotype
- if((currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) && (!(currentNode.getElement() instanceof DynamicEObjectImpl))) {
+ if((currentNode.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) && (!(currentNode.getElement() instanceof DynamicEObjectImpl))) {
//yes, Execution of the Deletion command
editPart.getEditingDomain().runExclusive(new Runnable() {
@@ -339,7 +339,7 @@ public class AppliedStereotypeCompartmentEditPolicy extends AppliedStereotypeNod
while(i < node.getChildren().size()) {
if((node.getChildren().get(i)) instanceof Node) {
final Node currentNode = (Node)(node.getChildren().get(i));
- if(currentNode.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
+ if(currentNode.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
EObject stereotypeApplication = currentNode.getElement();
Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
if(stereotype != null && stereotypesPropertiesToDisplay.contains(stereotype.getQualifiedName())) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
index 6ac1704eb9c..69a4c6604ff 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
@@ -23,7 +23,7 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.providers.RestrictedAbstractEditPartProvider;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypePropertyEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypesCommentEditPart;
@@ -42,7 +42,7 @@ public class StereotypePropertiesEditPartProvider extends RestrictedAbstractEdit
public StereotypePropertiesEditPartProvider() {
super();
- nodeMap.put(AppliedStereotypeConpartmentEditPart.ID, AppliedStereotypeConpartmentEditPart.class);
+ nodeMap.put(AppliedStereotypeCompartmentEditPart.ID, AppliedStereotypeCompartmentEditPart.class);
nodeMap.put(AppliedStereotypePropertyEditPart.ID, AppliedStereotypeMultilinePropertyEditPart.class);
nodeMap.put(AppliedStereotypesCommentEditPart.ID, AppliedStereotypesCommentEditPart.class);
edgeMap.put(AppliedStereotypesCommentLinkEditPart.ID, AppliedStereotypesCommentLinkEditPart.class);
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestLayoutWithStereotype.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestLayoutWithStereotype.java
index 6863231c590..437dfd46782 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestLayoutWithStereotype.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestLayoutWithStereotype.java
@@ -43,12 +43,14 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPa
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.figure.node.AutomaticCompartmentLayoutManager;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.EditingFlowPage;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.StereotypePropertiesCompartment;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
@@ -70,10 +72,15 @@ public class TestLayoutWithStereotype extends AbstractPapyrusTestCase {
private static final String TEST_PROFILE_STEREOTYPE1 = "testProfile::Stereotype1";
@Test
- public void testToManageModel() {
+ public void testLayoutStereotypeApplicationOnClass() {
testToCreateANode(UMLElementTypes.Class_2008);
}
+ @Test
+ public void testLayoutStereotypeApplicationOnPackage() {
+ //testToCreateAPackage(UMLElementTypes.Package_2007);
+
+ }
/**
* Test to create a node.
@@ -211,7 +218,7 @@ public class TestLayoutWithStereotype extends AbstractPapyrusTestCase {
for(int i = 0; i < NotationClass1.getTransientChildren().size(); i++) {
View view = (View) NotationClass1.getTransientChildren().get(i);
- if(view.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
+ if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
appliedStereotypeCompartmentNotation = view;
}
if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
@@ -334,7 +341,7 @@ public class TestLayoutWithStereotype extends AbstractPapyrusTestCase {
stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
//look for the editpart that represents the property of applied stereotype
- stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeConpartmentEditPart.ID);
+ stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
@@ -427,6 +434,359 @@ public class TestLayoutWithStereotype extends AbstractPapyrusTestCase {
}
}
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateAPackage(IElementType type) {
+
+ //VARIABLES
+ org.eclipse.uml2.uml.Package package1=null;
+ //stereotype that is applied on class1
+ Stereotype stereotypeTest=null;
+ //view of the class
+ View NotationPackage1=null;
+ PackageFigure package1figure=null;
+ //editpart of class1
+ GraphicalEditPart packageEditPart=null;
+ //compartment of stereotype
+ View appliedStereotypeCompartmentNotation = null;
+ //compartment Shape
+ View shapeCompartmentView=null;
+ //the view of the applied stereotype property
+ View stereotypePropertyView=null;
+ GraphicalEditPart stereotypeCompartmentEdipart=null;
+ GraphicalEditPart stereotypePropertyEdipart=null;
+
+
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
+
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
+ //1 element element due to the reference to the profile
+ assertTrue(CREATION + INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size() == 1);
+
+
+ {//execution of the command
+ 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);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
+ }
+
+
+
+ //get the created Class
+ package1 = (org.eclipse.uml2.uml.Package)((org.eclipse.uml2.uml.Package)getRootSemanticModel()).getPackagedElement("Package1");
+ assertNotNull("created class must be not null", package1 );
+ //look for the editpart that the class
+ packageEditPart = (PackageEditPart)getDiagramEditPart().getChildren().get(0);
+ //test if stereotype can be applied
+ assertTrue("stereotype1 must be applicable on class1", package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);
+
+
+ //look for the applied stereotype compartment
+ NotationPackage1=packageEditPart.getNotationView();
+ {//execution of the command
+ SetBoundsCommand resizeCommand = new SetBoundsCommand(diagramEditor.getEditingDomain(),
+ "resize",
+ new EObjectAdapter((View) NotationPackage1),
+ new Rectangle(0, 0, 200, 200) );
+
+ assertTrue("CREATION: " + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, resizeCommand.canExecute() == true);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy( resizeCommand));
+ }
+ {//test about the layout
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
+ // now verify position of each subfigure
+ package1figure=((PackageFigure)nodePlate.getChildren().get(0));
+ package1figure.setBounds(new Rectangle(0,0,200,200));
+ assertTrue("The figure of package1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof Package);
+ package1figure.getLayoutManager().layout(package1figure);
+ assertTrue("The figure of the Class has not the good X coordinate",package1figure.getBounds().x==0);
+ assertTrue("The figure of the Class has not the good Y coordinate",package1figure.getBounds().y==0);
+ assertTrue("The figure of the Class has not the good width coordinate",package1figure.getBounds().width==200);
+ assertTrue("The figure of the Class has not the good height coordinate",package1figure.getBounds().height==200);
+
+ // At this moment the class figure must contain 4 sub-figures 1label+ 3compartments
+ assertTrue("The number of figure children must be equal to 4",package1figure.getChildren().size()==4);
+
+ //wrappinglabel for name
+ assertTrue("The sub figure [0] is not a wrapping label",package1figure.getChildren().get(0) instanceof WrappingLabel);
+ WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(0);
+
+ assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
+ assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==3);
+ assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
+ assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
+ assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));
+
+ assertTrue("The sub figure [0] is not a compartment",package1figure.getChildren().get(1) instanceof RectangleFigure);
+ RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(1);
+ assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+
+ // compartment for attribute
+ assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
+ assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==20);
+ assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
+ assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==59);
+
+
+ //compartment for operation
+ assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(2) instanceof RectangleFigure);
+ RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(2);
+ assertTrue("The sub figure [0] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
+ assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==80);
+ assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
+ assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==59);
+
+
+ // compartment for nested classifier
+ assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(3) instanceof RectangleFigure);
+ RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(3);
+ assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
+ assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==140);
+ assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
+ assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==59);
+
+ }
+
+ {// execution of the application of the stereotype
+ ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
+ stereotypeslist.add(package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)packageEditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
+ diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
+ assertTrue("No applied stereotype found on the element ", package1.getAppliedStereotypes().size() != 0);
+ }
+
+
+
+ for(int i = 0; i < NotationPackage1.getTransientChildren().size(); i++) {
+ View view = (View) NotationPackage1.getTransientChildren().get(i);
+ if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
+ appliedStereotypeCompartmentNotation = view;
+ }
+ if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
+ shapeCompartmentView= view;
+ }
+ }
+ // the mechanism of stereotype display is running.
+ //the thread is synchronous
+ assertTrue( "No stereotype Compartment found in the notation", appliedStereotypeCompartmentNotation != null);
+ assertTrue( "No stereotype shape Compartment found in the notation", shapeCompartmentView != null);
+
+ //now display stereotypes
+ stereotypeTest=package1.getAppliedStereotypes().get(0);
+
+ {//display stereotype1
+ RecordingCommand displayStereotypeCommand= AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(diagramEditor.getEditingDomain(), NotationPackage1,stereotypeTest.getQualifiedName() , UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
+
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayStereotypeCommand);
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
+
+ //get the label
+ org.eclipse.draw2d.Label stereotypeLabel=((ClassifierFigure)nodePlate.getChildren().get(0)).getStereotypesLabel();
+ assertTrue( "stereotype label must be not null" ,stereotypeLabel!=null);
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,stereotypeLabel.getText().equals("«stereotype1»"));
+ }
+
+ {//test about the layout
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
+ // now verify position of each subfigure
+ package1figure=((PackageFigure)nodePlate.getChildren().get(0));
+ package1figure.setBounds(new Rectangle(0,0,200,200));
+ assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
+ package1figure.getLayoutManager().layout(package1figure);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good X coordinate",package1figure.getBounds().x==0);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good Y coordinate",package1figure.getBounds().y==0);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good width coordinate",package1figure.getBounds().width==200);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good height coordinate",package1figure.getBounds().height==200);
+
+ // At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ 3compartments
+ assertTrue("The number of children «stereotype1»Class1 is not equals to 6",package1figure.getChildren().size()==5);
+
+
+ //wrappingLabel for stereotype
+ assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",package1figure.getChildren().get(0) instanceof Label);
+ Label stereotypelabelClass=(Label)package1figure.getChildren().get(0);
+
+ assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
+ assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
+ assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
+ assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
+ assertTrue("The label of the Class does not display «stereotype1»",stereotypelabelClass.getText().equals("«stereotype1»"));
+
+
+ //wrappingLabel for name
+ assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",package1figure.getChildren().get(1) instanceof WrappingLabel);
+ WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(1);
+
+ assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
+ assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
+ assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
+ assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
+ assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));
+
+ // compartment for property of stereotype
+ assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof RectangleFigure);
+ RectangleFigure stereotypePropertiesClass=(RectangleFigure)package1figure.getChildren().get(2);
+ assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",stereotypePropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+
+
+ assertTrue("The compartment attribute of the Class has not the good X coordinate",stereotypePropertiesClass.getBounds().x==1);
+ assertTrue("The compartment attribute of the Class has not the good Y coordinate",stereotypePropertiesClass.getBounds().y==36);
+ assertTrue("The compartment attribute of the Class has not the good width coordinate",stereotypePropertiesClass.getBounds().width==200);
+ assertTrue("The compartment attribute of the Class has not the good height coordinate",stereotypePropertiesClass.getBounds().height==54);
+
+
+ // compartment attribute
+ assertTrue("The sub figure [0] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof RectangleFigure);
+ RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(2);
+ assertTrue("The sub figure [0] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+
+
+ assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
+ assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==36);
+ assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
+ assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==54);
+
+
+ //compartment for operation
+ assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(3) instanceof RectangleFigure);
+ RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(3);
+ assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
+ assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==91);
+ assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
+ assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==54);
+
+ //compartment for nested classifier
+ assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(4) instanceof RectangleFigure);
+ RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(4);
+ assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
+ assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==146);
+ assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
+ assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==54);
+
+ }
+
+
+
+
+
+
+ {//test display of property of stereotype in compartment
+ RecordingCommand displayPropertyStereotypeCommand= AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(diagramEditor.getEditingDomain(), NotationPackage1,stereotypeTest.getQualifiedName()+".testInt");
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayPropertyStereotypeCommand);
+
+ //the compartment must be visible
+ assertTrue( "the compartment must be visible", appliedStereotypeCompartmentNotation.isVisible()==true);
+ //look for view that represents the property of the applied stereotype
+ stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
+ assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
+ //look for the editpart that represents the property of applied stereotype
+ stereotypeCompartmentEdipart=(GraphicalEditPart)packageEditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
+ stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
+ assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
+ assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
+ EditingFlowPage textarea=(EditingFlowPage)stereotypePropertyEdipart.getFigure();
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)textarea.getChildren().get(0)).getText().equals("testInt=0"));
+ }
+
+ {//test about the layout
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)packageEditPart.getFigure()).getChildren().get(0);
+ // now verify position of each subfigure
+ package1figure=((PackageFigure)nodePlate.getChildren().get(0));
+ package1figure.setBounds(new Rectangle(0,0,200,200));
+ assertTrue("The figure of «stereotype1»Class1 is not an automaticCompartmentLayoutManager",package1figure.getLayoutManager() instanceof AutomaticCompartmentLayoutManager);
+ package1figure.getLayoutManager().layout(package1figure);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good X coordinate",package1figure.getBounds().x==0);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good Y coordinate",package1figure.getBounds().y==0);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good width coordinate",package1figure.getBounds().width==200);
+ assertTrue("The figure of the «stereotype1»Class1 has not the good height coordinate",package1figure.getBounds().height==200);
+
+ // At this moment the class figure must contain 5 sub-figures 1 label for stereotype+ 1label for name+ compartment of stereotypes+ 3compartments
+ assertTrue("The number of children «stereotype1»Class1 is not equals to 6",package1figure.getChildren().size()==6);
+
+
+ //label for stereotype
+ assertTrue("The sub figure [0] of «stereotype1»Class1 is not a label",package1figure.getChildren().get(0) instanceof Label);
+ Label stereotypelabelClass=(Label)package1figure.getChildren().get(0);
+
+ assertTrue("The label of the Class has not the good X coordinate",stereotypelabelClass.getBounds().x==1);
+ assertTrue("The label of the Class has not the good Y coordinate",stereotypelabelClass.getBounds().y==3);
+ assertTrue("The label of the Class has not the good width coordinate",stereotypelabelClass.getBounds().width==200);
+ assertTrue("The label of the Class has not the good heightcoordinate",stereotypelabelClass.getBounds().height==15);
+ assertTrue("The label of the Class does not display «stereotype1»",stereotypelabelClass.getText().equals("«stereotype1»"));
+
+
+ //wrappingLabel for name
+ assertTrue("The sub figure [1] of «stereotype1»Class1 is not a wrapping label",package1figure.getChildren().get(1) instanceof WrappingLabel);
+ WrappingLabel labelClass=(WrappingLabel)package1figure.getChildren().get(1);
+
+ assertTrue("The label of the Class has not the good X coordinate",labelClass.getBounds().x==1);
+ assertTrue("The label of the Class has not the good Y coordinate",labelClass.getBounds().y==19);
+ assertTrue("The label of the Class has not the good width coordinate",labelClass.getBounds().width==200);
+ assertTrue("The label of the Class has not the good heightcoordinate",labelClass.getBounds().height==16);
+ assertTrue("The label of the Class does not display Class1",labelClass.getText().equals("Class1"));
+
+
+ // compartment for property of stereotypes
+ assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(2) instanceof StereotypePropertiesCompartment);
+ StereotypePropertiesCompartment sterotypesPropertiesClass=(StereotypePropertiesCompartment)package1figure.getChildren().get(2);
+
+ assertTrue("the stereotype properties compartment does not conent the compartment for a stereotype",sterotypesPropertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ ResizableCompartmentFigure compartmentFigure=(ResizableCompartmentFigure) sterotypesPropertiesClass.getChildren().get(0);
+ assertTrue("The content of the sterotype properties compartment is not an EditingFlowPage",compartmentFigure.getContentPane().getChildren().get(0) instanceof EditingFlowPage);
+ EditingFlowPage stereotypeProperty= (EditingFlowPage)compartmentFigure.getContentPane().getChildren().get(0);
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)stereotypeProperty.getChildren().get(0)).getText().equals("testInt=0"));
+
+ assertTrue("The compartment property of stereotypes of the Class has not the good X coordinate",sterotypesPropertiesClass.getBounds().x==1);
+ assertTrue("The compartment property of stereotypes of the Class has not the good Y coordinate",sterotypesPropertiesClass.getBounds().y==36);
+ assertTrue("The compartment property of stereotypes of the Class has not the good width coordinate",sterotypesPropertiesClass.getBounds().width==200);
+ assertTrue("The compartment property of stereotypes of the Class has not the good height coordinate",sterotypesPropertiesClass.getBounds().height==51);
+
+ //compartment for attribute
+ assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(3) instanceof RectangleFigure);
+ RectangleFigure propertiesClass=(RectangleFigure)package1figure.getChildren().get(3);
+ assertTrue("The sub figure [2] is not the attribute compartment is not a ResizableCompartmentFigure",propertiesClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+
+ assertTrue("The compartment attribute of the Class has not the good X coordinate",propertiesClass.getBounds().x==1);
+ assertTrue("The compartment attribute of the Class has not the good Y coordinate",propertiesClass.getBounds().y==88);
+ assertTrue("The compartment attribute of the Class has not the good width coordinate",propertiesClass.getBounds().width==200);
+ assertTrue("The compartment attribute of the Class has not the good height coordinate",propertiesClass.getBounds().height==37);
+
+
+ //compartment for operation
+ assertTrue("The sub figure [2] of «stereotype1»Class1 is not a compartment",package1figure.getChildren().get(4) instanceof RectangleFigure);
+ RectangleFigure operationsClass=(RectangleFigure)package1figure.getChildren().get(4);
+ assertTrue("The sub figure [2] is not the operation compartment is not a ResizableCompartmentFigure",operationsClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment operation of the Class has not the good X coordinate",operationsClass.getBounds().x==1);
+ assertTrue("The compartment operation of the Class has not the good y coordinate",operationsClass.getBounds().y==126);
+ assertTrue("The compartment operation of the Class has not the good width coordinate",operationsClass.getBounds().width==200);
+ assertTrue("The compartment operation of the Class has not the good height coordinate",operationsClass.getBounds().height==37);
+
+ //compartment for nested classifier
+ assertTrue("The figure of class1 is not an automaticCompartmentLayoutManager",package1figure.getChildren().get(5) instanceof RectangleFigure);
+ RectangleFigure innerclassifiersClass=(RectangleFigure)package1figure.getChildren().get(5);
+ assertTrue("The sub figure [0] is not the nested Classifier compartment is not a ResizableCompartmentFigure",innerclassifiersClass.getChildren().get(0) instanceof ResizableCompartmentFigure);
+ assertTrue("The compartment nested classifier of the Class has not the good X coordinate",innerclassifiersClass.getBounds().x==1);
+ assertTrue("The compartment nested classifier of the Class has not the good Y coordinate",innerclassifiersClass.getBounds().y==164);
+ assertTrue("The compartment nested classifier of the Class has not the good width coordinate",innerclassifiersClass.getBounds().width==200);
+ assertTrue("The compartment nested classifier of the Class has not the good Height coordinate",innerclassifiersClass.getBounds().height==37);
+
+ }
+ }
+
+
@Before
@Override
protected void setUp() throws Exception {
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestProfileApplication.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestProfileApplication.java
index f46ca5ce625..730844e5724 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestProfileApplication.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestProfileApplication.java
@@ -29,7 +29,7 @@ import org.junit.Test;
public class TestProfileApplication extends AbstractPapyrusTestCase {
@Test
- public void testToManageModel() throws ServiceException {
+ public void testProfileApplicationOnModel() throws ServiceException {
RegisteredProfile registeredProfile = RegisteredProfile.getRegisteredProfile("TestProfile");
final Model root = ((Model)getDiagramEditPart().resolveSemanticElement());
assertTrue("Registered profile not found", registeredProfile != null);
diff --git a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
index 4c88dd3f61a..b2f629e03de 100644
--- a/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
+++ b/tests/junit/plugins/uml/org.eclipse.papyrus.diagram.stereotypeproperty.tests/src/org/eclipse/papyrus/diagram/stereotypeproperty/TestStereotypeApplication.java
@@ -34,10 +34,12 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IShapeCompartmentEditPa
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassEditPart;
+import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.PackageEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.EditingFlowPage;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeConpartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.PackageFigure;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
@@ -56,10 +58,16 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
private static final String TEST_PROFILE_STEREOTYPE1 = "testProfile::Stereotype1";
@Test
- public void testToManageModel() {
+ public void testStereotypeApplicationOnClass() {
testToCreateANode(UMLElementTypes.Class_2008);
}
+
+ @Test
+ public void testStereotypeApplicationOnPackage() {
+ testToCreateAPackage(UMLElementTypes.Package_2007);
+
+ }
/**
* Test to create a node.
@@ -125,7 +133,7 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
for(int i = 0; i < NotationClass1.getTransientChildren().size(); i++) {
View view = (View) NotationClass1.getTransientChildren().get(i);
- if(view.getType().equals(AppliedStereotypeConpartmentEditPart.ID)) {
+ if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
appliedStereotypeCompartmentNotation = view;
}
if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
@@ -162,7 +170,7 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
//look for the editpart that represents the property of applied stereotype
- stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeConpartmentEditPart.ID);
+ stereotypeCompartmentEdipart=(GraphicalEditPart)classEditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
@@ -188,4 +196,115 @@ public class TestStereotypeApplication extends AbstractPapyrusTestCase {
}
+
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateAPackage(IElementType type) {
+
+ //VARIABLES
+ org.eclipse.uml2.uml.Package package1=null;
+ //stereotype that is applied on class1
+ Stereotype stereotypeTest=null;
+ //view of the class
+ View Notationpackage1=null;
+ //editpart of class1
+ GraphicalEditPart package1EditPart=null;
+ //compartment of stereotype
+ View appliedStereotypeCompartmentNotation = null;
+ //compartment Shape
+ View shapeCompartmentView=null;
+ //the view of the applied stereotype property
+ View stereotypePropertyView=null;
+ GraphicalEditPart stereotypeCompartmentEdipart=null;
+ GraphicalEditPart stereotypePropertyEdipart=null;
+
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, getDiagramEditPart().getChildren().size() == 0);
+
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 1);
+ //1 element element due to the reference to the profile
+ assertTrue(CREATION + INITIALIZATION_TEST, ((Model)getRootSemanticModel()).getAllAppliedProfiles().size() == 1);
+
+
+ {//execution of the command
+ 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);
+ diagramEditor.getDiagramEditDomain().getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootView().getChildren().size() == 1);
+ }
+
+ //get the created Class
+ package1 = (org.eclipse.uml2.uml.Package)((org.eclipse.uml2.uml.Package)getRootSemanticModel()).getPackagedElement("Package1");
+ assertNotNull("created class must be not null", package1 );
+ //look for the editpart that the class
+ package1EditPart = (PackageEditPart)getDiagramEditPart().getChildren().get(0);
+ //test if stereotype can be applied
+ assertTrue("stereotype1 must be applicable on class1", package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1) != null);
+
+ {// execution of the application of the stereotype
+ ArrayList<Stereotype> stereotypeslist = new ArrayList<Stereotype>();
+ stereotypeslist.add(package1.getApplicableStereotype(TEST_PROFILE_STEREOTYPE1));
+ ApplyStereotypeCommand applyStereotypeCommand = new ApplyStereotypeCommand(((Element)package1EditPart.resolveSemanticElement()), stereotypeslist, diagramEditor.getEditingDomain());
+ diagramEditor.getEditingDomain().getCommandStack().execute(applyStereotypeCommand);
+ assertTrue("No applied stereotype found on the element ", package1.getAppliedStereotypes().size() != 0);
+ }
+
+ //look for the applied stereotype compartment
+ Notationpackage1=package1EditPart.getNotationView();
+
+ for(int i = 0; i < Notationpackage1.getTransientChildren().size(); i++) {
+ View view = (View) Notationpackage1.getTransientChildren().get(i);
+ if(view.getType().equals(AppliedStereotypeCompartmentEditPart.ID)) {
+ appliedStereotypeCompartmentNotation = view;
+ }
+ if(view.getType().equals(IShapeCompartmentEditPart.VIEW_TYPE)) {
+ shapeCompartmentView= view;
+ }
+ }
+ // the mechanism of stereotype display is running.
+ //the thread is synchronous
+ assertTrue( "No stereotype Compartment found in the notation", appliedStereotypeCompartmentNotation != null);
+ assertTrue( "No stereotype shape Compartment found in the notation", shapeCompartmentView != null);
+
+ //now display stereotypes
+ stereotypeTest=package1.getAppliedStereotypes().get(0);
+
+ {//display stereotype1
+ RecordingCommand displayStereotypeCommand= AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(diagramEditor.getEditingDomain(), Notationpackage1,stereotypeTest.getQualifiedName() , UMLVisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
+
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayStereotypeCommand);
+ org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure nodePlate=(org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure)((BorderedNodeFigure)package1EditPart.getFigure()).getChildren().get(0);
+
+ //get the label
+ org.eclipse.draw2d.Label stereotypeLabel=((PackageFigure)nodePlate.getChildren().get(0)).getStereotypesLabel();
+ assertTrue( "stereotype label must be not null" ,stereotypeLabel!=null);
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,stereotypeLabel.getText().equals("«stereotype1»"));
+ }
+
+ {//test display of property of stereotype in compartment
+ RecordingCommand displayPropertyStereotypeCommand= AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(diagramEditor.getEditingDomain(), Notationpackage1,stereotypeTest.getQualifiedName()+".testInt");
+ diagramEditor.getEditingDomain().getCommandStack().execute(displayPropertyStereotypeCommand);
+
+ //the compartment must be visible
+ assertTrue( "the compartment must be visible", appliedStereotypeCompartmentNotation.isVisible()==true);
+ //look for view that represents the property of the applied stereotype
+ stereotypePropertyView=(View)appliedStereotypeCompartmentNotation.getChildren().get(0);
+ assertNotNull( "the view of the applied stereotype property must be created", stereotypePropertyView);
+ //look for the editpart that represents the property of applied stereotype
+ stereotypeCompartmentEdipart=(GraphicalEditPart)package1EditPart.getChildBySemanticHint(AppliedStereotypeCompartmentEditPart.ID);
+ stereotypePropertyEdipart=(GraphicalEditPart)stereotypeCompartmentEdipart.getChildBySemanticHint(AppliedStereotypeMultilinePropertyEditPart.ID);
+ assertNotNull( "the editpart of the applied stereotype compartment must be created", stereotypeCompartmentEdipart);
+ assertNotNull( "the editpart of the applied stereotype property must be created", stereotypePropertyEdipart);
+ EditingFlowPage textarea=(EditingFlowPage)stereotypePropertyEdipart.getFigure();
+ assertTrue( "text of stereotype label be equals to «stereotype1» " ,((TextFlowEx)textarea.getChildren().get(0)).getText().equals("testInt=0"));
+ }
+ }
+
}

Back to the top