Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org')
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/Activator.java44
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/AllTests.java30
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java27
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests2.java11
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/FileUtil.java78
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/PopupUtil.java190
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestAdvancedDragDrop_364696.java169
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentDeletion_364804.java223
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentGates_364816.java232
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentKind_364710.java119
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentName_382951.java98
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperand_364701.java323
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCreationUndo_384618.java265
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionCombinedFragment_364813.java185
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionMove_364812.java300
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDestructionNode_384201.java136
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraints_384596.java206
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestExecutionSpecificationDimension_384572.java145
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGuardEdition_364808.java201
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestInteractionConstraint_382966.java182
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAlignment_364688.java115
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAutoResize_383723.java309
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineLabelCustomize_383722.java283
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageCreate_379661.java205
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageEndConstraint_364817.java164
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageLostFound_384202.java275
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessagesDeletion_364828.java278
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMovingCombinedFragment_364711.java125
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedCombinedFragment_364795.java97
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedExecution_384616.java199
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestObservationLink_364826.java455
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestParentBarAutoresize_385603.java222
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestSynchronousMessageCreation_364827.java194
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/AllCanonicalTests.java34
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/CreateSequenceDiagramCommand.java57
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/IChildTestProvider.java24
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ILinkTestProvider.java28
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ITestProvider.java32
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestChildNode.java235
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestCombinedFragmentChildNode.java177
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestLink.java471
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramChildNode.java210
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramLink.java252
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramTopNode.java139
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestTopNode.java316
45 files changed, 8060 insertions, 0 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/Activator.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/Activator.java
new file mode 100644
index 00000000000..722d5a0e4fc
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/Activator.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/AllTests.java
new file mode 100644
index 00000000000..485959c60d4
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/AllTests.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.tests;
+
+import org.eclipse.papyrus.uml.diagram.sequence.tests.bug.BugTests;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.bug.BugTests2;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.AllCanonicalTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * All tests together.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ AllCanonicalTests.class, BugTests.class, BugTests2.class })
+public class AllTests {
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
new file mode 100644
index 00000000000..6c9a8a912ba
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * All tests for bug.
+ */
+@RunWith(Suite.class)
+@SuiteClasses({ TestCombinedFragmentKind_364710.class, TestCombinedFragmentOperand_364701.class, TestLifelineAlignment_364688.class, TestMessageEndConstraint_364817.class, TestMessagesDeletion_364828.class, TestMovingCombinedFragment_364711.class, TestNestedCombinedFragment_364795.class, TestSynchronousMessageCreation_364827.class, TestCombinedFragmentGates_364816.class, TestCombinedFragmentDeletion_364804.class, TestDecompositionCombinedFragment_364813.class, TestDecompositionMove_364812.class, TestAdvancedDragDrop_364696.class, TestGuardEdition_364808.class, TestObservationLink_364826.class })
+public class BugTests {
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests2.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests2.java
new file mode 100644
index 00000000000..ded5dde482f
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests2.java
@@ -0,0 +1,11 @@
+package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({TestCombinedFragmentName_382951.class, TestCreationUndo_384618.class, TestDestructionNode_384201.class, TestDurationConstraints_384596.class, TestExecutionSpecificationDimension_384572.class, TestInteractionConstraint_382966.class, /*TestLifelineAutoResize_383723.class, TestLifelineLabelCustomize_383722.class,*/ TestMessageCreate_379661.class, TestMessageLostFound_384202.class, TestNestedExecution_384616.class, TestParentBarAutoresize_385603.class})
+public class BugTests2 {
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/FileUtil.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/FileUtil.java
new file mode 100644
index 00000000000..66ec1d8e41c
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/FileUtil.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.nio.charset.Charset;
+
+
+public class FileUtil {
+
+ /**
+ * @param in
+ * the input stream to read from.
+ * @return the contents of the inputstream.
+ */
+ public static String read(InputStream in) {
+ return read(new InputStreamReader(in, Charset.forName("UTF-8")));
+ }
+
+ /**
+ * @param url
+ * the URL to read from.
+ * @return the contents of the url.
+ */
+ public static String read(URL url) {
+ try {
+ return read(url.openStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @param in
+ * the reader to read from.
+ * @return the contents of the reader.
+ */
+ public static String read(Reader in) {
+ StringBuffer buffer = new StringBuffer();
+ try {
+ while(in.ready()) {
+ buffer.append((char)in.read());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ close(in);
+ }
+ return buffer.toString();
+ }
+
+
+ private static void close(Closeable c) {
+ if(c != null) {
+ try {
+ c.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/PopupUtil.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/PopupUtil.java
new file mode 100644
index 00000000000..26836246673
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/PopupUtil.java
@@ -0,0 +1,190 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
+
+
+public class PopupUtil {
+
+ static boolean menuPopup = false;
+
+ static int clickMenuIndex = 0;
+
+ public static boolean isMenuPopup() {
+ return menuPopup;
+ }
+
+ public static void addMenuListener(int clickIndex) {
+ menuPopup = false;
+ clickMenuIndex = clickIndex;
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Display.getDefault().addFilter(SWT.Show, menuListener);
+ Display.getDefault().addFilter(SWT.Hide, menuListener);
+ }
+ });
+ }
+
+ public static void removeMenuListener() {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Display.getDefault().removeFilter(SWT.Show, menuListener);
+ Display.getDefault().removeFilter(SWT.Hide, menuListener);
+ }
+ });
+ }
+
+ public static void click(final Menu bar) {
+ click(bar, 0);
+ }
+
+ public static void click(final Menu bar, int index) {
+ MenuItem[] items = bar.getItems();
+ if(items != null && index < items.length)
+ notifyEvent(items[index], SWT.Selection);
+
+ bar.setVisible(false);
+ bar.notifyListeners(SWT.Hide, new Event());
+ waitForComplete();
+ }
+
+ protected static void waitForComplete() {
+ boolean run = true;
+ while(run) {
+ try {
+ run = Display.getDefault().readAndDispatch();
+ } catch (Exception e) {
+ run = true;
+ }
+ }
+ }
+
+ public static void notifyEvent(final Widget menuItem, final int eventType) {
+ final Event event = new Event();
+ event.time = (int)System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = eventType;
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ menuItem.notifyListeners(eventType, event);
+ }
+ });
+
+ waitForComplete();
+ }
+
+ /**
+ * A private class to listen for the show/hide events.
+ */
+ static class ShowHideListener implements Listener {
+
+ /**
+ * Handles the event by checking if it is the proper event. If it is a show, then the current context menu is
+ * set. Otherwise it will be set to <code>null</code> if it is a hide event.
+ *
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ * @param event
+ * the event to check.
+ */
+ public void handleEvent(Event event) {
+ if(!(event.widget instanceof Menu))
+ return;
+ Menu menu = (Menu)event.widget;
+ if(hasStyle(menu, SWT.POP_UP)) {
+ if(event.type == SWT.Show) {
+ currentContextMenu = menu;
+ click(menu, clickMenuIndex);
+ menuPopup = true;
+ }
+ if(event.type == SWT.Hide)
+ currentContextMenu = null;
+ }
+ }
+ }
+
+ /**
+ * Checks if the widget has the given style.
+ *
+ * @param w
+ * the widget.
+ * @param style
+ * the style.
+ * @return <code>true</code> if the widget has the specified style bit set. Otherwise <code>false</code>.
+ */
+ public static boolean hasStyle(final Widget w, final int style) {
+ if((w == null) || w.isDisposed())
+ return false;
+ if(style == SWT.NONE)
+ return true;
+
+ final List<Boolean> list = new ArrayList<Boolean>();
+ w.getDisplay().syncExec(new Runnable() {
+
+
+ public void run() {
+ list.add((w.getStyle() & style) != 0);
+ }
+ });
+ return list.get(0);
+ }
+
+ private static Menu currentContextMenu;
+
+ private static Listener menuListener = new ShowHideListener();
+
+ private static Listener dialogCloseHandler = new Listener() {
+
+ public void handleEvent(Event event) {
+ if(event.widget instanceof Shell) {
+ Shell shell = (Shell)event.widget;
+ waitForComplete();
+ notifyEvent(shell.getDefaultButton(), SWT.Selection);
+ }
+ }
+ };
+
+ public static void addDialogCloseHandler() {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Display.getDefault().addFilter(SWT.Show, dialogCloseHandler);
+ }
+ });
+ }
+
+ public static void removeDialogCloseHandler() {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ Display.getDefault().removeFilter(SWT.Show, dialogCloseHandler);
+ }
+ });
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestAdvancedDragDrop_364696.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestAdvancedDragDrop_364696.java
new file mode 100644
index 00000000000..f0810227a3d
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestAdvancedDragDrop_364696.java
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.ConnectableElement;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.junit.Test;
+
+/**
+ * Drag and drop is not well supported for all elements of sequence diagrams. Dnd
+ * should be supported for all elements. Moreover, it would be interesting to have
+ * an advanced drag and drop support for some elements. For instance, a drag and
+ * drop of a ConnectableElement on an Interaction should create a Lifeline and
+ * reference the dropped ConnectableElement in the Lifeline "represents" property.
+ * A generic solution may be possible.
+ */
+public class TestAdvancedDragDrop_364696 extends TestTopNode {
+
+ private static final String UML_REPLACEMENT_TEMPLATE = "><nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_zAqbcIP8EeGnt9CMb_JfYQ\" name=\"Person\">" + "<ownedAttribute xmi:id=\"__-RhYIP8EeGnt9CMb_JfYQ\" name=\"company\" isStatic=\"true\" type=\"_6imi4IP8EeGnt9CMb_JfYQ\"/>" + "</nestedClassifier>" + "<nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_6imi4IP8EeGnt9CMb_JfYQ\" name=\"Company\">" + "<ownedAttribute xmi:type=\"uml:Port\" xmi:id=\"_1oQd4IP-EeGnt9CMb_JfYQ\" name=\"port1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EShort\"/>" + "</ownedAttribute>" + "<ownedAttribute xmi:id=\"_CVUmYIP_EeGnt9CMb_JfYQ\" name=\"Property1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EDouble\"/>" + "</ownedAttribute>" + "</nestedClassifier>" + "</packagedElement>" + "<packageImport xmi:id=\"_q19q4YP8EeGnt9CMb_JfYQ\">" + "<importedPackage xmi:type=\"uml:Model\" href=\"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0\"/>" + "</packageImport>";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ protected void projectCreation() {
+ 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());
+ }
+
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel((DiResourceSet)this.diResourceSet);
+ // diResourceSet.createsModels(file);
+ ICreationCommand command = getDiagramCommandCreation();
+ command.createDiagram((DiResourceSet)diResourceSet, null, "DiagramToTest");
+ diResourceSet.save(new NullProgressMonitor());
+
+ }
+ initUml();
+
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeAllEditors(true);
+
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception e) {
+ System.err.println("error " + e);
+ }
+ }
+
+ protected void initUml() throws CoreException {
+ IFile uml = project.getFile("ClazzDiagramTest.uml");
+ String content = FileUtil.read(uml.getContents());
+ content = content.replaceAll("/>", UML_REPLACEMENT_TEMPLATE);
+
+ uml.setContents(new ByteArrayInputStream(content.getBytes()), false, true, new NullProgressMonitor());
+ }
+
+ @Test
+ public void testDragDrop() {
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ {
+ Classifier p = interaction.getNestedClassifier("Person");
+ Feature feature = p.getFeature("company");
+
+ assertTrue("", getRootEditPart().getChildren().size() == 0);
+ dropObject(getRootEditPart(), feature);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(0) instanceof LifelineEditPart);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRepresents(((LifelineEditPart)getRootEditPart().getChildren().get(0))) == feature);
+ }
+ {
+ Classifier p = interaction.getNestedClassifier("Company");
+ Feature feature = p.getFeature("Property1");
+
+ dropObject(getRootEditPart(), feature);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 2);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(1) instanceof LifelineEditPart);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRepresents(((LifelineEditPart)getRootEditPart().getChildren().get(1))) == feature);
+ }
+
+ {
+ Classifier p = interaction.getNestedClassifier("Company");
+ Feature feature = p.getFeature("port1");
+
+ dropObject(getRootEditPart(), feature);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 3);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(2) instanceof LifelineEditPart);
+ assertTrue(DROP + TEST_THE_EXECUTION, getRepresents(((LifelineEditPart)getRootEditPart().getChildren().get(2))) == feature);
+ }
+ }
+
+ protected ConnectableElement getRepresents(LifelineEditPart editPart) {
+ Lifeline lifeline = (Lifeline)editPart.resolveSemanticElement();
+ return lifeline.getRepresents();
+ }
+
+ protected void dropObject(GraphicalEditPart parent, Object obj) {
+ int childrenSize = parent.getChildren().size();
+
+ DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
+ ArrayList list = new ArrayList();
+ list.add(obj);
+ dropObjectsRequest.setObjects(list);
+ dropObjectsRequest.setLocation(new Point(20, 20));
+ Command command = parent.getCommand(dropObjectsRequest);
+ assertNotNull(DROP + COMMAND_NULL, command);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(DROP + TEST_THE_EXECUTION, parent.getChildren().size() == childrenSize + 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(DROP + TEST_THE_UNDO, parent.getChildren().size() == childrenSize);
+
+ getDiagramCommandStack().redo();
+ assertTrue(DROP + TEST_THE_REDO, parent.getChildren().size() == childrenSize + 1);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentDeletion_364804.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentDeletion_364804.java
new file mode 100644
index 00000000000..cfc12612a63
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentDeletion_364804.java
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+/**
+ * Currently, deleting a combined fragments deletes all its contents. Sometimes,
+ * the user just wants to delete the combined fragment and keeping its content.
+ * It would be useful to give the possibility to not delete the combined
+ * fragment content. This would imply a refactoring of the model.
+ *
+ */
+public class TestCombinedFragmentDeletion_364804 extends TestTopNode {
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testCombinedFragmentDeleteAll() {
+ deleteAll(UMLElementTypes.CombinedFragment_3004);
+ }
+
+ @Test
+ public void testConsiderIgnoreFragmentDeleteAll() {
+ deleteAll(UMLElementTypes.ConsiderIgnoreFragment_3007);
+ }
+
+ @Test
+ public void testCombinedFragmentKeepContents() {
+ keepContents(UMLElementTypes.CombinedFragment_3004);
+ }
+
+ @Test
+ public void testConsiderIgnoreFragmentKeepContents() {
+ keepContents(UMLElementTypes.ConsiderIgnoreFragment_3007);
+ }
+
+ protected void deleteAll(IElementType type) {
+ createNode(type, getRootEditPart(), new Point(100, 100), new Dimension(200, 200));
+ waitForComplete();
+
+ // create child combined fragment
+ CombinedFragmentEditPart parentCFP = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)parentCFP.getChildren().get(0);
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ createNode(type, op, new Point(150, 150), new Dimension(100, 100));
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(200, 200), new Dimension(60, 240));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 2);
+ LifelineEditPart lifelineEP = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+
+ waitForComplete();
+ createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifelineEP, getAbsoluteCenter(lifelineEP).translate(0, 10), null);
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifelineEP.getChildren().size() == 2);
+
+ PopupUtil.addMenuListener(0);
+
+ { // destroy semantic
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = parentCFP.getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(0) instanceof LifelineEditPart);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, lifelineEP.getChildren().size() == 1); // action execution is deleted
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getRootEditPart().getChildren().size() == 2);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, lifelineEP.getChildren().size() == 2);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, getRootEditPart().getChildren().size() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, lifelineEP.getChildren().size() == 1);
+ }
+ getEMFCommandStack().undo();
+
+ { // delete view
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = parentCFP.getCommand(deleteViewRequest);
+
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(0) instanceof LifelineEditPart);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootEditPart().getChildren().size() == 2);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootEditPart().getChildren().size() == 1);
+ }
+ }
+
+ protected void keepContents(IElementType type) {
+ createNode(type, getRootEditPart(), new Point(100, 100), new Dimension(200, 200));
+ waitForComplete();
+
+ // create child combined fragment
+ CombinedFragmentEditPart parentCFP = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)parentCFP.getChildren().get(0);
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ createNode(type, op, new Point(150, 150), new Dimension(100, 100));
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(200, 200), new Dimension(60, 240));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 2);
+ LifelineEditPart lifelineEP = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+
+ waitForComplete();
+ createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifelineEP, getAbsoluteCenter(lifelineEP).translate(0, 10), null);
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifelineEP.getChildren().size() == 2);
+
+ PopupUtil.addMenuListener(1);
+
+ { // destroy semantic
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = parentCFP.getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 2);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(1) instanceof CombinedFragmentEditPart);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, lifelineEP.getChildren().size() == 2);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getRootEditPart().getChildren().size() == 2);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, lifelineEP.getChildren().size() == 2);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, getRootEditPart().getChildren().size() == 2);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, lifelineEP.getChildren().size() == 2);
+ }
+ getEMFCommandStack().undo();
+
+ { // delete view
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = parentCFP.getCommand(deleteViewRequest);
+
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 2);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, getRootEditPart().getChildren().size() == 2);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, getRootEditPart().getChildren().size() == 2);
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ page.closeAllEditors(false);
+ papyrusEditor = null;
+
+ waitForComplete();
+ PopupUtil.removeMenuListener();
+ }
+
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ // CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentGates_364816.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentGates_364816.java
new file mode 100644
index 00000000000..1a76e5b25ef
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentGates_364816.java
@@ -0,0 +1,232 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message2EditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message6EditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Message7EditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Message;
+import org.junit.Test;
+
+/**
+ * A different gate is created for each message that have a combined fragment as
+ * source or destination. This is incompatible with the UML standard. The first
+ * gate should be used as a source by the second message. A dialog box allowing
+ * the selection of an existing gate on a combined fragment would allow the reuse
+ * of that gate.
+ */
+public class TestCombinedFragmentGates_364816 extends TestLink {
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testMessageAsyc_Gate() {
+ installEnvironment(UMLElementTypes.Lifeline_3001, UMLElementTypes.CombinedFragment_3004);
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)target;
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+
+ // prepare link and gate
+ createLink(UMLElementTypes.Message_4004, source, target, getAbsoluteCenter(source), getLeft(target));
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().get(0) instanceof Message2EditPart);
+ assertTrue(CREATION + INITIALIZATION_TEST, cf.getCfragmentGates().size() == 1);
+
+ // check reuse of gate
+ PopupUtil.addDialogCloseHandler();
+ createLink(UMLElementTypes.Message_4004, source, target, getAbsoluteCenter(source).translate(0, 40), getLeft(target).translate(0, 40));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().get(1) instanceof Message2EditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, cf.getCfragmentGates().size() == 1);
+
+ Message2EditPart conn1 = (Message2EditPart)source.getSourceConnections().get(0);
+ Message2EditPart conn2 = (Message2EditPart)source.getSourceConnections().get(1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn1.resolveSemanticElement()).getReceiveEvent() == cf.getCfragmentGates().get(0));
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn2.resolveSemanticElement()).getReceiveEvent() == cf.getCfragmentGates().get(0));
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_UNDO, cf.getCfragmentGates().size() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_REDO, cf.getCfragmentGates().size() == 1);
+ }
+
+ @Test
+ public void testMessageFound_Gate() {
+ installEnvironment(UMLElementTypes.Lifeline_3001, UMLElementTypes.CombinedFragment_3004);
+ source = (GraphicalEditPart)source.getParent().getParent(); //interaction
+
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)target;
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+
+ // prepare link and gate
+ createLink(UMLElementTypes.Message_4009, source, target, new Point(0, 0), getLeft(target));
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().get(0) instanceof Message7EditPart);
+ assertTrue(CREATION + INITIALIZATION_TEST, cf.getCfragmentGates().size() == 1);
+
+ // check reuse of gate
+ PopupUtil.addDialogCloseHandler();
+ createLink(UMLElementTypes.Message_4009, source, target, new Point(0, 20), getLeft(target).translate(0, 40));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().get(1) instanceof Message7EditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, cf.getCfragmentGates().size() == 1);
+
+ Message7EditPart conn1 = (Message7EditPart)source.getSourceConnections().get(0);
+ Message7EditPart conn2 = (Message7EditPart)source.getSourceConnections().get(1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn1.resolveSemanticElement()).getReceiveEvent() == cf.getCfragmentGates().get(0));
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn2.resolveSemanticElement()).getReceiveEvent() == cf.getCfragmentGates().get(0));
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_UNDO, cf.getCfragmentGates().size() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_REDO, cf.getCfragmentGates().size() == 1);
+ }
+
+ @Test
+ public void testMessageLost_Gate() {
+ installEnvironment(UMLElementTypes.CombinedFragment_3004, UMLElementTypes.Lifeline_3001);
+ target = (GraphicalEditPart)target.getParent().getParent(); //interaction
+
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)source;
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+
+ // prepare link and gate
+ createLink(UMLElementTypes.Message_4008, source, target, getLeft(source), new Point(0, 150));
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + INITIALIZATION_TEST, source.getSourceConnections().get(0) instanceof Message6EditPart);
+ assertTrue(CREATION + INITIALIZATION_TEST, cf.getCfragmentGates().size() == 1);
+
+ // check reuse of gate
+ PopupUtil.addDialogCloseHandler();
+ createLink(UMLElementTypes.Message_4008, source, target, getLeft(source), new Point(0, 200));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().get(1) instanceof Message6EditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, cf.getCfragmentGates().size() == 1);
+
+ Message6EditPart conn1 = (Message6EditPart)source.getSourceConnections().get(0);
+ Message6EditPart conn2 = (Message6EditPart)source.getSourceConnections().get(1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn1.resolveSemanticElement()).getSendEvent() == cf.getCfragmentGates().get(0));
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((Message)conn2.resolveSemanticElement()).getSendEvent() == cf.getCfragmentGates().get(0));
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_UNDO, cf.getCfragmentGates().size() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 2);
+ assertTrue(CREATION + TEST_THE_REDO, cf.getCfragmentGates().size() == 1);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ waitForComplete();
+ PopupUtil.removeDialogCloseHandler();
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ public void installEnvironment(IElementType sourceType, IElementType targetType) {
+ //create the source
+ createNode(sourceType, getRootEditPart(), new Point(100, 100), new Dimension(62, 250));
+
+ //create the target
+ createNode(targetType, getRootEditPart(), new Point(300, 100), new Dimension(200, 200));
+
+ source = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ target = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+ }
+
+ protected Point getLeft(IGraphicalEditPart part) {
+ IFigure f = part.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getLeft().getCopy();
+ return c;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentKind_364710.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentKind_364710.java
new file mode 100644
index 00000000000..e0a211bb212
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentKind_364710.java
@@ -0,0 +1,119 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.gef.EditPart;
+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.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.InteractionOperatorKind;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+/**
+ * Currently, combined fragment kind can be changed only if the combined fragment
+ * has a unique operand. Kind modification should be allowed in the case of a
+ * combined fragment owing more than one operand when the modification is
+ * compatible with the number of operands. For instance, the change of seq kind to
+ * alt kind should be allowed.
+ *
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=364710
+ *
+ */
+public class TestCombinedFragmentKind_364710 extends TestTopNode {
+
+ private static final String CHANGE_OPERATOR_KIND = "Change Operator Kind: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testConsiderIgnoreFragment() {
+ createNode(UMLElementTypes.ConsiderIgnoreFragment_3007, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ ConsiderIgnoreFragmentEditPart cep = (ConsiderIgnoreFragmentEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+
+ // add operand
+ createNode(UMLElementTypes.InteractionOperand_3005, cfp, new Point(30, 100), new Dimension(100, 100));
+ assertTrue(CREATION + TEST_THE_EXECUTION, cfp.getChildren().size() == 2);
+
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ InteractionOperatorKind[] list = { InteractionOperatorKind.IGNORE_LITERAL, InteractionOperatorKind.CONSIDER_LITERAL };
+ for(int i = 0; i < list.length; i++) {
+ changeOperatorKind(cep, cf, list[i]);
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_THE_EXECUTION, cf.getInteractionOperator() == list[i]);
+ }
+ }
+
+ @Test
+ public void testCombinedFragment() {
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+
+ // add operand
+ createNode(UMLElementTypes.InteractionOperand_3005, cfp, new Point(30, 100), new Dimension(100, 100));
+ assertTrue(CREATION + TEST_THE_EXECUTION, cfp.getChildren().size() == 2);
+
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ InteractionOperatorKind[] list = { InteractionOperatorKind.ALT_LITERAL, InteractionOperatorKind.PAR_LITERAL, InteractionOperatorKind.STRICT_LITERAL, InteractionOperatorKind.CRITICAL_LITERAL, InteractionOperatorKind.ASSERT_LITERAL, InteractionOperatorKind.SEQ_LITERAL };
+ for(int i = 0; i < list.length; i++) {
+ changeOperatorKind(cep, cf, list[i]);
+ }
+ }
+
+ protected void changeOperatorKind(CombinedFragmentEditPart p, CombinedFragment cf, InteractionOperatorKind kind) {
+ EAttribute feature = UMLPackage.eINSTANCE.getCombinedFragment_InteractionOperator();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
+ SetRequest request = new SetRequest(p.getEditingDomain(), cf, feature, kind);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_THE_EXECUTION, cf.getInteractionOperator() == kind);
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentName_382951.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentName_382951.java
new file mode 100644
index 00000000000..530e5b1cc2c
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentName_382951.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.ConsiderIgnoreFragment;
+import org.junit.Test;
+
+/**
+ * Combined fragment name shall be displayed at the right upper corner of the fragment.
+ *
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=382951
+ *
+ */
+public class TestCombinedFragmentName_382951 extends TestTopNode {
+
+ private static final String PREF_STORE = "org.eclipse.papyrus.infra.gmfdiag.preferences";
+ private static final String COMBINED_FRAGMENT_KEY = "ELEMENT_PapyrusUMLSequenceDiagram_CombinedFragment_CombinedFragmentCompartment.compartment_name.visibility";
+ private static final String CONSIDER_FRAGMENT_KEY = "ELEMENT_PapyrusUMLSequenceDiagram_ConsiderIgnoreFragment_CombinedFragmentCompartment.compartment_name.visibility";
+
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testCombinedFragment() {
+ IEclipsePreferences store = InstanceScope.INSTANCE.getNode(PREF_STORE);
+ store.putBoolean(COMBINED_FRAGMENT_KEY, true);
+
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ WrappingLabel label = cep.getTitleLabel();
+ assertTrue(TEST_THE_EXECUTION, label.isVisible());
+ assertTrue(TEST_THE_EXECUTION, label.getText().equals(cf.getName()));
+
+ store.putBoolean(COMBINED_FRAGMENT_KEY, false);
+ assertFalse(TEST_THE_EXECUTION, label.isVisible());
+ }
+
+ @Test
+ public void testConsiderIgnoreFragment() {
+ IEclipsePreferences store = InstanceScope.INSTANCE.getNode(PREF_STORE);
+ store.putBoolean(CONSIDER_FRAGMENT_KEY, false);
+
+ createNode(UMLElementTypes.ConsiderIgnoreFragment_3007, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ ConsiderIgnoreFragmentEditPart cep = (ConsiderIgnoreFragmentEditPart)getRootEditPart().getChildren().get(0);
+ ConsiderIgnoreFragment cf = (ConsiderIgnoreFragment)cep.resolveSemanticElement();
+ WrappingLabel label = cep.getTitleLabel();
+ assertFalse(TEST_THE_EXECUTION, label.isVisible());
+
+ store.putBoolean(CONSIDER_FRAGMENT_KEY, true);
+ assertTrue(TEST_THE_EXECUTION, label.isVisible());
+ assertTrue(TEST_THE_EXECUTION, label.getText().equals(cf.getName()));
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperand_364701.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperand_364701.java
new file mode 100644
index 00000000000..975bd4c582d
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperand_364701.java
@@ -0,0 +1,323 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+/**
+ * Adding of operands is allowed, but it is not possible to delete an operand
+ * from a combined fragment. Moreover, the resize of operands is also not
+ * possible. https://bugs.eclipse.org/bugs/show_bug.cgi?id=364701
+ *
+ */
+public class TestCombinedFragmentOperand_364701 extends TestTopNode {
+
+ private static final String OPERAND_RESIZE = "Operand Resize: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testOperandAddDelete() {
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = setupCombinedFragment();
+
+ // add operand
+ {
+ createNode(UMLElementTypes.InteractionOperand_3005, cfp, new Point(50, 100), new Dimension(100, 100));
+ assertTrue(CREATION + TEST_THE_EXECUTION, cfp.getChildren().size() == 2);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, cfp.getChildren().size() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, cfp.getChildren().size() == 2);
+ }
+
+ { // delete operand
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = op.getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ waitForComplete();
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, cfp.getChildren().size() == 1);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, cfp.getChildren().size() == 2);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, cfp.getChildren().size() == 1);
+ }
+ getEMFCommandStack().undo();
+
+ { // delete view
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, cfp.getChildren().size() == 2);
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = op.getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, cfp.getChildren().size() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, cfp.getChildren().size() == 2);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, cfp.getChildren().size() == 1);
+ }
+ }
+
+ private CombinedFragmentCombinedFragmentCompartmentEditPart setupCombinedFragment() {
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(30, 80), new Dimension(100, 100));
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+ assertTrue(CREATION + INITIALIZATION_TEST, cfp.getChildren().size() == 1);
+ return cfp;
+ }
+
+ @Test
+ public void testOperandResizeHeight() {
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = setupCombinedFragment();
+ waitForComplete();
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ // resize operand north
+ {
+ Dimension deltaSize = new Dimension(0, 30);
+ Rectangle before = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + INITIALIZATION_TEST, before.height() == getAbsoluteBounds(cfp).height());
+
+ resizeNorth(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.height() == getAbsoluteBounds(cfp).height());
+ }
+
+ // resize operand south
+ {
+ Dimension deltaSize = new Dimension(0, 20);
+ resizeSouth(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.height() == getAbsoluteBounds(cfp).height());
+ }
+
+ // resize operand north
+ {
+ Dimension deltaSize = new Dimension(0, -20);
+ Rectangle before = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + INITIALIZATION_TEST, before.height() == getAbsoluteBounds(cfp).height());
+
+ resizeNorth(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.height() == getAbsoluteBounds(cfp).height());
+ }
+
+ // resize operand south
+ {
+ Dimension deltaSize = new Dimension(0, -20);
+ resizeSouth(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.height() == getAbsoluteBounds(cfp).height());
+ }
+ }
+
+ @Test
+ public void testOperandResizeWidth() {
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = setupCombinedFragment();
+ waitForComplete();
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+
+ // resize operand east
+ {
+ Dimension deltaSize = new Dimension(100, 0);
+ Rectangle before = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + INITIALIZATION_TEST, before.width() == getAbsoluteBounds(cfp).width());
+ resizeEast(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.width() == getAbsoluteBounds(cfp).width());
+ }
+
+ // resize operand west
+ {
+ Dimension deltaSize = new Dimension(20, 0);
+ resizeWest(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.width() == getAbsoluteBounds(cfp).width());
+ }
+
+ // resize operand east
+ {
+ Dimension deltaSize = new Dimension(-20, 0);
+ Rectangle before = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + INITIALIZATION_TEST, before.width() == getAbsoluteBounds(cfp).width());
+ resizeEast(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.width() == getAbsoluteBounds(cfp).width());
+ }
+
+ // resize operand west
+ {
+ Dimension deltaSize = new Dimension(-20, 0);
+ resizeWest(op, deltaSize);
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.width() == getAbsoluteBounds(cfp).width());
+ }
+ }
+
+ protected void resizeEast(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getRight(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.EAST);
+ req.setSizeDelta(deltaSize);
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ protected void resizeWest(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getLeft(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.WEST);
+ req.setSizeDelta(deltaSize);
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void resizeSouth(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getBottom(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.SOUTH);
+ req.setSizeDelta(deltaSize);
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void resizeNorth(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getTop(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.NORTH);
+ req.setSizeDelta(deltaSize);
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void manageResizeCommnad(IGraphicalEditPart op, Dimension deltaSize, Command c) {
+ assertNotNull(OPERAND_RESIZE + COMMAND_NULL, c);
+ assertTrue(OPERAND_RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(OPERAND_RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(OPERAND_RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(op)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(OPERAND_RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(op)));
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ // CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ protected Point getRight(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getRight();
+ return p;
+ }
+
+ protected Point getLeft(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getLeft();
+ return p;
+ }
+
+ private Point getBottom(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getBottom();
+ return p;
+ }
+
+ private Point getTop(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getTop();
+ return p;
+ }
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCreationUndo_384618.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCreationUndo_384618.java
new file mode 100644
index 00000000000..f3c9e9c6dfe
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCreationUndo_384618.java
@@ -0,0 +1,265 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+/**
+ * Undo doesn't work anymore for creation of the following elements: lifelines, messages, action and behavior executions.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384618
+ *
+ */
+public class TestCreationUndo_384618 extends TestLink {
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testLifeline() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, getRootEditPart().getChildren().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, getRootEditPart().getChildren().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, getRootEditPart().getChildren().size() == 1);
+ }
+
+ @Test
+ public void testActionExecution() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifeline1, new Point(131, 200), new Dimension(20, 40));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 2);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getChildren().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getChildren().size() == 2);
+ }
+
+ @Test
+ public void testBehaviorExecution() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline1, new Point(131, 200), new Dimension(20, 40));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 2);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getChildren().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getChildren().size() == 2);
+ }
+
+ @Test
+ public void testMessageAsync() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createLink(UMLElementTypes.Message_4004, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), getAbsoluteCenter(lifeline2).translate(0, 10));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testMessageDelete() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createLink(UMLElementTypes.Message_4007, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), getAbsoluteCenter(lifeline2).translate(0, 10));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+
+ @Test
+ public void testMessageCreate() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(150, 150), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createLink(UMLElementTypes.Message_4006, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), getAbsoluteCenter(lifeline2));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testMessageSync() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline1, new Point(131, 140), new Dimension(20, 60));
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline2, new Point(331, 200), new Dimension(20, 60));
+ waitForComplete();
+
+ IGraphicalEditPart source = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart target = (IGraphicalEditPart)lifeline2.getChildren().get(1);
+
+ createLink(UMLElementTypes.Message_4003, source, target, getAbsoluteCenter(source), getAbsoluteCenter(target).translate(0, -28));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+
+ }
+
+ @Test
+ public void testMessageReply() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline1, new Point(131, 140), new Dimension(20, 60));
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline2, new Point(331, 200), new Dimension(20, 60));
+ waitForComplete();
+
+ IGraphicalEditPart source = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart target = (IGraphicalEditPart)lifeline2.getChildren().get(1);
+
+ createLink(UMLElementTypes.Message_4005, source, target, getAbsoluteCenter(source), getAbsoluteCenter(target).translate(0, -28));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionCombinedFragment_364813.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionCombinedFragment_364813.java
new file mode 100644
index 00000000000..827e4596b86
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionCombinedFragment_364813.java
@@ -0,0 +1,185 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EReference;
+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.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+
+/**
+ * When a combined fragment is created on a part decomposition, the property
+ * "covered" of the combined fragment contains only the lifeline representing the
+ * part and not the lifelines representing the part decompositions. This property
+ * should also reference the lifelines representing the part decompositions that
+ * are covered by the combined fragment.
+ */
+public class TestDecompositionCombinedFragment_364813 extends TestTopNode {
+
+ private static final String CHANGE_REPRESENTS = "Change Represents: ";
+
+ private static final String UML_REPLACEMENT_TEMPLATE = "><nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_zAqbcIP8EeGnt9CMb_JfYQ\" name=\"Person\">" + "<ownedAttribute xmi:id=\"__-RhYIP8EeGnt9CMb_JfYQ\" name=\"company\" isStatic=\"true\" type=\"_6imi4IP8EeGnt9CMb_JfYQ\"/>" + "</nestedClassifier>" + "<nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_6imi4IP8EeGnt9CMb_JfYQ\" name=\"Company\">" + "<ownedAttribute xmi:type=\"uml:Port\" xmi:id=\"_1oQd4IP-EeGnt9CMb_JfYQ\" name=\"port1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EShort\"/>" + "</ownedAttribute>" + "<ownedAttribute xmi:id=\"_CVUmYIP_EeGnt9CMb_JfYQ\" name=\"Property1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EDouble\"/>" + "</ownedAttribute>" + "</nestedClassifier>" + "</packagedElement>" + "<packageImport xmi:id=\"_q19q4YP8EeGnt9CMb_JfYQ\">" + "<importedPackage xmi:type=\"uml:Model\" href=\"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0\"/>" + "</packageImport>";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ protected void projectCreation() {
+ 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());
+ }
+
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel((DiResourceSet)this.diResourceSet);
+ ICreationCommand command = getDiagramCommandCreation();
+ command.createDiagram((DiResourceSet)diResourceSet, null, "DiagramToTest");
+ diResourceSet.save(new NullProgressMonitor());
+
+ }
+ initUml();
+
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeAllEditors(true);
+
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception e) {
+ System.err.println("error " + e);
+ }
+ }
+
+ protected void initUml() throws CoreException {
+ IFile uml = project.getFile("ClazzDiagramTest.uml");
+ String content = FileUtil.read(uml.getContents());
+ content = content.replaceAll("/>", UML_REPLACEMENT_TEMPLATE);
+
+ uml.setContents(new ByteArrayInputStream(content.getBytes()), false, true, new NullProgressMonitor());
+ }
+
+ @Test
+ public void testCover() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(240, 200));
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(80, 120), new Dimension(200, 200));
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(200, 120), new Dimension(200, 200));
+
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ Classifier p = interaction.getNestedClassifier("Person");
+ changeRepresents(lifeline1, p.getFeature("company"));
+ assertTrue(CREATION + INITIALIZATION_TEST, !lifeline1.isInlineMode());
+ assertTrue(CREATION + INITIALIZATION_TEST, lifeline1.getChildren().size() == 1);
+
+ waitForComplete();
+ PopupUtil.addDialogCloseHandler();
+ createNode(UMLElementTypes.Lifeline_3001, lifeline1, new Point(100, 120), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, lifeline1, new Point(200, 120), new Dimension(62, 200));
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 3);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().get(1) instanceof LifelineEditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().get(2) instanceof LifelineEditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.isInlineMode());
+
+ waitForComplete();
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(1);
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ CombinedFragmentEditPart cep2 = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(2);
+ CombinedFragment cf2 = (CombinedFragment)cep2.resolveSemanticElement();
+ LifelineEditPart childLifeline = (LifelineEditPart)lifeline1.getChildren().get(1);
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, cf.getCovereds().size() == 3);
+ assertTrue(CREATION + TEST_THE_EXECUTION, cf2.getCovereds().size() == 2);
+ assertTrue(CREATION + TEST_THE_EXECUTION, !cf2.getCovereds().contains(childLifeline.resolveSemanticElement()));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ waitForComplete();
+ PopupUtil.removeDialogCloseHandler();
+ }
+
+ protected void changeRepresents(LifelineEditPart p, Object value) {
+ Lifeline lifeline = (Lifeline)p.resolveSemanticElement();
+ EReference feature = UMLPackage.eINSTANCE.getLifeline_Represents();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(lifeline);
+ SetRequest request = new SetRequest(p.getEditingDomain(), lifeline, feature, value);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_THE_EXECUTION, lifeline.getRepresents().equals(value));
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionMove_364812.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionMove_364812.java
new file mode 100644
index 00000000000..9945fb60fdf
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDecompositionMove_364812.java
@@ -0,0 +1,300 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+
+/**
+ * Current implementation of lifelines representing decompositions does'nt allow
+ * their moving (horizontally), resizing and resizing of the lifeline representing
+ * the father component. These operations should be allowed.
+ */
+public class TestDecompositionMove_364812 extends TestTopNode {
+
+ private static final String MOVE = "Move: ";
+
+ private static final String UML_REPLACEMENT_TEMPLATE = "><nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_zAqbcIP8EeGnt9CMb_JfYQ\" name=\"Person\">" + "<ownedAttribute xmi:id=\"__-RhYIP8EeGnt9CMb_JfYQ\" name=\"company\" isStatic=\"true\" type=\"_6imi4IP8EeGnt9CMb_JfYQ\"/>" + "</nestedClassifier>" + "<nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_6imi4IP8EeGnt9CMb_JfYQ\" name=\"Company\">" + "<ownedAttribute xmi:type=\"uml:Port\" xmi:id=\"_1oQd4IP-EeGnt9CMb_JfYQ\" name=\"port1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EShort\"/>" + "</ownedAttribute>" + "<ownedAttribute xmi:id=\"_CVUmYIP_EeGnt9CMb_JfYQ\" name=\"Property1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EDouble\"/>" + "</ownedAttribute>" + "</nestedClassifier>" + "</packagedElement>" + "<packageImport xmi:id=\"_q19q4YP8EeGnt9CMb_JfYQ\">" + "<importedPackage xmi:type=\"uml:Model\" href=\"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0\"/>" + "</packageImport>";
+
+ private static final String RESIZE = "Resize: ";
+
+ private static final String CHANGE_REPRESENTS = "Change Represents: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ protected void projectCreation() {
+ 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());
+ }
+
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel((DiResourceSet)this.diResourceSet);
+ ICreationCommand command = getDiagramCommandCreation();
+ command.createDiagram((DiResourceSet)diResourceSet, null, "DiagramToTest");
+ diResourceSet.save(new NullProgressMonitor());
+
+ }
+ initUml();
+
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeAllEditors(true);
+
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception e) {
+ System.err.println("error " + e);
+ }
+ }
+
+ protected void initUml() throws CoreException {
+ IFile uml = project.getFile("ClazzDiagramTest.uml");
+ String content = FileUtil.read(uml.getContents());
+ content = content.replaceAll("/>", UML_REPLACEMENT_TEMPLATE);
+
+ uml.setContents(new ByteArrayInputStream(content.getBytes()), false, true, new NullProgressMonitor());
+ }
+
+ @Test
+ public void testMoving() {
+ LifelineEditPart decomposition = setupDecomposition();
+ { // test move
+ moveLifeline(decomposition, new Point(50, 0));
+ moveLifeline(decomposition, new Point(-20, 0));
+ // move child
+ moveLifeline((LifelineEditPart)decomposition.getChildren().get(1), new Point(10, 0));
+ moveLifeline((LifelineEditPart)decomposition.getChildren().get(2), new Point(-10, 0));
+ }
+ }
+
+ @Test
+ public void testResizing() {
+ LifelineEditPart decomposition = setupDecomposition();
+ // resize decomposition
+ {
+ resizeEast(decomposition, new Dimension(50, 0));
+ resizeEast(decomposition, new Dimension(-20, 0));
+ resizeWest(decomposition, new Dimension(30, 0));
+ resizeWest(decomposition, new Dimension(-10, 0));
+ }
+
+ { // resize child
+ resizeEast((LifelineEditPart)decomposition.getChildren().get(1), new Dimension(20, 0));
+ resizeEast((LifelineEditPart)decomposition.getChildren().get(1), new Dimension(-10, 0));
+
+ resizeWest((LifelineEditPart)decomposition.getChildren().get(2), new Dimension(20, 0));
+ resizeWest((LifelineEditPart)decomposition.getChildren().get(2), new Dimension(-10, 0));
+ }
+ }
+
+ private void manageResizeCommnad(IGraphicalEditPart part, Dimension deltaSize, Command c) {
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(part);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(part);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(part)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(part)));
+ }
+
+ protected void resizeEast(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getRight(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.EAST);
+ req.setSizeDelta(deltaSize);
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ protected void resizeWest(IGraphicalEditPart op, Dimension deltaSize) {
+ Point p = getLeft(op);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(PositionConstants.WEST);
+ req.setSizeDelta(deltaSize);
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ protected LifelineEditPart setupDecomposition() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(240, 200));
+
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ Classifier p = interaction.getNestedClassifier("Person");
+ changeRepresents(lifeline1, p.getFeature("company"));
+ assertTrue(CREATION + INITIALIZATION_TEST, !lifeline1.isInlineMode());
+ assertTrue(CREATION + INITIALIZATION_TEST, lifeline1.getChildren().size() == 1);
+
+ waitForComplete();
+ PopupUtil.addDialogCloseHandler();
+ createNode(UMLElementTypes.Lifeline_3001, lifeline1, new Point(100, 120), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, lifeline1, new Point(200, 120), new Dimension(62, 200));
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 3);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().get(1) instanceof LifelineEditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getChildren().get(2) instanceof LifelineEditPart);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.isInlineMode());
+ waitForComplete();
+ return lifeline1;
+ }
+
+ protected void moveLifeline(LifelineEditPart lifelineEP, Point moveDelta) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ req.setResizeDirection(moveDelta.x > 0 ? PositionConstants.EAST : PositionConstants.WEST);
+ req.setLocation(getAbsoluteCenter(lifelineEP));
+ req.setEditParts(lifelineEP);
+ req.setMoveDelta(moveDelta);
+
+ Command command = lifelineEP.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(lifelineEP);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(lifelineEP);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.x() - before.x() == moveDelta.x);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.y() - before.y() == moveDelta.y);
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(lifelineEP)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_REDO, after.equals(getAbsoluteBounds(lifelineEP)));
+ }
+
+ protected Point getLeft(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getLeft();
+ return p;
+ }
+
+ protected Point getRight(IGraphicalEditPart op) {
+ IFigure f = op.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point p = b.getRight();
+ return p;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ waitForComplete();
+ PopupUtil.removeDialogCloseHandler();
+ }
+
+ protected void changeRepresents(LifelineEditPart p, Object value) {
+ Lifeline lifeline = (Lifeline)p.resolveSemanticElement();
+ EReference feature = UMLPackage.eINSTANCE.getLifeline_Represents();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(lifeline);
+ SetRequest request = new SetRequest(p.getEditingDomain(), lifeline, feature, value);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_THE_EXECUTION, lifeline.getRepresents().equals(value));
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDestructionNode_384201.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDestructionNode_384201.java
new file mode 100644
index 00000000000..e4522972aa9
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDestructionNode_384201.java
@@ -0,0 +1,136 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+/**
+ * The icon of the tool "destruction node" is missing in the palette of the sequence diagram editor.
+ * The default size of the figure associated to the destruction node is too big and should be resizable.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384201
+ *
+ */
+public class TestDestructionNode_384201 extends TestTopNode {
+
+ private static final String RESIZE = "Resize: ";
+
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testResizeNorth() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.DestructionOccurrenceSpecification_3022, lifeline1, new Point(131, 150), new Dimension(20, 20));
+ DestructionOccurrenceSpecificationEditPart dsep = (DestructionOccurrenceSpecificationEditPart)lifeline1.getChildren().get(1);
+ resize(dsep, getAbsoluteBounds(dsep).getTop(), PositionConstants.NORTH, new Dimension(0, 20));
+ resize(dsep, getAbsoluteBounds(dsep).getTop(), PositionConstants.NORTH, new Dimension(0, -20));
+ }
+
+
+ @Test
+ public void testResizeWest() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.DestructionOccurrenceSpecification_3022, lifeline1, new Point(131, 150), new Dimension(20, 20));
+ DestructionOccurrenceSpecificationEditPart dsep = (DestructionOccurrenceSpecificationEditPart)lifeline1.getChildren().get(1);
+ resize(dsep, getAbsoluteBounds(dsep).getLeft(), PositionConstants.WEST, new Dimension(20, 0));
+ resize(dsep, getAbsoluteBounds(dsep).getLeft(), PositionConstants.WEST, new Dimension(-20, 0));
+ }
+
+ @Test
+ public void testResizeEast() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.DestructionOccurrenceSpecification_3022, lifeline1, new Point(131, 150), new Dimension(20, 20));
+ DestructionOccurrenceSpecificationEditPart dsep = (DestructionOccurrenceSpecificationEditPart)lifeline1.getChildren().get(1);
+ resize(dsep, getAbsoluteBounds(dsep).getRight(), PositionConstants.EAST, new Dimension(20, 0));
+ resize(dsep, getAbsoluteBounds(dsep).getRight(), PositionConstants.EAST, new Dimension(-20, 0));
+ }
+
+ private void resize(IGraphicalEditPart op, Point p, int resizeDir, Dimension deltaSize) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(resizeDir);
+ req.setSizeDelta(deltaSize);
+ if(resizeDir == PositionConstants.NORTH || resizeDir == PositionConstants.WEST)
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ verifyResizeCommnad(op, deltaSize, c);
+ }
+
+ private void verifyResizeCommnad(IGraphicalEditPart op, Dimension deltaSize, Command c) {
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(op)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(op)));
+ }
+
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraints_384596.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraints_384596.java
new file mode 100644
index 00000000000..5e2e38fff55
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraints_384596.java
@@ -0,0 +1,206 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
+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.Event;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.uml2.uml.ActionExecutionSpecification;
+import org.eclipse.uml2.uml.DurationConstraint;
+import org.eclipse.uml2.uml.Interval;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+import org.eclipse.uml2.uml.ValueSpecification;
+import org.junit.Test;
+
+/**
+ * An embedded textuel editor shall allow editing duration constraints. This editor shall be accessible on the diagram.
+ * When the two values of the interval are equal, the value shall be displayed only once.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384596
+ *
+ */
+public class TestDurationConstraints_384596 extends TestTopNode {
+
+ private static final String SEP = "..";
+
+ /** The occurrence specification(s) which are the nearest from a creation request */
+ public static final String NEAREST_OCCURRENCE_SPECIFICATION = "Nearest occurrence specification"; //$NON-NLS-1$
+
+ /** The occurrence specification(s) which are the nearest from a creation request (2nd end of creation) */
+ public static final String NEAREST_OCCURRENCE_SPECIFICATION_2 = "Nearest occurrence specification (end)"; //$NON-NLS-1$
+
+ private static final String EDIT = "Edit: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testDurationEdition() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200), null);
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(UMLElementTypes.ActionExecutionSpecification_3006, lifeline1, new Point(131, 200), new Dimension(20, 40), null);
+ waitForComplete();
+
+ ActionExecutionSpecificationEditPart esp = (ActionExecutionSpecificationEditPart)lifeline1.getChildren().get(1);
+ createDuraitonConstraint(lifeline1, esp);
+
+ DurationConstraintEditPart dp = (DurationConstraintEditPart)lifeline1.getChildren().get(2);
+
+ // edit text
+ WrappingLabel label = verifyEditText(dp, "1s", "2s");
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains("1s..2s"));
+
+ label = verifyEditText(dp, "d", "d+3");
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains("d..d+3"));
+
+ getEMFCommandStack().undo();
+ assertTrue(EDIT + TEST_THE_UNDO, label.getText().contains("1s..2s"));
+
+ label = verifyEditText(dp, "1", "1");
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains("1") && !label.getText().contains(SEP));
+
+ }
+
+ protected WrappingLabel verifyEditText(DurationConstraintEditPart dp, String min, String max) {
+ DurationConstraintLabelEditPart lp = (DurationConstraintLabelEditPart)dp.getChildren().get(0);
+ WrappingLabel label = performEditRequest(lp);
+
+ Composite composite = (Composite)lp.getViewer().getControl();
+ Text editor = findEditor(composite, label);
+
+ editor.setText(min + SEP + max);
+ input(editor, SWT.CR);
+
+ DurationConstraint constraint = (DurationConstraint)dp.resolveSemanticElement();
+ ValueSpecification spec = constraint.getSpecification();
+ assertTrue(EDIT + TEST_THE_EXECUTION, min.equals(ValueSpecificationUtil.getSpecificationValue(((Interval)spec).getMin())));
+ assertTrue(EDIT + TEST_THE_EXECUTION, max.equals(ValueSpecificationUtil.getSpecificationValue(((Interval)spec).getMax())));
+
+ waitForComplete();
+ return label;
+ }
+
+ protected void createDuraitonConstraint(final LifelineEditPart lifeline1, ActionExecutionSpecificationEditPart esp) {
+ ActionExecutionSpecification aes = (ActionExecutionSpecification)esp.resolveSemanticElement();
+
+ Map<String, Object> extendedData = new HashMap<String, Object>();
+ List<OccurrenceSpecification> events = new ArrayList<OccurrenceSpecification>(2);
+ events.add(aes.getStart());
+ extendedData.put(NEAREST_OCCURRENCE_SPECIFICATION, events);
+
+ events = new ArrayList<OccurrenceSpecification>(2);
+ events.add(aes.getFinish());
+ extendedData.put(NEAREST_OCCURRENCE_SPECIFICATION_2, events);
+
+ createNode(UMLElementTypes.DurationConstraint_3021, lifeline1, getAbsoluteBounds(esp).getBottom(), new Dimension(20, 40), extendedData);
+ waitForComplete();
+ }
+
+ public void input(Widget widget, char... character) {
+ if(widget.isDisposed())
+ return;
+
+ for(char c : character) {
+ Event e = createKeyEvent(widget, 0, c);
+ e.type = SWT.KeyDown;
+ widget.notifyListeners(SWT.KeyDown, e);
+
+ e = createKeyEvent(widget, 0, c);
+ e.type = SWT.KeyUp;
+ widget.notifyListeners(SWT.KeyUp, e);
+ }
+ waitForComplete();
+
+ Event e = new Event();
+ e.type = SWT.DefaultSelection;
+ widget.notifyListeners(SWT.DefaultSelection, e);
+ }
+
+ private Event createKeyEvent(Widget widget, int keyCode, char character) {
+ Event event = new Event();
+ event.time = (int)System.currentTimeMillis();
+ event.widget = widget;
+ event.display = Display.getDefault();
+ event.keyCode = keyCode;
+ event.character = character;
+ return event;
+ }
+
+ private Text findEditor(Composite composite, WrappingLabel label) {
+ for(Control c : composite.getChildren()) {
+ if(c instanceof Text) {
+ if(label.getText().equals(((Text)c).getText()))
+ return (Text)c;
+ }
+ }
+ return null;
+ }
+
+ protected WrappingLabel performEditRequest(DurationConstraintLabelEditPart lp) {
+ WrappingLabel label = (WrappingLabel)lp.getFigure();
+ Rectangle b = label.getBounds().getCopy();
+ label.translateToAbsolute(b);
+ DirectEditRequest req = new DirectEditRequest();
+ req.setLocation(b.getCenter());
+ lp.performRequest(req);
+ return label;
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size, Map<String, Object> extendedData) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ if(extendedData != null)
+ requestcreation.getExtendedData().putAll(extendedData);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestExecutionSpecificationDimension_384572.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestExecutionSpecificationDimension_384572.java
new file mode 100644
index 00000000000..ce340da22bb
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestExecutionSpecificationDimension_384572.java
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+/**
+ * Cannot reduce dimensions of Behavior Execution Specification box. The minimal height is 20.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384572
+ *
+ */
+public class TestExecutionSpecificationDimension_384572 extends TestTopNode {
+
+ private static final String RESIZE = "Resize: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testResizeActionExecutionNorth() {
+ resizeNorth(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testResizeBehaviorExecutionNorth() {
+ resizeNorth(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testResizeActionExecutionSouth() {
+ resizeSouth(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testResizeBehaviorExecutionSouth() {
+ resizeSouth(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ protected void resizeNorth(IElementType elementType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(elementType, lifeline1, new Point(131, 200), new Dimension(20, 40));
+ waitForComplete();
+
+ IGraphicalEditPart esp = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ resize(esp, getAbsoluteBounds(esp).getTop(), PositionConstants.NORTH, new Dimension(0, 30));
+ resize(esp, getAbsoluteBounds(esp).getTop(), PositionConstants.NORTH, new Dimension(0, -30));
+
+ resize(esp, getAbsoluteBounds(esp).getTop(), PositionConstants.NORTH, new Dimension(0, -20));
+ }
+
+ protected void resizeSouth(IElementType elementType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ createNode(elementType, lifeline1, new Point(131, 200), new Dimension(20, 40));
+ waitForComplete();
+
+ IGraphicalEditPart esp = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ resize(esp, getAbsoluteBounds(esp).getBottom(), PositionConstants.SOUTH, new Dimension(0, 30));
+ resize(esp, getAbsoluteBounds(esp).getBottom(), PositionConstants.SOUTH, new Dimension(0, -30));
+
+ resize(esp, getAbsoluteBounds(esp).getBottom(), PositionConstants.SOUTH, new Dimension(0, -20));
+ }
+
+ private void resize(IGraphicalEditPart op, Point p, int resizeDir, Dimension deltaSize) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(resizeDir);
+ req.setSizeDelta(deltaSize);
+ if(resizeDir == PositionConstants.NORTH || resizeDir == PositionConstants.WEST)
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void manageResizeCommnad(IGraphicalEditPart op, Dimension deltaSize, Command c) {
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(op)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(op)));
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGuardEdition_364808.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGuardEdition_364808.java
new file mode 100644
index 00000000000..6bae61e96a6
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGuardEdition_364808.java
@@ -0,0 +1,201 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+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.Event;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.InteractionConstraint;
+import org.eclipse.uml2.uml.InteractionOperatorKind;
+import org.eclipse.uml2.uml.LiteralInteger;
+import org.eclipse.uml2.uml.LiteralString;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+
+/**
+ * An advanced textual editor for combined fragments guards would allow to capture
+ * complex guards.
+ *
+ */
+public class TestGuardEdition_364808 extends TestTopNode {
+
+ private static final String CHANGE_OPERATOR_KIND = "Change Operator Kind: ";
+
+ private static final String EDIT = "Edit: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testEditText() {
+ InteractionOperandEditPart op = setupOperand();
+ WrappingLabel label = performEditRequest(op);
+
+ Composite composite = (Composite)op.getViewer().getControl();
+ Text editor = findEditor(composite, label);
+ assertNotNull(editor);
+ assertTrue(EDIT + INITIALIZATION_TEST, label.getText().contains(editor.getText()));
+
+ // edit text
+ String cond = "a < b";
+ editor.setText(cond);
+ input(editor, SWT.CR);
+ waitForComplete();
+
+ // verify
+ CombinedFragment cf = (CombinedFragment)((CombinedFragmentEditPart)getRootEditPart().getChildren().get(0)).resolveSemanticElement();
+ InteractionConstraint guard = cf.getOperands().get(0).getGuard();
+ assertTrue(EDIT + TEST_THE_EXECUTION, cond.equals(((LiteralString)guard.getSpecification()).getValue()));
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains(cond));
+ }
+
+ @Test
+ public void testEditLoop() {
+ InteractionOperandEditPart op = setupOperand();
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ changeOperatorKind(cep, (CombinedFragment)cep.resolveSemanticElement(), InteractionOperatorKind.LOOP_LITERAL);
+
+ WrappingLabel label = performEditRequest(op);
+
+ Composite composite = (Composite)op.getViewer().getControl();
+ Text editor = findEditor(composite, label);
+ assertNotNull(editor);
+
+ // edit text
+ String cond = "[1,10] a < b";
+ editor.setText(cond);
+ input(editor, SWT.CR);
+ waitForComplete();
+
+ // verify
+ CombinedFragment cf = (CombinedFragment)((CombinedFragmentEditPart)getRootEditPart().getChildren().get(0)).resolveSemanticElement();
+ InteractionConstraint guard = cf.getOperands().get(0).getGuard();
+ assertTrue(EDIT + TEST_THE_EXECUTION, "a < b".equals(((LiteralString)guard.getSpecification()).getValue()));
+ assertTrue(EDIT + TEST_THE_EXECUTION, ((LiteralInteger)guard.getMaxint()).getValue() == 10);
+ assertTrue(EDIT + TEST_THE_EXECUTION, ((LiteralInteger)guard.getMinint()).getValue() == 1);
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains("1,10"));
+ assertTrue(EDIT + TEST_THE_EXECUTION, label.getText().contains("a < b"));
+ }
+
+ protected InteractionOperandEditPart setupOperand() {
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ waitForComplete();
+ return op;
+ }
+
+ protected WrappingLabel performEditRequest(InteractionOperandEditPart op) {
+ WrappingLabel label = op.getPrimaryShape().getInteractionConstraintLabel();
+ Rectangle b = label.getBounds().getCopy();
+ label.translateToAbsolute(b);
+ DirectEditRequest req = new DirectEditRequest();
+ req.setLocation(b.getCenter());
+ op.performRequest(req);
+ return label;
+ }
+
+ private Text findEditor(Composite composite, WrappingLabel label) {
+ for(Control c : composite.getChildren()) {
+ if(c instanceof Text) {
+ if(label.getText().equals(((Text)c).getText()))
+ return (Text)c;
+ }
+ }
+ return null;
+ }
+
+ protected void changeOperatorKind(CombinedFragmentEditPart p, CombinedFragment cf, InteractionOperatorKind kind) {
+ EAttribute feature = UMLPackage.eINSTANCE.getCombinedFragment_InteractionOperator();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
+ SetRequest request = new SetRequest(p.getEditingDomain(), cf, feature, kind);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_THE_EXECUTION, cf.getInteractionOperator() == kind);
+ }
+
+ public void input(Widget widget, char... character) {
+ if(widget.isDisposed())
+ return;
+
+ for(char c : character) {
+ Event e = createKeyEvent(widget, 0, c);
+ e.type = SWT.KeyDown;
+ widget.notifyListeners(SWT.KeyDown, e);
+
+ e = createKeyEvent(widget, 0, c);
+ e.type = SWT.KeyUp;
+ widget.notifyListeners(SWT.KeyUp, e);
+ }
+ waitForComplete();
+ }
+
+ private Event createKeyEvent(Widget widget, int keyCode, char character) {
+ Event event = new Event();
+ event.time = (int)System.currentTimeMillis();
+ event.widget = widget;
+ event.display = Display.getDefault();
+ event.keyCode = keyCode;
+ event.character = character;
+ return event;
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestInteractionConstraint_382966.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestInteractionConstraint_382966.java
new file mode 100644
index 00000000000..b598b43be91
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestInteractionConstraint_382966.java
@@ -0,0 +1,182 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.util.Collections;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.Transaction;
+import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
+import org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl;
+import org.eclipse.gef.EditPart;
+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.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.InteractionConstraint;
+import org.eclipse.uml2.uml.InteractionOperatorKind;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+
+/**
+ * Minint and Maxint values are allways visible on the diagram, even when the guard of a loop combined fragment is deleted and also when these values
+ * are not defined. This interval shall not appear on the diagram when it is not defined in the model.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=382966
+ *
+ */
+public class TestInteractionConstraint_382966 extends TestTopNode {
+
+ private static final String CHANGE_OPERATOR_KIND = "Change Operator Kind: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testEditMaxint() {
+ InteractionOperandEditPart op = setupOperand();
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ changeOperatorKind(cep, (CombinedFragment)cep.resolveSemanticElement(), InteractionOperatorKind.LOOP_LITERAL);
+
+ CombinedFragment cf = (CombinedFragment)((CombinedFragmentEditPart)getRootEditPart().getChildren().get(0)).resolveSemanticElement();
+ final InteractionConstraint guard = cf.getOperands().get(0).getGuard();
+
+ executeCommandWithoutHistory(getRootEditPart().getEditingDomain(), new DummyCommand() {
+
+ public void execute() {
+ guard.setMaxint(null); // unset maxint
+ guard.setSpecification(null);
+ }
+ }, true);
+ waitForComplete();
+
+ WrappingLabel label = op.getPrimaryShape().getInteractionConstraintLabel();
+ assertTrue(TEST_THE_EXECUTION, label.getText().equals(""));
+ }
+
+ @Test
+ public void testEditMinint() {
+ InteractionOperandEditPart op = setupOperand();
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ changeOperatorKind(cep, (CombinedFragment)cep.resolveSemanticElement(), InteractionOperatorKind.LOOP_LITERAL);
+
+ CombinedFragment cf = (CombinedFragment)((CombinedFragmentEditPart)getRootEditPart().getChildren().get(0)).resolveSemanticElement();
+ final InteractionConstraint guard = cf.getOperands().get(0).getGuard();
+
+ executeCommandWithoutHistory(getRootEditPart().getEditingDomain(), new DummyCommand() {
+
+ public void execute() {
+ guard.setMinint(null); // unset maxint
+ guard.setSpecification(null);
+ }
+ }, true);
+ waitForComplete();
+
+ WrappingLabel label = op.getPrimaryShape().getInteractionConstraintLabel();
+ assertTrue(TEST_THE_EXECUTION, label.getText().equals(""));
+ }
+
+
+ /**
+ * Execute a EMF command without history
+ *
+ * @param editingDomain
+ * The editing domain
+ * @param command
+ * The command
+ * @param flag
+ */
+ public static void executeCommandWithoutHistory(EditingDomain editingDomain, org.eclipse.emf.common.command.Command command, boolean flag) {
+ TransactionalCommandStackImpl stack = new TransactionalCommandStackImpl();
+ stack.setEditingDomain((InternalTransactionalEditingDomain)editingDomain);
+ try {
+ stack.execute(command, Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (RollbackException e) {
+ e.printStackTrace();
+ }
+ }
+
+ static class DummyCommand extends org.eclipse.emf.common.command.AbstractCommand {
+
+ public void execute() {
+ }
+
+ public void redo() {
+ }
+
+ public void undo() {
+ }
+
+ protected boolean prepare() {
+ return true;
+ }
+ };
+
+ protected InteractionOperandEditPart setupOperand() {
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80), new Dimension(100, 100));
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ waitForComplete();
+ return op;
+ }
+
+ protected void changeOperatorKind(CombinedFragmentEditPart p, CombinedFragment cf, InteractionOperatorKind kind) {
+ EAttribute feature = UMLPackage.eINSTANCE.getCombinedFragment_InteractionOperator();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
+ SetRequest request = new SetRequest(p.getEditingDomain(), cf, feature, kind);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_THE_EXECUTION, cf.getInteractionOperator() == kind);
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAlignment_364688.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAlignment_364688.java
new file mode 100644
index 00000000000..add09e06b62
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAlignment_364688.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+
+/**
+ * All lifelines (except lifelines that are result of a create message) should be
+ * aligned vertically and must remain aligned.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688
+ *
+ */
+public class TestLifelineAlignment_364688 extends TestLink {
+
+ private static final String ALIGNMENT = "Alignment: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testAlignment() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(20, 20), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(150, 150), new Dimension(62, 200));
+
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ final LifelineEditPart lifeline3 = (LifelineEditPart)getRootEditPart().getChildren().get(2);
+
+ assertTrue(ALIGNMENT + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline1).y == getAbsoluteBounds(lifeline2).y);
+ assertTrue(ALIGNMENT + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline3).y == getAbsoluteBounds(lifeline2).y);
+ waitForComplete();
+
+ createLink(UMLElementTypes.Message_4006, lifeline2, lifeline3);
+ assertTrue(ALIGNMENT + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline1).y == getAbsoluteBounds(lifeline2).y);
+ assertTrue(ALIGNMENT + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline3).y > getAbsoluteBounds(lifeline2).y);
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+
+ Point c = getAbsoluteCenter((IGraphicalEditPart)source);
+ connectionRequest.setLocation(c);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+
+ Point t = getAbsoluteCenter((IGraphicalEditPart)target);
+ connectionRequest.setLocation(t);
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAutoResize_383723.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAutoResize_383723.java
new file mode 100644
index 00000000000..136169d7091
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineAutoResize_383723.java
@@ -0,0 +1,309 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.ByteArrayInputStream;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.Transaction;
+import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;
+import org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+/**
+ * When the width of a lifeline has been manually modified, it should not be in autosize mode
+ * (the size should not be modified when the Lifeline#represent property is set).
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=383723
+ *
+ */
+public class TestLifelineAutoResize_383723 extends TestTopNode {
+
+ private static final String RESIZE = "Resize: ";
+
+ private static final String CHANGE_REPRESENTS = "Change Represents: ";
+
+ private static final String UML_REPLACEMENT_TEMPLATE = "><nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_zAqbcIP8EeGnt9CMb_JfYQ\" name=\"Person\">" + "<ownedAttribute xmi:id=\"__-RhYIP8EeGnt9CMb_JfYQ\" name=\"company\" isStatic=\"true\" type=\"_6imi4IP8EeGnt9CMb_JfYQ\"/>" + "</nestedClassifier>" + "<nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_6imi4IP8EeGnt9CMb_JfYQ\" name=\"Company\">" + "<ownedAttribute xmi:type=\"uml:Port\" xmi:id=\"_1oQd4IP-EeGnt9CMb_JfYQ\" name=\"port1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EShort\"/>" + "</ownedAttribute>" + "<ownedAttribute xmi:id=\"_CVUmYIP_EeGnt9CMb_JfYQ\" name=\"Property1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EDouble\"/>" + "</ownedAttribute>" + "</nestedClassifier>" + "</packagedElement>" + "<packageImport xmi:id=\"_q19q4YP8EeGnt9CMb_JfYQ\">" + "<importedPackage xmi:type=\"uml:Model\" href=\"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0\"/>" + "</packageImport>";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testManualSize() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ RectangleFigure fig = lifeline1.getPrimaryShape().getFigureLifelineNameContainerFigure();
+ Rectangle bounds = fig.getBounds().getCopy();
+ fig.translateToAbsolute(bounds);
+
+ resize(lifeline1, bounds.getLeft(), PositionConstants.WEST, new Dimension(-20, 0)); // manual resize
+
+ Rectangle manualSize = getAbsoluteBounds(lifeline1);
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ Classifier p = interaction.getNestedClassifier("Person");
+
+ changeRepresents(lifeline1, p.getFeature("company"));
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline1).equals(manualSize));
+
+ changeRepresents(lifeline1, null);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline1).equals(manualSize));
+ }
+
+ @Test
+ public void testAutoSize() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), null);
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ Rectangle initBounds = getAbsoluteBounds(lifeline1);
+
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ Classifier p = interaction.getNestedClassifier("Person");
+ changeRepresents(lifeline1, p.getFeature("company"));
+ assertTrue(RESIZE + TEST_THE_EXECUTION, !getAbsoluteBounds(lifeline1).equals(initBounds));
+
+ // the size of the label should be undone if the represented element is set to null, or when the user uses the "Undo" action.
+ getEMFCommandStack().undo();
+ assertTrue(RESIZE + TEST_THE_UNDO, getAbsoluteBounds(lifeline1).equals(initBounds));
+ getEMFCommandStack().redo();
+
+ changeRepresents(lifeline1, null);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(lifeline1).equals(initBounds));
+ }
+
+
+ @Test
+ public void testPropertyChanged() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), null);
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ Rectangle initBounds = getAbsoluteBounds(lifeline1);
+
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ Classifier p = interaction.getNestedClassifier("Person");
+ final Property feature = (Property)p.getFeature("company");
+ changeRepresents(lifeline1, feature);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, !getAbsoluteBounds(lifeline1).equals(initBounds));
+
+ // change name
+ executeCommandWithoutHistory(getRootEditPart().getEditingDomain(), new DummyCommand() {
+
+ public void execute() {
+ feature.setName("abc");
+ }
+ }, true);
+
+ Rectangle bounds = getAbsoluteBounds(lifeline1);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, !bounds.equals(initBounds));
+
+ // change type
+ executeCommandWithoutHistory(getRootEditPart().getEditingDomain(), new DummyCommand() {
+
+ public void execute() {
+ feature.getType().setName("xy");
+ }
+ }, true);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, !getAbsoluteBounds(lifeline1).equals(initBounds));
+ assertTrue(RESIZE + TEST_THE_EXECUTION, !getAbsoluteBounds(lifeline1).equals(bounds));
+ }
+
+ /**
+ * Execute a EMF command without history
+ *
+ * @param editingDomain
+ * The editing domain
+ * @param command
+ * The command
+ * @param flag
+ */
+ public static void executeCommandWithoutHistory(EditingDomain editingDomain, org.eclipse.emf.common.command.Command command, boolean flag) {
+ TransactionalCommandStackImpl stack = new TransactionalCommandStackImpl();
+ stack.setEditingDomain((InternalTransactionalEditingDomain)editingDomain);
+ try {
+ stack.execute(command, Collections.singletonMap(Transaction.OPTION_UNPROTECTED, Boolean.TRUE));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (RollbackException e) {
+ e.printStackTrace();
+ }
+ }
+
+ static class DummyCommand extends org.eclipse.emf.common.command.AbstractCommand {
+
+ public void execute() {
+ }
+
+ public void redo() {
+ }
+
+ public void undo() {
+ }
+
+ protected boolean prepare() {
+ return true;
+ }
+ };
+
+ protected void projectCreation() {
+ 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());
+ }
+
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel((DiResourceSet)this.diResourceSet);
+ ICreationCommand command = getDiagramCommandCreation();
+ command.createDiagram((DiResourceSet)diResourceSet, null, "DiagramToTest");
+ diResourceSet.save(new NullProgressMonitor());
+
+ }
+ initUml();
+
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeAllEditors(true);
+
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception e) {
+ System.err.println("error " + e);
+ }
+ }
+
+ protected void initUml() throws CoreException {
+ IFile uml = project.getFile("ClazzDiagramTest.uml");
+ String content = FileUtil.read(uml.getContents());
+ content = content.replaceAll("/>", UML_REPLACEMENT_TEMPLATE);
+
+ uml.setContents(new ByteArrayInputStream(content.getBytes()), false, true, new NullProgressMonitor());
+ }
+
+ protected void changeRepresents(LifelineEditPart p, Object value) {
+ Lifeline lifeline = (Lifeline)p.resolveSemanticElement();
+ EReference feature = UMLPackage.eINSTANCE.getLifeline_Represents();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(lifeline);
+ SetRequest request = new SetRequest(p.getEditingDomain(), lifeline, feature, value);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ if(value != null)
+ assertTrue(CHANGE_REPRESENTS + TEST_THE_EXECUTION, lifeline.getRepresents().equals(value));
+ }
+
+ private void resize(IGraphicalEditPart op, Point p, int resizeDir, Dimension deltaSize) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(resizeDir);
+ req.setSizeDelta(deltaSize);
+ if(resizeDir == PositionConstants.NORTH || resizeDir == PositionConstants.WEST)
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void manageResizeCommnad(IGraphicalEditPart op, Dimension deltaSize, Command c) {
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(op)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(op)));
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineLabelCustomize_383722.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineLabelCustomize_383722.java
new file mode 100644
index 00000000000..bcd4a5788a4
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestLifelineLabelCustomize_383722.java
@@ -0,0 +1,283 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.gef.EditPart;
+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.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+/**
+ * It should be possible from property view (appearance) and from papyrus preferences to decide how the represented ConnectableElement appears in
+ * Lifeline label.
+ * One should be able to only show the represented element type name, or its name, or both. When the type is not set, one should have the choice to
+ * make it appear as undefined or to be systematically hidden.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=383722
+ *
+ */
+public class TestLifelineLabelCustomize_383722 extends TestTopNode {
+
+ private static final String LABEL = "Label: ";
+
+ private static final String CHANGE_REPRESENTS = "Change Represents: ";
+
+ /** key for the appearance of properties or other specific display */
+ public static final String CUSTOM_APPEARENCE_ANNOTATION = "CustomAppearance_Annotation";
+
+ /** key for the appearance of properties or other specific display */
+ public static final String CUSTOM_APPEARANCE_MASK_VALUE = "CustomAppearance_MaskValue";
+
+ public static final int SHOW_REPRESENT_NAME = 1 << 1;
+
+ public static final int SHOW_REPRESENT_TYPE = 1 << 2;
+
+ public static final int SHOW_UNDEFINED_TYPE = 1 << 3;
+
+ public static final int SHOW_LIFELINE_NAME = 1 << 4;
+
+ public static final String LABEL_DISPLAY_PREFERENCE = PackageEditPart.MODEL_ID + "_Lifeline.label.display";
+
+ private static final String UML_REPLACEMENT_TEMPLATE = "><nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_zAqbcIP8EeGnt9CMb_JfYQ\" name=\"Person\">" + "<ownedAttribute xmi:id=\"__-RhYIP8EeGnt9CMb_JfYQ\" name=\"company\" isStatic=\"true\" type=\"_6imi4IP8EeGnt9CMb_JfYQ\"/>" + "</nestedClassifier>" + "<nestedClassifier xmi:type=\"uml:Class\" xmi:id=\"_6imi4IP8EeGnt9CMb_JfYQ\" name=\"Company\">" + "<ownedAttribute xmi:type=\"uml:Port\" xmi:id=\"_1oQd4IP-EeGnt9CMb_JfYQ\" name=\"port1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EShort\"/>" + "</ownedAttribute>" + "<ownedAttribute xmi:id=\"_CVUmYIP_EeGnt9CMb_JfYQ\" name=\"Property1\">" + "<type xmi:type=\"uml:PrimitiveType\" href=\"pathmap://UML_METAMODELS/Ecore.metamodel.uml#EDouble\"/>" + "</ownedAttribute>" + "</nestedClassifier>" + "</packagedElement>" + "<packageImport xmi:id=\"_q19q4YP8EeGnt9CMb_JfYQ\">" + "<importedPackage xmi:type=\"uml:Model\" href=\"pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0\"/>" + "</packageImport>";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testLabelAppearence1() {
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ setLabelAppearence(lifeline1, SHOW_REPRESENT_NAME | SHOW_REPRESENT_TYPE);
+ assertTrue(LABEL, "company:Company".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelAppearence2() {
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ setLabelAppearence(lifeline1, SHOW_LIFELINE_NAME);
+ assertTrue(LABEL, "Lifeline".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelAppearence3() {
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ setLabelAppearence(lifeline1, SHOW_REPRESENT_TYPE);
+ assertTrue(LABEL, "Lifeline:Company".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelAppearence4() {
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ setLabelAppearence(lifeline1, SHOW_LIFELINE_NAME | SHOW_REPRESENT_NAME | SHOW_REPRESENT_TYPE);
+ assertTrue(LABEL, "Lifeline:Company".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelPreference1() {
+ setLabelPreference(SHOW_REPRESENT_NAME | SHOW_REPRESENT_TYPE);
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ assertTrue(LABEL, "company:Company".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelPreference2() {
+ setLabelPreference(SHOW_LIFELINE_NAME);
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ assertTrue(LABEL, "Lifeline".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelPreference3() {
+ setLabelPreference(SHOW_REPRESENT_TYPE);
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ assertTrue(LABEL, "Lifeline:Company".equals(label.getText()));
+ }
+
+ @Test
+ public void testLabelPreference4() {
+ setLabelPreference(SHOW_LIFELINE_NAME | SHOW_REPRESENT_NAME | SHOW_REPRESENT_TYPE);
+ final LifelineEditPart lifeline1 = setupLifeline();
+ WrappingLabel label = lifeline1.getPrimaryShape().getFigureLifelineLabelFigure();
+ assertTrue(LABEL, "Lifeline:Company".equals(label.getText()));
+ }
+
+ protected LifelineEditPart setupLifeline() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ // set lifeline represent
+ Interaction interaction = (Interaction)getRootSemanticModel();
+ Classifier p = interaction.getNestedClassifier("Person");
+ changeRepresents(lifeline1, p.getFeature("company"));
+ return lifeline1;
+ }
+
+ protected IPreferenceStore setLabelPreference(final int value) {
+ IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ store.setValue(LABEL_DISPLAY_PREFERENCE, value);
+ return store;
+ }
+
+ protected void setLabelAppearence(final LifelineEditPart lifeline1, final int value) {
+ DummyCommand c = new DummyCommand() {
+
+ public void execute() {
+ View view = lifeline1.getNotationView();
+ EAnnotation oldAnnotation = view.getEAnnotation(CUSTOM_APPEARENCE_ANNOTATION); //VisualInformationPapyrusConstants
+ if(oldAnnotation == null) {
+ oldAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ oldAnnotation.setSource(CUSTOM_APPEARENCE_ANNOTATION);
+ view.getEAnnotations().add(oldAnnotation);
+ }
+ oldAnnotation.getDetails().put(CUSTOM_APPEARANCE_MASK_VALUE, String.valueOf(value));
+ }
+ };
+ getEMFCommandStack().execute(c);
+ }
+
+ protected void projectCreation() {
+ 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());
+ }
+
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor());
+ diResourceSet.createsModels(file);
+ new CreateUMLModelCommand().createModel((DiResourceSet)this.diResourceSet);
+ ICreationCommand command = getDiagramCommandCreation();
+ command.createDiagram((DiResourceSet)diResourceSet, null, "DiagramToTest");
+ diResourceSet.save(new NullProgressMonitor());
+
+ }
+ initUml();
+
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ page.closeAllEditors(true);
+
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
+ page.openEditor(new FileEditorInput(file), desc.getId());
+ } catch (Exception e) {
+ System.err.println("error " + e);
+ }
+ }
+
+ protected void initUml() throws CoreException {
+ IFile uml = project.getFile("ClazzDiagramTest.uml");
+ String content = FileUtil.read(uml.getContents());
+ content = content.replaceAll("/>", UML_REPLACEMENT_TEMPLATE);
+
+ uml.setContents(new ByteArrayInputStream(content.getBytes()), false, true, new NullProgressMonitor());
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ protected void changeRepresents(LifelineEditPart p, Object value) {
+ Lifeline lifeline = (Lifeline)p.resolveSemanticElement();
+ EReference feature = UMLPackage.eINSTANCE.getLifeline_Represents();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(lifeline);
+ SetRequest request = new SetRequest(p.getEditingDomain(), lifeline, feature, value);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_REPRESENTS + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ if(value != null)
+ assertTrue(CHANGE_REPRESENTS + TEST_THE_EXECUTION, lifeline.getRepresents().equals(value));
+ }
+
+ static class DummyCommand extends org.eclipse.emf.common.command.AbstractCommand {
+
+ public void execute() {
+ }
+
+ public void redo() {
+ }
+
+ public void undo() {
+ }
+
+ protected boolean prepare() {
+ return true;
+ }
+ };
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageCreate_379661.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageCreate_379661.java
new file mode 100644
index 00000000000..47b5a9b7cfd
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageCreate_379661.java
@@ -0,0 +1,205 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+/**
+ * The active region to select the target Lifeline is very critical in the creation of the message Create. The active region should be header and the
+ * vertical bar.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=379661
+ *
+ */
+public class TestMessageCreate_379661 extends TestLink {
+
+ private static final String MOVE = "Move: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testHeaderAnchor() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(150, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ RectangleFigure fig = lifeline2.getPrimaryShape().getFigureLifelineNameContainerFigure();
+ Rectangle bounds = fig.getBounds().getCopy();
+ fig.translateToAbsolute(bounds);
+
+ createLink(UMLElementTypes.Message_4006, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), bounds.getCenter());
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+
+ @Test
+ public void testVerticalBarAnchor() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(150, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ IFigure fig = lifeline2.getPrimaryShape().getFigureLifelineDotLineFigure();
+ Rectangle bounds = fig.getBounds().getCopy();
+ fig.translateToAbsolute(bounds);
+
+ createLink(UMLElementTypes.Message_4006, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), bounds.getCenter());
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testMove() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(150, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ IFigure fig = lifeline2.getPrimaryShape().getFigureLifelineDotLineFigure();
+ Rectangle bounds = fig.getBounds().getCopy();
+ fig.translateToAbsolute(bounds);
+
+ createLink(UMLElementTypes.Message_4006, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), bounds.getCenter());
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ moveLifeline(lifeline1, new Point(20, 0));
+ moveLifeline(lifeline2, new Point(50, 0));
+ moveLifeline(lifeline2, new Point(-20, 0));
+
+ moveLifeline(lifeline2, new Point(0, 30));
+ moveLifeline(lifeline2, new Point(0, -10));
+ }
+
+ protected void moveLifeline(LifelineEditPart lifelineEP, Point moveDelta) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ if(moveDelta.x != 0)
+ req.setResizeDirection(moveDelta.x > 0 ? PositionConstants.EAST : PositionConstants.WEST);
+ if(moveDelta.y != 0)
+ req.setResizeDirection(moveDelta.y > 0 ? PositionConstants.SOUTH : PositionConstants.NORTH);
+ req.setLocation(getAbsoluteCenter(lifelineEP));
+ req.setEditParts(lifelineEP);
+ req.setMoveDelta(moveDelta);
+
+ Command command = lifelineEP.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(lifelineEP);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(lifelineEP);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.x() - before.x() == moveDelta.x);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.y() - before.y() == moveDelta.y);
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(lifelineEP)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_REDO, after.equals(getAbsoluteBounds(lifelineEP)));
+ }
+
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+} \ No newline at end of file
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageEndConstraint_364817.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageEndConstraint_364817.java
new file mode 100644
index 00000000000..f84d1d5d745
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageEndConstraint_364817.java
@@ -0,0 +1,164 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageEndEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.MessageEnd;
+import org.junit.Test;
+
+/**
+ * It is not possible to link a constraint to a messageEnd with a constraint Link.
+ * The selection of a messageEnd should be possible.
+ *
+ */
+public class TestMessageEndConstraint_364817 extends TestLink {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ public void checkConstraintLink(IElementType sourceType, IElementType targetType, IElementType linkType, IElementType subNodeType) {
+ installEnvironment(sourceType, targetType, subNodeType);
+
+ createNode(UMLElementTypes.Constraint_3008, getRootEditPart(), new Point(200, 400), new Dimension(100, 50));
+ createLink(linkType, source, target, getAbsoluteCenter(source), getAbsoluteCenter(target));
+ waitForComplete();
+
+ AbstractMessageEditPart linkEditPart = (AbstractMessageEditPart)source.getSourceConnections().get(0);
+ MessageEndEditPart linkEndPoint = null;
+ for(Object child : linkEditPart.getChildren())
+ if(child instanceof MessageEndEditPart)
+ linkEndPoint = (MessageEndEditPart) child;
+
+ ConstraintEditPart constraintEditPart = (ConstraintEditPart)getRootEditPart().getChildren().get(2);
+ createLink(UMLElementTypes.ConstraintConstrainedElement_4011, constraintEditPart, linkEndPoint, getAbsoluteCenter(constraintEditPart), getAbsoluteCenter(linkEndPoint));
+
+ Constraint constraint = (Constraint)constraintEditPart.resolveSemanticElement();
+ assertTrue(CREATION + TEST_THE_EXECUTION, constraint.getConstrainedElements().get(0) instanceof MessageEnd);
+ assertTrue(CREATION + TEST_THE_EXECUTION, constraintEditPart.getSourceConnections().size() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, constraintEditPart.getSourceConnections().size() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, constraintEditPart.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testMessageAsync_4004() {
+ checkConstraintLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4004, null);
+ }
+
+ @Test
+ public void testMessageSync_4003() {
+ checkConstraintLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4003, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testMessageReply_4005() {
+ checkConstraintLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4005, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testMessageDelete_4007() {
+ checkConstraintLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4007, null);
+ }
+
+ @Test
+ public void testMessageCreate_4006() {
+ checkConstraintLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4006, null);
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+
+ // get the connection end command
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ public void installEnvironment(IElementType sourceType, IElementType targetType, IElementType subNodeType) {
+ //create the source
+ createNode(sourceType, getRootEditPart(), new Point(100, 100), new Dimension(62, 250));
+
+ //create the target
+ createNode(targetType, getRootEditPart(), new Point(300, 100), new Dimension(62, 250));
+
+ source = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ target = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+
+ if(subNodeType != null) {
+ waitForComplete();
+ source = createSubNode(source, subNodeType, getAbsoluteCenter(source));
+ target = createSubNode(target, subNodeType, getAbsoluteCenter(target).translate(0, 50));
+ waitForComplete();
+ }
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageLostFound_384202.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageLostFound_384202.java
new file mode 100644
index 00000000000..7e8f4790f6b
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessageLostFound_384202.java
@@ -0,0 +1,275 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.AbstractPointListShape;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.IdentityAnchor;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+/**
+ * Within the sequence diagram editor, it not possible to model lost message,found message or general ordering.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384202
+ *
+ */
+public class TestMessageLostFound_384202 extends TestLink {
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testMessageFound() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+
+ waitForComplete();
+ source = (GraphicalEditPart)getRootEditPart().getParent();
+
+ createLink(UMLElementTypes.Message_4009, source, lifeline1, getAbsoluteCenter(source), getAbsoluteCenter(lifeline1)); // new Point(100,0)
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testMessageLost() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+
+ waitForComplete();
+ target = (GraphicalEditPart)getRootEditPart().getParent();
+
+ createLink(UMLElementTypes.Message_4008, lifeline1, target, getAbsoluteCenter(lifeline1), getAbsoluteCenter(target)); // getAbsoluteBounds(target).getBottomRight());
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline1.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline1.getSourceConnections().size() == 1);
+ }
+
+ @Test
+ public void testGeneralOrderingOnExecution() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete();
+
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline1, new Point(131, 140), new Dimension(20, 60));
+ createNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifeline2, new Point(331, 200), new Dimension(20, 60));
+ waitForComplete();
+
+ IGraphicalEditPart source = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart target = (IGraphicalEditPart)lifeline2.getChildren().get(1);
+
+ createLink(UMLElementTypes.GeneralOrdering_4012, source, target, getAbsoluteBounds(source).getTop(), getAbsoluteBounds(target).getTop());
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+
+ }
+
+ @Test
+ public void testGeneralOrderingOnMessage() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(200, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 200));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(400, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final LifelineEditPart lifeline2 = (LifelineEditPart)getRootEditPart().getChildren().get(1);
+ final LifelineEditPart lifeline3 = (LifelineEditPart)getRootEditPart().getChildren().get(2);
+ final LifelineEditPart lifeline4 = (LifelineEditPart)getRootEditPart().getChildren().get(3);
+ waitForComplete();
+
+ createLink(UMLElementTypes.Message_4004, lifeline1, lifeline2, getAbsoluteCenter(lifeline1).translate(0, -20), getAbsoluteCenter(lifeline2).translate(0, -20));
+ createLink(UMLElementTypes.Message_4004, lifeline3, lifeline4, getAbsoluteCenter(lifeline3).translate(0, 20), getAbsoluteCenter(lifeline4).translate(0, 20));
+ waitForComplete();
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline1.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline3.getSourceConnections().size() == 1);
+
+ AbstractMessageEditPart s = (AbstractMessageEditPart)lifeline1.getSourceConnections().get(0);
+ AbstractMessageEditPart t = (AbstractMessageEditPart)lifeline3.getSourceConnections().get(0);
+
+ createLink(UMLElementTypes.GeneralOrdering_4012, lifeline1, lifeline3, getAbsoluteEdgeExtremity(s, true), getAbsoluteEdgeExtremity(t, true));
+ waitForComplete();
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, lifeline3.getTargetConnections().size() == 1);
+
+ assertTrue(CREATION + TEST_THE_UNDO, getDiagramCommandStack().canUndo());
+ getEMFCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, lifeline3.getTargetConnections().size() == 0);
+
+ assertTrue(CREATION + TEST_THE_REDO, getDiagramCommandStack().canRedo());
+ getEMFCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, lifeline3.getTargetConnections().size() == 1);
+
+ }
+
+ /**
+ * Get the extremity of a connection edit part
+ *
+ * @param connection
+ * the connection edit part to find extremity
+ * @param isStart
+ * true to find the start, false for the end
+ * @return connection's extremity in absolute coordinates or null
+ */
+ public static Point getAbsoluteEdgeExtremity(ConnectionNodeEditPart connection, boolean isStart) {
+ Connection msgFigure = connection.getConnectionFigure();
+ if(connection.getNotationView() instanceof Edge) {
+ // rather take up to date model information
+ Edge edge = (Edge)connection.getNotationView();
+ Anchor idAnchor = null;
+ ConnectionAnchor conAnchor = null;
+ Object part = null;
+ if(isStart && connection.getSource() instanceof IGraphicalEditPart) {
+ View linkedFigure = edge.getSource();
+ // connection.getSource() may be not up to date, get part for linkedFigure
+ part = connection.getSource().getViewer().getEditPartRegistry().get(linkedFigure);
+ idAnchor = edge.getSourceAnchor();
+ conAnchor = msgFigure.getSourceAnchor();
+ } else if(!isStart && connection.getTarget() instanceof IGraphicalEditPart) {
+ View linkedFigure = edge.getTarget();
+ // connection.getTarget() may be not up to date, get part for linkedFigure
+ part = connection.getTarget().getViewer().getEditPartRegistry().get(linkedFigure);
+ idAnchor = edge.getTargetAnchor();
+ conAnchor = msgFigure.getTargetAnchor();
+ }
+ if(part instanceof IGraphicalEditPart && idAnchor instanceof IdentityAnchor && conAnchor != null) {
+ // take up to date bounds of the linked part in case it is moved
+ Rectangle linkedPartBounds = getAbsoluteBounds((IGraphicalEditPart)part);
+
+ IFigure anchorOwningFigure = conAnchor.getOwner();
+ IFigure partFigure = ((IGraphicalEditPart)part).getFigure();
+ Dimension delta = anchorOwningFigure.getBounds().getLocation().getDifference(partFigure.getBounds().getLocation());
+ // get position from anchor id
+ String oldTerminal = ((IdentityAnchor)idAnchor).getId();
+ PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal);
+ int xPos = linkedPartBounds.x + delta.width + (int)Math.round(anchorOwningFigure.getBounds().width * pp.preciseX);
+ int yPos = linkedPartBounds.y + delta.height + (int)Math.round(anchorOwningFigure.getBounds().height * pp.preciseY);
+ return new Point(xPos, yPos);
+ }
+ }
+ // can not get from model, rely on figure
+ if(msgFigure instanceof AbstractPointListShape) {
+ Point extremity;
+ if(isStart) {
+ // start event of the message
+ extremity = ((AbstractPointListShape)msgFigure).getStart().getCopy();
+ } else {
+ // finish event of the message
+ extremity = ((AbstractPointListShape)msgFigure).getEnd().getCopy();
+ }
+ msgFigure.getParent().translateToAbsolute(extremity);
+ return extremity;
+ }
+ return null;
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessagesDeletion_364828.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessagesDeletion_364828.java
new file mode 100644
index 00000000000..579b7cbcd46
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMessagesDeletion_364828.java
@@ -0,0 +1,278 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.ILinkTestProvider;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.MessageEnd;
+import org.junit.Test;
+
+/**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=364828
+ * When a message is deleted, its associated send and receive events are not
+ * deleted. These events must be deleted because new events are systematically
+ * created upon the creation of a new message.
+ *
+ * It fixes the deletion of the associated send MessageSend and receive
+ * MessageRecv events for
+ * - Message Sync
+ * - Message Async
+ * - Message Reply
+ * - Message Create
+ * - Message Delete
+ *
+ */
+public class TestMessagesDeletion_364828 extends TestLink {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Override
+ public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, ILinkTestProvider provider) {
+ CreateConnectionViewRequest request = super.createConnectionViewRequest(type, source, target, provider);
+ EObject container = getRootEditPart().resolveSemanticElement();
+ request.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ request.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+ return request;
+ }
+
+ public void deleteMessageEvents(IElementType sourceType, IElementType targetType, IElementType linkType, ILinkTestProvider provider) {
+ installEnvironment(sourceType, targetType, provider);
+ Interaction interaction = (Interaction)getRootEditPart().resolveSemanticElement();
+
+ // create message link
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, provider);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getDiagramCommandStack().execute(command);
+
+ // delete message link
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEdgesSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, getMessageEndCount(interaction.getFragments()) == 2);
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command delCommand = ((ConnectionEditPart)source.getSourceConnections().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, delCommand);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, delCommand != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, delCommand.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(delCommand));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, getMessageEndCount(interaction.getFragments()) == 0);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getMessageEndCount(interaction.getFragments()) == 2);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, getMessageEndCount(interaction.getFragments()) == 0);
+ }
+
+ private int getMessageEndCount(EList<InteractionFragment> fragments) {
+ int count = 0;
+ for(InteractionFragment f : fragments)
+ if(f instanceof MessageEnd)
+ count++;
+
+ return count;
+ }
+
+ @Test
+ public void testMessageAsync_4004() {
+ deleteMessageEvents(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4004, lifelineProvider);
+ }
+
+ @Test
+ public void testMessageSync_4003() {
+ deleteMessageEvents(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4003, executionProvider);
+ }
+
+ @Test
+ public void testMessageReply_4005() {
+ deleteMessageEvents(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4005, executionProvider);
+ }
+
+ @Test
+ public void testMessageDelete_4007() {
+ deleteMessageEvents(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4007, lifelineProvider);
+ }
+
+ @Test
+ public void testMessageCreate_4006() {
+ deleteMessageEvents(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4006, lifelineProvider);
+ }
+
+ protected ILinkTestProvider executionProvider = new ILinkTestProvider() {
+
+
+ public boolean hasSemanticChild() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.hasSemanticChild();
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getChildLocation(parentEditPart);
+ }
+
+ public int getEditPartChildrenSize() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getEditPartChildrenSize();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public int getSemanticChildrenSize() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getSemanticChildrenSize() - 4; // ignore ActionExecution
+ }
+
+ public int getViewChildrenSize() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getViewChildrenSize();
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getParentEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return null;
+ }
+
+ public int getEdgesSize() {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getEdgesSize();
+ }
+
+ public Point getConnectionSourceLocation(EditPart source) {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getConnectionSourceLocation(source);
+ }
+
+ public Point getConnectionTargetLocation(EditPart target) {
+ return TestMessagesDeletion_364828.this.lifelineProvider.getConnectionTargetLocation(target);
+ }
+
+ public void setUp() {
+ IElementType childNodeType = UMLElementTypes.ActionExecutionSpecification_3006;
+ source = createSubNode(source, childNodeType, getChildLocation(source));
+ sourcePlayer = createSubNode(sourcePlayer, childNodeType, getChildLocation(sourcePlayer));
+
+ target = createSubNode(target, childNodeType, getChildLocation(target).translate(0, 50));
+ targetPlayer = createSubNode(targetPlayer, childNodeType, getChildLocation(targetPlayer).translate(0, 50));
+ }
+
+ };
+
+ protected ILinkTestProvider lifelineProvider = new ILinkTestProvider() {
+
+ public int getEdgesSize() {
+ return getDiagramEditPart().getDiagramView().getEdges().size();
+ }
+
+ public int getEditPartChildrenSize() {
+ return getRootEditPart().getChildren().size();
+ }
+
+ public int getSemanticChildrenSize() {
+ int count = 0;
+ EList<Element> elems = ((Element)getRootEditPart().getNotationView().getElement()).getOwnedElements();
+ for(Element f : elems)
+ if(!(f instanceof MessageEnd) && !(f instanceof ExecutionOccurrenceSpecification))
+ count++;
+
+ return count;
+ }
+
+ public int getViewChildrenSize() {
+ return getRootEditPart().getNotationView().getChildren().size();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return getRootEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return null;
+ }
+
+ public Point getConnectionSourceLocation(EditPart part) {
+ if(part instanceof LifelineEditPart) {
+ IFigure f = ((LifelineEditPart)part).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f);
+ }
+ if(part instanceof AbstractExecutionSpecificationEditPart || part instanceof InteractionEditPart) { // found message
+ return getAbsoluteBounds((IGraphicalEditPart)part).getTopLeft();
+ }
+ return new Point(0, 0);
+ }
+
+ public Point getConnectionTargetLocation(EditPart part) {
+ if(part instanceof LifelineEditPart) {
+ IFigure f = ((LifelineEditPart)part).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f);
+ }
+ if(part instanceof AbstractExecutionSpecificationEditPart || part instanceof InteractionEditPart) {
+ Rectangle r = getAbsoluteBounds((IGraphicalEditPart)part);
+ return r.getBottom();
+ }
+ return new Point(0, 0);
+ }
+
+ public boolean hasSemanticChild() {
+ return true;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ IFigure f = ((LifelineEditPart)parentEditPart).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f).translate(0, 1);
+ }
+
+ public void setUp() {
+ }
+ };
+
+ private Point getCenter(IFigure f) {
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getCenter().getCopy();
+ return c;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMovingCombinedFragment_364711.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMovingCombinedFragment_364711.java
new file mode 100644
index 00000000000..c6fef38d99e
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestMovingCombinedFragment_364711.java
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+
+/**
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=364711
+ * When a lifeline covered by a combined fragment are moved (horizontally), the
+ * combined fragment does'nt follow the lifeline. Combined fragments should
+ * automatically follow lifeline when they are moved.
+ */
+public class TestMovingCombinedFragment_364711 extends TestTopNode {
+
+ private static final String MOVE = "Move: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testMovingRight() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(20, 20));
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80));
+ final LifelineEditPart lifelineEP = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete(); // wait for updating covered field
+
+ Point moveDelta = new Point(50, 0);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ req.setResizeDirection(PositionConstants.WEST);
+ req.setLocation(getAbsoluteCenter(lifelineEP));
+ req.setEditParts(lifelineEP);
+ req.setMoveDelta(moveDelta);
+
+ Command command = lifelineEP.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(cep);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+
+ Rectangle after = getAbsoluteBounds(cep);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.x() - before.x() == moveDelta.x);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.y() - before.y() == moveDelta.y);
+
+ getEMFCommandStack().undo();
+ assertTrue(MOVE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(cep)));
+
+ getEMFCommandStack().redo();
+ assertTrue(MOVE + TEST_THE_REDO, after.equals(getAbsoluteBounds(cep)));
+ }
+
+ @Test
+ public void testMovingLeft() {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(70, 20));
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(60, 80));
+ final LifelineEditPart lifelineEP = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ final CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(1);
+ waitForComplete(); // wait for updating covered field
+
+ Point moveDelta = new Point(-30, 0);
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ req.setResizeDirection(PositionConstants.EAST);
+ req.setLocation(getAbsoluteCenter(lifelineEP));
+ req.setEditParts(lifelineEP);
+ req.setMoveDelta(moveDelta);
+
+ Command command = lifelineEP.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(cep);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+
+ Rectangle after = getAbsoluteBounds(cep);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.x() - before.x() == moveDelta.x);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.y() - before.y() == moveDelta.y);
+
+ getEMFCommandStack().undo();
+ assertTrue(MOVE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(cep)));
+
+ getEMFCommandStack().redo();
+ assertTrue(MOVE + TEST_THE_REDO, after.equals(getAbsoluteBounds(cep)));
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ Command command = parent.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);
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedCombinedFragment_364795.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedCombinedFragment_364795.java
new file mode 100644
index 00000000000..72c91032214
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedCombinedFragment_364795.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.junit.Test;
+
+/**
+ * When a combined fragment is created inside another combined fragment, the
+ * property "covered" of the nested combined fragment is empty. This property
+ * should be initialized by the lifelines covered by this combined fragment and
+ * kept up to date when the list of covered lifelines evolves.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=364795
+ */
+public class TestNestedCombinedFragment_364795 extends TestTopNode {
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testCover() {
+ // create parent combined fragment
+ createNode(UMLElementTypes.CombinedFragment_3004, getRootEditPart(), new Point(10, 80), new Dimension(300, 200));
+ waitForComplete(); // wait for updating covered field
+ CombinedFragmentEditPart parentCFP = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ InteractionOperandEditPart oep = (InteractionOperandEditPart)((GraphicalEditPart)parentCFP.getChildren().get(0)).getChildren().get(0);
+
+ // create child combined fragment
+ createNode(UMLElementTypes.CombinedFragment_3004, oep, new Point(90, 90), new Dimension(200, 100));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(120, 20), new Dimension(62, 240));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(200, 20), new Dimension(62, 240));
+ CombinedFragmentEditPart childCFP = (CombinedFragmentEditPart)oep.getChildren().get(0);
+ final CombinedFragment parentCF = (CombinedFragment)parentCFP.resolveSemanticElement();
+ final CombinedFragment childCF = (CombinedFragment)childCFP.resolveSemanticElement();
+
+ waitForComplete(); // wait for updating covered field
+ assertTrue(CREATION + TEST_THE_EXECUTION, parentCF.getCovereds().size() == 2);
+ assertTrue(CREATION + TEST_THE_EXECUTION, childCF.getCovereds().size() == 2);
+
+ GraphicalEditPart lifelineEP = (GraphicalEditPart)getRootEditPart().getChildren().get(2);
+ deleteNode(lifelineEP);
+ waitForComplete(); // wait for updating covered field
+ assertTrue(CREATION + TEST_THE_EXECUTION, parentCF.getCovereds().size() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, childCF.getCovereds().size() == 1);
+ }
+
+ protected void deleteNode(GraphicalEditPart graphicalEditPart) {
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command delCommand = graphicalEditPart.getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, delCommand);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, delCommand != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, delCommand.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(delCommand));
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedExecution_384616.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedExecution_384616.java
new file mode 100644
index 00000000000..4c52546a529
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestNestedExecution_384616.java
@@ -0,0 +1,199 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+
+/**
+ * Support all messages in nested actions and behaviors execution (delete, move and resize)
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=384616
+ *
+ */
+public class TestNestedExecution_384616 extends TestTopNode {
+
+ private static final String RESIZE = "Resize: ";
+
+ private static final String MOVE = "Move: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testActionExecutionSpecification() {
+ manageActions(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testBehaviorExecutionSpecification() {
+ manageActions(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ protected void manageActions(IElementType elementType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ // create nested execution specification
+ createNode(elementType, lifeline1, new Point(131, 200), new Dimension(20, 80));
+ waitForComplete();
+
+ /*
+ * Tips: 1. The real location of the first node would be (123, 200). 2. Make sure the bottom of nested Execution is less than the parent one.
+ */
+
+ createNode(elementType, lifeline1, new Point(131, 220), new Dimension(20, 40));
+ waitForComplete();
+
+ IGraphicalEditPart esp = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart esp2 = (IGraphicalEditPart)lifeline1.getChildren().get(2);
+
+ // move
+ move(esp2, new Point(0, 20));
+ // resize
+ resize(esp, getAbsoluteBounds(esp2).getTop(), PositionConstants.NORTH, new Dimension(0, 30));
+
+ { // destroy semantic
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = esp2.getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 2); // action execution is deleted
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, lifeline1.getChildren().size() == 3);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, lifeline1.getChildren().size() == 2);
+ }
+ getEMFCommandStack().undo();
+ esp2 = (IGraphicalEditPart)lifeline1.getChildren().get(2);
+ { // delete view
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = esp2.getCommand(deleteViewRequest);
+
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, lifeline1.getChildren().size() == 2);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, getRootEditPart().getChildren().get(0) instanceof LifelineEditPart);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, lifeline1.getChildren().size() == 3);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, lifeline1.getChildren().size() == 2);
+ }
+ }
+
+ private void resize(IGraphicalEditPart op, Point p, int resizeDir, Dimension deltaSize) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(resizeDir);
+ req.setSizeDelta(deltaSize);
+ if(resizeDir == PositionConstants.NORTH || resizeDir == PositionConstants.WEST)
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ manageResizeCommnad(op, deltaSize, c);
+ }
+
+ private void manageResizeCommnad(IGraphicalEditPart op, Dimension deltaSize, Command c) {
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(op)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(RESIZE + TEST_THE_REDO, after.equals(getAbsoluteBounds(op)));
+ }
+
+ protected void move(IGraphicalEditPart part, Point moveDelta) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ req.setResizeDirection(moveDelta.y > 0 ? PositionConstants.SOUTH : PositionConstants.NORTH);
+ req.setLocation(getAbsoluteCenter(part));
+ req.setEditParts(part);
+ req.setMoveDelta(moveDelta);
+
+ Command command = part.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(part);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(part);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.x() - before.x() == moveDelta.x);
+ assertTrue(MOVE + TEST_THE_EXECUTION, after.y() - before.y() == moveDelta.y);
+
+ getEMFCommandStack().undo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_UNDO, before.equals(getAbsoluteBounds(part)));
+
+ getEMFCommandStack().redo();
+ waitForComplete();
+ assertTrue(MOVE + TEST_THE_REDO, after.equals(getAbsoluteBounds(part)));
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestObservationLink_364826.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestObservationLink_364826.java
new file mode 100644
index 00000000000..5c28d20d4e8
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestObservationLink_364826.java
@@ -0,0 +1,455 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import java.util.ArrayList;
+
+import org.eclipse.draw2d.AbstractPointListShape;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.IdentityAnchor;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.ObservationLinkMetamodelType;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+
+/**
+ * To enhance the usability of time and duration observation, these elements have
+ * to be handled like a classic UML constraint. In a first step, an observation
+ * should be created, and in a second step it should be linked to a messageEnd or
+ * execution specification event with a Link (like a constraint link). The
+ * semantic of this link is different to the semantic of the constraintLink
+ * because Observations are PackageableElements.
+ */
+public class TestObservationLink_364826 extends TestLink {
+
+ public static final String OBSERVATION_LINK_TYPE = "observation link"; //$NON-NLS-1$
+
+ public static final String OBSERVATION_LINK_REQUEST_START = "observation connection start"; //$NON-NLS-1$
+
+ public static final String OBSERVATION_LINK_REQUEST_END = "observation connection end"; //$NON-NLS-1$
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ @Test
+ public void testTimeObservationExecution1() {
+ manageTimeObservationExecution(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testTimeObservationExecution2() {
+ manageTimeObservationExecution(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testTimeObservationLink1() {
+ manageTimeObservationLink(UMLElementTypes.Message_4004, null);
+ }
+
+ @Test
+ public void testTimeObservationLink2() {
+ manageTimeObservationLink(UMLElementTypes.Message_4006, null);
+ }
+
+ @Test
+ public void testTimeObservationLink3() {
+ manageTimeObservationLink(UMLElementTypes.Message_4007, null);
+ }
+
+ @Test
+ public void testTimeObservationLink4() {
+ manageTimeObservationLink(UMLElementTypes.Message_4003, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testTimeObservationLink5() {
+ manageTimeObservationLink(UMLElementTypes.Message_4003, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testTimeObservationLink6() {
+ manageTimeObservationLink(UMLElementTypes.Message_4005, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testTimeObservationLink7() {
+ manageTimeObservationLink(UMLElementTypes.Message_4005, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testDurationObservationLink1() {
+ manageDurationObservationLink(UMLElementTypes.Message_4004, null);
+ }
+
+ @Test
+ public void testDurationObservationLink2() {
+ manageDurationObservationLink(UMLElementTypes.Message_4006, null);
+ }
+
+ @Test
+ public void testDurationObservationLink3() {
+ manageDurationObservationLink(UMLElementTypes.Message_4007, null);
+ }
+
+ @Test
+ public void testDurationObservationLink4() {
+ manageDurationObservationLink(UMLElementTypes.Message_4003, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testDurationObservationLink5() {
+ manageDurationObservationLink(UMLElementTypes.Message_4003, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testDurationObservationLink6() {
+ manageDurationObservationLink(UMLElementTypes.Message_4005, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testDurationObservationLink7() {
+ manageDurationObservationLink(UMLElementTypes.Message_4005, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+
+ public void manageDurationObservationLink(IElementType linkType, IElementType execType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 250));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(500, 100), new Dimension(62, 250));
+ createNode(UMLElementTypes.DurationObservation_3024, getRootEditPart(), new Point(100, 100), new Dimension(20, 15));
+ createNode(UMLElementTypes.DurationObservation_3024, getRootEditPart(), new Point(100, 200), new Dimension(20, 15));
+ waitForComplete();
+
+ GraphicalEditPart lifeline1 = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ GraphicalEditPart lifeline2 = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+ GraphicalEditPart observation1 = (GraphicalEditPart)getRootEditPart().getChildren().get(2);
+ GraphicalEditPart observation2 = (GraphicalEditPart)getRootEditPart().getChildren().get(3);
+
+ AbstractMessageEditPart connPart = null;
+ // create message link between lifeline
+ if(execType == null) {
+ createLink(linkType, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), getAbsoluteCenter(lifeline2));
+
+ connPart = (AbstractMessageEditPart)lifeline1.getSourceConnections().get(0);
+ } else {
+ createNode(execType, lifeline1, getAbsoluteCenter(lifeline1).translate(0, -20), null);
+ createNode(execType, lifeline2, getAbsoluteCenter(lifeline2).translate(0, 40), null);
+ IGraphicalEditPart start = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart end = (IGraphicalEditPart)lifeline2.getChildren().get(1);
+
+ waitForComplete();
+ createLink(linkType, start, end, getAbsoluteTop(start), getAbsoluteTop(end));
+ connPart = (AbstractMessageEditPart)start.getSourceConnections().get(0);
+ }
+ waitForComplete();
+
+ manageObservationLink(observation1, connPart, getAbsoluteEdgeExtremity((ConnectionNodeEditPart)connPart, true).translate(0, -5));
+ manageObservationLink(observation2, connPart, getAbsoluteEdgeExtremity((ConnectionNodeEditPart)connPart, false).translate(0, -5));
+ }
+
+
+ public void manageTimeObservationLink(IElementType linkType, IElementType execType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 250));
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(500, 100), new Dimension(62, 250));
+ createNode(UMLElementTypes.TimeObservation_3020, getRootEditPart(), new Point(100, 100), new Dimension(20, 15));
+ createNode(UMLElementTypes.TimeObservation_3020, getRootEditPart(), new Point(100, 200), new Dimension(20, 15));
+ waitForComplete();
+
+ GraphicalEditPart lifeline1 = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ GraphicalEditPart lifeline2 = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+ GraphicalEditPart observation1 = (GraphicalEditPart)getRootEditPart().getChildren().get(2);
+ GraphicalEditPart observation2 = (GraphicalEditPart)getRootEditPart().getChildren().get(3);
+
+ AbstractMessageEditPart connPart = null;
+ // create message link between lifeline
+ if(execType == null) {
+ createLink(linkType, lifeline1, lifeline2, getAbsoluteCenter(lifeline1), getAbsoluteCenter(lifeline2));
+
+ connPart = (AbstractMessageEditPart)lifeline1.getSourceConnections().get(0);
+ } else {
+ createNode(execType, lifeline1, getAbsoluteCenter(lifeline1).translate(0, -20), null);
+ createNode(execType, lifeline2, getAbsoluteCenter(lifeline2).translate(0, 40), null);
+ IGraphicalEditPart start = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ IGraphicalEditPart end = (IGraphicalEditPart)lifeline2.getChildren().get(1);
+
+ waitForComplete();
+ createLink(linkType, start, end, getAbsoluteTop(start), getAbsoluteTop(end));
+ connPart = (AbstractMessageEditPart)start.getSourceConnections().get(0);
+ }
+ waitForComplete();
+
+ //TimeObservationLabelEditPart
+ observation1 = (GraphicalEditPart)observation1.getChildren().get(0);
+ observation2 = (GraphicalEditPart)observation2.getChildren().get(0);
+
+ manageObservationLink(observation1, lifeline1, getAbsoluteEdgeExtremity((ConnectionNodeEditPart)connPart, true).translate(0, -5));
+ manageObservationLink(observation2, lifeline2, getAbsoluteEdgeExtremity((ConnectionNodeEditPart)connPart, false).translate(0, -5));
+ }
+
+
+ public void manageTimeObservationExecution(IElementType type) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(300, 100), new Dimension(62, 250));
+ createNode(UMLElementTypes.TimeObservation_3020, getRootEditPart(), new Point(100, 100), new Dimension(20, 15));
+ createNode(UMLElementTypes.TimeObservation_3020, getRootEditPart(), new Point(100, 200), new Dimension(20, 15));
+ waitForComplete();
+
+ GraphicalEditPart lifeline1 = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ GraphicalEditPart observation1 = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+ GraphicalEditPart observation2 = (GraphicalEditPart)getRootEditPart().getChildren().get(2);
+
+ //TimeObservationLabelEditPart
+ observation1 = (GraphicalEditPart)observation1.getChildren().get(0);
+ observation2 = (GraphicalEditPart)observation2.getChildren().get(0);
+ waitForComplete();
+
+ createNode(type, lifeline1, getAbsoluteCenter(lifeline1).translate(0, -20), null);
+ waitForComplete();
+
+ manageObservationLink(observation1, lifeline1, getAbsoluteBounds((IGraphicalEditPart)lifeline1.getChildren().get(1)).getTop().getCopy().translate(0, -5));
+ manageObservationLink(observation2, lifeline1, getAbsoluteBounds((IGraphicalEditPart)lifeline1.getChildren().get(1)).getBottom().getCopy().translate(0, 5));
+ }
+
+ protected void manageObservationLink(GraphicalEditPart start, EditPart end, Point t) {
+ {
+ ArrayList list = new ArrayList();
+ list.add(ObservationLinkMetamodelType.getInstance());
+
+ CreateUnspecifiedTypeConnectionRequest connectionRequest = new CreateUnspecifiedTypeConnectionRequest(list, false, getRootEditPart().getDiagramPreferencesHint());
+ connectionRequest.setType(OBSERVATION_LINK_REQUEST_START);
+ //connectionRequest.setFactory(new SimpleFactory(ObservationLink.class));
+
+ connectionRequest.setLocation(getAbsoluteCenter(start));
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(start);
+ start.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(start);
+ connectionRequest.setTargetEditPart(end);
+ connectionRequest.setType(OBSERVATION_LINK_REQUEST_END);
+ connectionRequest.setLocation(t);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ Command command = end.getCommand(connectionRequest);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + INITIALIZATION_TEST, start.getSourceConnections().size() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, start.getSourceConnections().size() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, start.getSourceConnections().size() == 1);
+ }
+ { // destroy
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = ((ConnectionEditPart)start.getSourceConnections().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, start.getSourceConnections().size() == 0);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, start.getSourceConnections().size() == 1);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, start.getSourceConnections().size() == 0);
+ }
+
+ getEMFCommandStack().undo();
+ { // delete view
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = ((ConnectionEditPart)start.getSourceConnections().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, start.getSourceConnections().size() == 0);
+
+ getEMFCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, start.getSourceConnections().size() == 1);
+
+ getEMFCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, start.getSourceConnections().size() == 0);
+ }
+ getEMFCommandStack().undo();
+ }
+
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ protected Point getAbsoluteCenter(IGraphicalEditPart part) {
+ IFigure f = part.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getCenter().getCopy();
+ return c;
+ }
+
+ protected Point getAbsoluteTop(IGraphicalEditPart part) {
+ IFigure f = part.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getTop().getCopy();
+ return c;
+ }
+
+ /**
+ * Copy from org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil.getAbsoluteEdgeExtremity(ConnectionNodeEditPart, boolean)
+ *
+ * Get the extremity of a connection edit part
+ *
+ * @param connection
+ * the connection edit part to find extremity
+ * @param isStart
+ * true to find the start, false for the end
+ * @return connection's extremity in absolute coordinates or null
+ */
+ public static Point getAbsoluteEdgeExtremity(ConnectionNodeEditPart connection, boolean isStart) {
+ Connection msgFigure = connection.getConnectionFigure();
+ if(connection.getNotationView() instanceof Edge) {
+ // rather take up to date model information
+ Edge edge = (Edge)connection.getNotationView();
+ Anchor idAnchor = null;
+ ConnectionAnchor conAnchor = null;
+ Object part = null;
+ if(isStart && connection.getSource() instanceof IGraphicalEditPart) {
+ View linkedFigure = edge.getSource();
+ // connection.getSource() may be not up to date, get part for linkedFigure
+ part = connection.getSource().getViewer().getEditPartRegistry().get(linkedFigure);
+ idAnchor = edge.getSourceAnchor();
+ conAnchor = msgFigure.getSourceAnchor();
+ } else if(!isStart && connection.getTarget() instanceof IGraphicalEditPart) {
+ View linkedFigure = edge.getTarget();
+ // connection.getTarget() may be not up to date, get part for linkedFigure
+ part = connection.getTarget().getViewer().getEditPartRegistry().get(linkedFigure);
+ idAnchor = edge.getTargetAnchor();
+ conAnchor = msgFigure.getTargetAnchor();
+ }
+ if(part instanceof IGraphicalEditPart && idAnchor instanceof IdentityAnchor && conAnchor != null) {
+ // take up to date bounds of the linked part in case it is moved
+ Rectangle linkedPartBounds = getAbsoluteBounds((IGraphicalEditPart)part);
+
+ IFigure anchorOwningFigure = conAnchor.getOwner();
+ IFigure partFigure = ((IGraphicalEditPart)part).getFigure();
+ Dimension delta = anchorOwningFigure.getBounds().getLocation().getDifference(partFigure.getBounds().getLocation());
+ // get position from anchor id
+ String oldTerminal = ((IdentityAnchor)idAnchor).getId();
+ PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal);
+ int xPos = linkedPartBounds.x + delta.width + (int)Math.round(anchorOwningFigure.getBounds().width * pp.preciseX);
+ int yPos = linkedPartBounds.y + delta.height + (int)Math.round(anchorOwningFigure.getBounds().height * pp.preciseY);
+ return new Point(xPos, yPos);
+ }
+ }
+ // can not get from model, rely on figure
+ if(msgFigure instanceof AbstractPointListShape) {
+ Point extremity;
+ if(isStart) {
+ // start event of the message
+ extremity = ((AbstractPointListShape)msgFigure).getStart().getCopy();
+ } else {
+ // finish event of the message
+ extremity = ((AbstractPointListShape)msgFigure).getEnd().getCopy();
+ }
+ msgFigure.getParent().translateToAbsolute(extremity);
+ return extremity;
+ }
+ return null;
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestParentBarAutoresize_385603.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestParentBarAutoresize_385603.java
new file mode 100644
index 00000000000..8a444ab3ad9
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestParentBarAutoresize_385603.java
@@ -0,0 +1,222 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestTopNode;
+import org.junit.Test;
+
+/**
+ * When childs are outside the current size, the parent bar should autoresize. The parent should always wrap the children.
+ * Its size should be extended when we create, move, resize and reparent a child
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=385603
+ *
+ */
+public class TestParentBarAutoresize_385603 extends TestTopNode {
+ private static final String RESIZE = "Resize: ";
+
+ private static final String MOVE = "Move: ";
+
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testActionExecutionSpecificationUp() {
+ moveUp(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testActionExecutionSpecificationDown() {
+ moveDown(UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testBehaviorExecutionSpecificationDown() {
+ moveDown(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testBehaviorExecutionSpecificationUp() {
+ moveUp(UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ private void moveUp(IElementType elementType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 300));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ // create nested execution specification
+ createNode(elementType, lifeline1, new Point(131, 300), new Dimension(20, 40));
+ waitForComplete();
+ IGraphicalEditPart parent = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ Rectangle before = getAbsoluteBounds(parent);
+
+ // create child
+ /* With location (131, 270), the new Execution will not the child of parent. */
+ createNode(elementType, lifeline1, new Point(131, 310), new Dimension(20, 40));
+ waitForComplete();
+ IGraphicalEditPart child = (IGraphicalEditPart)lifeline1.getChildren().get(2);
+
+ //The parent will not be expand when creation.
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().y == before.getTop().y);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).height == before.height);
+
+ // move up
+ before = getAbsoluteBounds(parent);
+ Point moveDelta = new Point(0, -20);
+ move(child, moveDelta);
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().y == getAbsoluteBounds(child).getTop().y);
+ /*
+ * the parent would not be always expanded.
+ *
+ * assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().y - before.getTop().y == moveDelta.y);
+ */
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().y <= getAbsoluteBounds(child).getTop().y);
+
+ // resize
+ before = getAbsoluteBounds(parent);
+ Dimension deltaSize = new Dimension(0, 20);
+ resize(child, getAbsoluteBounds(child).getTop(), PositionConstants.NORTH, deltaSize);
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().y == getAbsoluteBounds(child).getTop().y);
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).height - before.height == deltaSize.height);
+ }
+
+ private void moveDown(IElementType elementType) {
+ createNode(UMLElementTypes.Lifeline_3001, getRootEditPart(), new Point(100, 100), new Dimension(62, 200));
+ final LifelineEditPart lifeline1 = (LifelineEditPart)getRootEditPart().getChildren().get(0);
+ waitForComplete();
+
+ // create nested execution specification
+ createNode(elementType, lifeline1, new Point(131, 200), new Dimension(20, 50));
+ waitForComplete();
+ IGraphicalEditPart parent = (IGraphicalEditPart)lifeline1.getChildren().get(1);
+ Rectangle before = getAbsoluteBounds(parent);
+
+ // create child
+ createNode(elementType, lifeline1, before.getRight().getTranslated(-1, 0), new Dimension(20, 50));
+ waitForComplete();
+ IGraphicalEditPart child = (IGraphicalEditPart)lifeline1.getChildren().get(2);
+
+ /*
+ * DISABLED: the parent is not always expanded when adding a child.
+ *
+ * assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getBottom().y > before.getBottom().y);
+ * assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getBottom().y == getAbsoluteBounds(child).getBottom().y);
+ */
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getBottom().y == before.getBottom().y);
+
+ // move
+ before = getAbsoluteBounds(parent);
+ Point moveDelta = new Point(0, 20);
+ move(child, moveDelta);
+ assertTrue(MOVE + TEST_THE_EXECUTION, before.getLocation().equals(getAbsoluteBounds(parent).getLocation() ));
+
+ /*
+ * The height of parent will not be changed when move down child.
+ * assertTrue(MOVE + TEST_THE_EXECUTION, before.height + moveDelta.y == getAbsoluteBounds(parent).height);
+ * assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getBottom().y == getAbsoluteBounds(child).getBottom().y);
+ */
+ assertTrue(MOVE + TEST_THE_EXECUTION, before.height == getAbsoluteBounds(parent).height);
+
+ // resize
+ before = getAbsoluteBounds(parent);
+ Dimension deltaSize = new Dimension(0, 30);
+ resize(child, getAbsoluteBounds(child).getBottom(), PositionConstants.SOUTH, deltaSize);
+
+ /*
+ * parent would not be changed.
+ *
+ * assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getBottom().y == getAbsoluteBounds(child).getBottom().y);
+ * assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).height == before.height + deltaSize.height);
+ */
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(parent).getTop().equals( before.getTop() ));
+
+ // move parent will move child bar
+ before = getAbsoluteBounds(child);
+ move(parent, moveDelta);
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(child).x - before.x == moveDelta.x );
+ assertTrue(MOVE + TEST_THE_EXECUTION, getAbsoluteBounds(child).y - before.y == moveDelta.y );
+
+ // resize parent will not resize child
+ before = getAbsoluteBounds(child);
+ resize(parent, getAbsoluteBounds(parent).getBottom(), PositionConstants.SOUTH, deltaSize);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, getAbsoluteBounds(child).equals( before ));
+ }
+
+ private void resize(IGraphicalEditPart op, Point p, int resizeDir, Dimension deltaSize) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
+ req.setLocation(p);
+ req.setEditParts(op);
+ req.setResizeDirection(resizeDir);
+ req.setSizeDelta(deltaSize);
+ if(resizeDir == PositionConstants.NORTH || resizeDir == PositionConstants.WEST)
+ req.setMoveDelta(new Point(-deltaSize.width(), -deltaSize.height()));
+
+ Command c = op.getCommand(req);
+ assertNotNull(RESIZE + COMMAND_NULL, c);
+ assertTrue(RESIZE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, c.canExecute() == true);
+ Rectangle before = getAbsoluteBounds(op);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(c));
+ waitForComplete();
+
+ Rectangle after = getAbsoluteBounds(op);
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.width() - before.width() == deltaSize.width());
+ assertTrue(RESIZE + TEST_THE_EXECUTION, after.height() - before.height() == deltaSize.height());
+ }
+
+ protected void move(IGraphicalEditPart part, Point moveDelta) {
+ ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ req.setResizeDirection(moveDelta.y > 0 ? PositionConstants.SOUTH : PositionConstants.NORTH);
+ req.setLocation(getAbsoluteCenter(part));
+ req.setEditParts(part);
+ req.setMoveDelta(moveDelta);
+
+ Command command = part.getCommand(req);
+ assertNotNull(MOVE + COMMAND_NULL, command);
+ assertTrue(MOVE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ waitForComplete();
+ }
+
+ public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parentPart.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestSynchronousMessageCreation_364827.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestSynchronousMessageCreation_364827.java
new file mode 100644
index 00000000000..3c1ffcd0ee1
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestSynchronousMessageCreation_364827.java
@@ -0,0 +1,194 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.bug;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.CreateSequenceDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.canonical.TestLink;
+import org.junit.Test;
+
+/**
+ * When a synchronous message is created, an executionSpecification (Action or
+ * Behavior: a popup menu should give the choice to the user) has to be created in
+ * case it does'nt exist.
+ *
+ */
+public class TestSynchronousMessageCreation_364827 extends TestLink {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ public void selectActionExecution(IElementType sourceType, IElementType targetType, IElementType linkType, IElementType subNodeType) {
+ installEnvironment(sourceType, targetType, subNodeType);
+ target = createSubNode(target, subNodeType, getAbsoluteCenter(target));
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, target instanceof ActionExecutionSpecificationEditPart);
+
+// assertTrue(CREATION + INITIALIZATION_TEST, target.getChildren().size() == 1);
+ waitForComplete();
+ PopupUtil.addMenuListener(0);
+ createLink(linkType, source, target, getAbsoluteCenter(source), getAbsoluteCenter(target).translate(0, 60));
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().get(0) instanceof AbstractMessageEditPart);
+ AbstractMessageEditPart p = (AbstractMessageEditPart)source.getSourceConnections().get(0);
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((View)p.getModel()).getType().equals(((IHintedType)linkType).getSemanticHint()));
+
+// assertTrue(CREATION + TEST_THE_EXECUTION, target.getChildren().size() == 2); // LifelineNameEditPart
+ assertTrue(CREATION + TEST_THE_EXECUTION, target instanceof ActionExecutionSpecificationEditPart);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, target.getTargetConnections().size() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_UNDO, target.getTargetConnections().size() == 1);
+ }
+
+ public void selectBehaviorExecution(IElementType sourceType, IElementType targetType, IElementType linkType, IElementType subNodeType) {
+ installEnvironment(sourceType, targetType, subNodeType);
+ target = createSubNode(target, subNodeType, getAbsoluteCenter(target));
+ assertTrue(CREATION + TEST_THE_EXECUTION, target instanceof BehaviorExecutionSpecificationEditPart);
+
+// assertTrue(CREATION + INITIALIZATION_TEST, target.getChildren().size() == 1);
+ waitForComplete();
+ PopupUtil.addMenuListener(1);
+ createLink(linkType, source, target, getAbsoluteCenter(source), getAbsoluteCenter(target).translate(0, 60));
+
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, source.getSourceConnections().get(0) instanceof AbstractMessageEditPart);
+ AbstractMessageEditPart p = (AbstractMessageEditPart)source.getSourceConnections().get(0);
+ assertTrue(CREATION + TEST_THE_EXECUTION, ((View)p.getModel()).getType().equals(((IHintedType)linkType).getSemanticHint()));
+
+// assertTrue(CREATION + TEST_THE_EXECUTION, target.getChildren().size() == 2);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, source.getSourceConnections().size() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, target.getTargetConnections().size() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, source.getSourceConnections().size() == 1);
+ assertTrue(CREATION + TEST_THE_REDO, target.getTargetConnections().size() == 1);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ waitForComplete();
+ PopupUtil.removeMenuListener();
+ }
+
+ @Test
+ public void testMessageSync_4003_Action() {
+ selectActionExecution(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4003, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testMessageSync_4003_Behavior() {
+ selectBehaviorExecution(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4003, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ @Test
+ public void testMessageReply_4005_Action() {
+ selectActionExecution(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4005, UMLElementTypes.ActionExecutionSpecification_3006);
+ }
+
+ @Test
+ public void testMessageReply_4005_Behavior() {
+ selectBehaviorExecution(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4005, UMLElementTypes.BehaviorExecutionSpecification_3003);
+ }
+
+ public void createLink(IElementType linkType, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, sourcePoint, targetPoint);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, Point sourcePoint, Point targetPoint) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+ connectionRequest.setLocation(sourcePoint);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the
+ // connection end
+ // command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+ connectionRequest.setLocation(targetPoint);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ connectionRequest.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ connectionRequest.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+
+ return connectionRequest;
+ }
+
+ public void createNode(IElementType type, GraphicalEditPart parent, Point location, Dimension size) {
+ //CREATION
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(location);
+ requestcreation.setSize(size);
+ Command command = parent.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);
+
+ getDiagramCommandStack().execute(command);
+ }
+
+ public void installEnvironment(IElementType sourceType, IElementType targetType, IElementType subNodeType) {
+ //create the source
+ createNode(sourceType, getRootEditPart(), new Point(100, 100), new Dimension(62, 250));
+
+ //create the target
+ createNode(targetType, getRootEditPart(), new Point(300, 100), new Dimension(62, 250));
+
+ source = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ target = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+
+ waitForComplete();
+ source = createSubNode(source, subNodeType, getAbsoluteCenter(source));
+
+ waitForComplete();
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/AllCanonicalTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/AllCanonicalTests.java
new file mode 100644
index 00000000000..6cdeb7eb8ff
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/AllCanonicalTests.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+
+/**
+ * All test in canonical package
+ */
+@RunWith(Suite.class)
+@SuiteClasses({
+// top nodes
+TestSequenceDiagramTopNode.class,
+// child nodes
+TestSequenceDiagramChildNode.class,
+//test links
+TestSequenceDiagramLink.class, TestCombinedFragmentChildNode.class })
+public class AllCanonicalTests {
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/CreateSequenceDiagramCommand.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/CreateSequenceDiagramCommand.java
new file mode 100644
index 00000000000..e71123b1873
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/CreateSequenceDiagramCommand.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.papyrus.uml.diagram.common.commands.CreateBehavioredClassifierDiagramCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Define a command to create a new Sequence Diagram. This command is used by all UI (toolbar,
+ * outline, creation wizards) to create a new Sequence Diagram.
+ */
+public class CreateSequenceDiagramCommand extends CreateBehavioredClassifierDiagramCommand {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getDiagramNotationID() {
+ return PackageEditPart.MODEL_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PreferencesHint getPreferenceHint() {
+ return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getDefaultDiagramName() {
+ return "SeqDiagram"; //$NON-NLS-1$
+ }
+
+ @Override
+ protected EClass getBehaviorEClass() {
+ return UMLPackage.eINSTANCE.getInteraction();
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/IChildTestProvider.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/IChildTestProvider.java
new file mode 100644
index 00000000000..70169a442e7
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/IChildTestProvider.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+
+interface IChildTestProvider extends ITestProvider {
+
+ boolean hasSemanticChild();
+
+ Point getChildLocation(GraphicalEditPart parentEditPart);
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ILinkTestProvider.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ILinkTestProvider.java
new file mode 100644
index 00000000000..8e2ff99dc4b
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ILinkTestProvider.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+
+public interface ILinkTestProvider extends IChildTestProvider {
+
+ int getEdgesSize();
+
+ Point getConnectionSourceLocation(EditPart source);
+
+ Point getConnectionTargetLocation(EditPart target);
+
+ void setUp();
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ITestProvider.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ITestProvider.java
new file mode 100644
index 00000000000..efa848dc8cc
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/ITestProvider.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.uml2.uml.Element;
+
+interface ITestProvider {
+
+ int getEditPartChildrenSize();
+
+ Element getDropElement();
+
+ int getSemanticChildrenSize();
+
+ int getViewChildrenSize();
+
+ GraphicalEditPart getParentEditPart();
+
+ GraphicalEditPart getDestroyEditPart();
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestChildNode.java
new file mode 100644
index 00000000000..c170c0c1e9e
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestChildNode.java
@@ -0,0 +1,235 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.tests.canonical;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Element;
+
+
+/**
+ * The Class TestChildNode.
+ */
+public abstract class TestChildNode extends AbstractPapyrusTestCase {
+
+ protected abstract CreateViewRequest createViewRequestShapeContainer();
+
+ protected GraphicalEditPart rootPart;
+
+ protected GraphicalEditPart getRootEditPart() {
+ if(rootPart == null) {
+ GraphicalEditPart part = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
+ rootPart = (GraphicalEditPart)part.getChildren().get(1);
+ }
+ return rootPart;
+ }
+
+ protected View getRootView() {
+ return getRootEditPart().getNotationView();
+ }
+
+ protected Element getRootSemanticModel() {
+ return (Element)getRootView().getElement();
+ }
+
+ protected DiagramCommandStack getDiagramCommandStack() {
+ return getRootEditPart().getDiagramEditDomain().getDiagramCommandStack();
+ }
+
+ protected org.eclipse.emf.common.command.CommandStack getEMFCommandStack() {
+ return getRootEditPart().getEditingDomain().getCommandStack();
+ }
+
+ protected void waitForComplete() {
+ boolean run = true;
+ while(run) {
+ try {
+ run = Display.getDefault().readAndDispatch();
+ } catch (Exception e) {
+ run = true;
+ }
+ }
+ }
+
+ /**
+ * Test view deletion.
+ *
+ * @param type
+ * the type
+ */
+ public void testViewDeletion(IElementType type, IChildTestProvider provider) {
+ //DELETION OF THE VIEW
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getViewChildrenSize() == 1);
+
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = provider.getDestroyEditPart().getCommand(deleteViewRequest);
+
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getViewChildrenSize() == 0);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getViewChildrenSize() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getViewChildrenSize() == 0);
+
+ }
+
+
+ /**
+ * Test destroy.
+ *
+ * @param type
+ * the type
+ */
+ public void testDestroy(IElementType type, IChildTestProvider provider) {
+ //DESTROY SEMANTIC+ VIEW
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = provider.getDestroyEditPart().getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getViewChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 0);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, provider.getViewChildrenSize() == 1);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getSemanticChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getViewChildrenSize() == 0);
+ }
+
+ /**
+ * Test to create a node.
+ *
+ * @param type
+ * the type
+ */
+ public void testToCreateChildNode(IElementType type, IChildTestProvider provider) {
+
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 0);
+
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+
+ requestcreation.setLocation(provider.getChildLocation(provider.getParentEditPart()));
+
+ Command command = provider.getParentEditPart().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);
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + TEST_THE_EXECUTION, provider.getViewChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getViewChildrenSize() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_REDO, provider.getViewChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_REDO, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+
+ }
+
+ public void createChildNode(IElementType type, IChildTestProvider provider) {
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(provider.getChildLocation(provider.getParentEditPart()));
+ Command command = provider.getParentEditPart().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);
+ getDiagramCommandStack().execute(command);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ createTopNode();
+ }
+
+ protected void createTopNode() {
+ CreateViewRequest requestcreation = createViewRequestShapeContainer();
+ requestcreation.setSize(new Dimension(100, 200));
+
+ Command command = getRootEditPart().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);
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootEditPart().getChildren().size() == 1);
+ }
+
+
+ /**
+ * Test to manage child node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToManageChildNode(IElementType type, IChildTestProvider provider) { //IElementType containerType,
+ testToCreateChildNode(type, provider);
+ // the node is still present
+ testDestroy(type, provider);
+ // the node has been destroyed, the UML element also
+ getEMFCommandStack().undo();
+ // the node and the UML element are present
+ testViewDeletion(type, provider);
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestCombinedFragmentChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestCombinedFragmentChildNode.java
new file mode 100644
index 00000000000..6a81431a439
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestCombinedFragmentChildNode.java
@@ -0,0 +1,177 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InteractionOperand;
+import org.eclipse.uml2.uml.InteractionOperatorKind;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.junit.Test;
+
+
+public class TestCombinedFragmentChildNode extends TestChildNode {
+
+ private static final String CHANGE_OPERATOR_KIND = "Change Operator Kind: ";
+
+ @Test
+ public void testToManageOperand() {
+ testToManageChildNode(UMLElementTypes.InteractionOperand_3005, combinedFragmentProvider);
+ }
+
+ @Test
+ public void testToManageContinuation() {
+ testToManageChildNode(UMLElementTypes.Continuation_3016, operandProvider);
+ }
+
+ @Override
+ protected CreateViewRequest createViewRequestShapeContainer() {
+ return CreateViewRequestFactory.getCreateShapeRequest(UMLElementTypes.CombinedFragment_3004, getDiagramEditPart().getDiagramPreferencesHint());
+ }
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Override
+ protected void createTopNode() {
+ super.createTopNode();
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ changeOperatorKind(cep, cf, InteractionOperatorKind.ALT_LITERAL);
+ waitForComplete();
+ }
+
+ protected void changeOperatorKind(CombinedFragmentEditPart p, CombinedFragment cf, InteractionOperatorKind kind) {
+ EAttribute feature = UMLPackage.eINSTANCE.getCombinedFragment_InteractionOperator();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
+ SetRequest request = new SetRequest(p.getEditingDomain(), cf, feature, kind);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_OPERATOR_KIND + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ }
+
+ private GraphicalEditPart containerEditPart;
+
+ IChildTestProvider operandProvider = new IChildTestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return getParentEditPart().getChildren().size();
+ }
+
+ public int getSemanticChildrenSize() {
+ InteractionOperand operand = ((InteractionOperand)getParentEditPart().getNotationView().getElement());
+ return operand.getFragments().size();
+ }
+
+ public int getViewChildrenSize() {
+ return getParentEditPart().getNotationView().getChildren().size();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ if(containerEditPart == null) {
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+ containerEditPart = (GraphicalEditPart)cfp.getChildren().get(0); // operand
+ }
+ return containerEditPart;
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ List children = getParentEditPart().getChildren();
+ return (GraphicalEditPart)children.get(children.size() - 1);
+ }
+
+ public boolean hasSemanticChild() {
+ return true;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ IFigure f = parentEditPart.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ return b.getCenter().getCopy();
+ }
+ };
+
+ IChildTestProvider combinedFragmentProvider = new IChildTestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return getParentEditPart().getChildren().size() - 1;
+ }
+
+ public int getSemanticChildrenSize() {
+ CombinedFragment cf = ((CombinedFragment)getParentEditPart().getNotationView().getElement());
+ return cf.getOperands().size() - 1;
+ }
+
+ public int getViewChildrenSize() {
+ return getParentEditPart().getNotationView().getChildren().size() - 1;
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ if(containerEditPart == null) {
+ CombinedFragmentEditPart cep = (CombinedFragmentEditPart)getRootEditPart().getChildren().get(0);
+ CombinedFragmentCombinedFragmentCompartmentEditPart cfp = (CombinedFragmentCombinedFragmentCompartmentEditPart)cep.getChildren().get(0);
+ containerEditPart = cfp;
+ }
+ return containerEditPart;
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ List children = getParentEditPart().getChildren();
+ return (GraphicalEditPart)children.get(children.size() - 1);
+ }
+
+ public boolean hasSemanticChild() {
+ return true;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ IFigure f = parentEditPart.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ return b.getCenter().getCopy();
+ }
+ };
+
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestLink.java
new file mode 100644
index 00000000000..efddb5cb893
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestLink.java
@@ -0,0 +1,471 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST.
+ *
+ *
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.tests.canonical;
+
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * The Class TestTopLink to test when this is link . The link is attached to a semantic element that has to be contained by the source and the target.
+ * To adapt when source owns the created link
+ */
+public abstract class TestLink extends AbstractPapyrusTestCase {
+
+ protected static final String THE_LINK_RECONNECT_EXISTS = "The Link exist";
+
+ protected static final String RECONNECTION_TARGET = "Reconnection of target";
+
+ protected static final String LINK_EXISTS_RECONNECTION_ON_TARGET = "Link exist on the target";
+
+ protected static final String THE_LINK_TO_RECONNECT_EXISTS = "The Link exist";
+
+ protected static final String RECONNECTION_SOURCE = "Reconnection of source";
+
+ protected static final String LINK_EXISTS_RECONNECTION_ON_SOURCE = "Link exist on the source";
+
+ public static final String SOURCE_MODEL_CONTAINER = "Source model container"; //$NON-NLS-1$
+
+ public static final String TARGET_MODEL_CONTAINER = "Target model container"; //$NON-NLS-1$
+
+ protected GraphicalEditPart source = null;
+
+ protected GraphicalEditPart sourcePlayer = null;
+
+ protected GraphicalEditPart target = null;
+
+ protected GraphicalEditPart targetPlayer = null;
+
+
+ protected GraphicalEditPart rootPart;
+
+ protected GraphicalEditPart getRootEditPart() {
+ if(rootPart == null) {
+ GraphicalEditPart part = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
+ rootPart = (GraphicalEditPart)part.getChildren().get(1); // compart
+ }
+ return rootPart;
+ }
+
+ protected DiagramCommandStack getDiagramCommandStack() {
+ return getRootEditPart().getDiagramEditDomain().getDiagramCommandStack();
+ }
+
+ protected org.eclipse.emf.common.command.CommandStack getEMFCommandStack() {
+ return getRootEditPart().getEditingDomain().getCommandStack();
+ }
+
+ protected void waitForComplete() {
+ boolean run = true;
+ while(run) {
+ try {
+ run = Display.getDefault().readAndDispatch();
+ } catch (Exception e) {
+ run = true;
+ }
+ }
+ }
+
+ protected Point getAbsoluteCenter(IGraphicalEditPart part) {
+ IFigure f = part.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getCenter().getCopy();
+ return c;
+ }
+
+ /**
+ * Get the bounds of an edit part
+ *
+ * @param part
+ * edit part to find bounds
+ * @return part's bounds in absolute coordinates
+ */
+ public static Rectangle getAbsoluteBounds(IGraphicalEditPart part) {
+ // take bounds from figure
+ Rectangle bounds = part.getFigure().getBounds().getCopy();
+
+ if(part.getNotationView() instanceof Node) {
+ // rather update with up to date model bounds
+ Node node = (Node)part.getNotationView();
+ LayoutConstraint cst = node.getLayoutConstraint();
+ if(cst instanceof Bounds) {
+ Bounds b = (Bounds)cst;
+ Point parentLoc = part.getFigure().getParent().getBounds().getLocation();
+ if(b.getX() > 0) {
+ bounds.x = b.getX() + parentLoc.x;
+ }
+ if(b.getY() > 0) {
+ bounds.y = b.getY() + parentLoc.y;
+ }
+ if(b.getHeight() != -1) {
+ bounds.height = b.getHeight();
+ }
+ if(b.getWidth() != -1) {
+ bounds.width = b.getWidth();
+ }
+ }
+ }
+
+ part.getFigure().getParent().translateToAbsolute(bounds);
+ return bounds;
+ }
+
+
+ /**
+ * Test view deletion.
+ *
+ * @param type
+ * the type
+ * @param provider
+ */
+ public void testViewDeletion(IElementType type, ILinkTestProvider provider) {
+ //DELETION OF THE VIEW
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, source.getSourceConnections().size() == 1);
+ int initSemanticSize = provider.getSemanticChildrenSize();
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = ((ConnectionEditPart)source.getSourceConnections().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == initSemanticSize);
+
+ getEMFCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, source.getSourceConnections().size() == 1);
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == initSemanticSize);
+
+ getEMFCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, source.getSourceConnections().size() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, provider.getSemanticChildrenSize() == initSemanticSize);
+
+ }
+
+ /**
+ * Retrieves the TransactionalEditingDomain
+ *
+ * @return the editing domain (can be null)
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ ServiceUtilsForActionHandlers serviceUtils = new ServiceUtilsForActionHandlers();
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ editingDomain = serviceUtils.getTransactionalEditingDomain();
+
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+
+ return editingDomain;
+ }
+
+ /**
+ * Test destroy.
+ *
+ * @param type
+ * the type
+ * @param provider
+ */
+ public void testDestroy(IElementType type, ILinkTestProvider provider) {
+
+ //DESTROY SEMANTIC+ VIEW
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEdgesSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, source.getSourceConnections().size() == 1);
+
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = ((ConnectionEditPart)source.getSourceConnections().get(0)).getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getEdgesSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, source.getSourceConnections().size() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 4);
+
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, getDiagramCommandStack().canUndo() == true);
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, provider.getEdgesSize() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, source.getSourceConnections().size() == 1);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEdgesSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, source.getSourceConnections().size() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getSemanticChildrenSize() == 4);
+ }
+
+
+ /**
+ * Test to create a link.
+ *
+ * @param linkType
+ * the type
+ * @param provider
+ */
+ public void testToCreateALink(IElementType linkType, ILinkTestProvider provider) {
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 4);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getSemanticChildrenSize() == 4);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEdgesSize() == 0); //add
+
+ CreateConnectionViewRequest req = createConnectionViewRequest(linkType, source, target, provider);
+ Command command = target.getCommand(req);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEdgesSize() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getViewChildrenSize() == 4);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == 4);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getEdgesSize() == 0); // add
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, provider.getEdgesSize() == 1);
+ }
+
+
+ public void installEnvironment(IElementType sourceType, IElementType targetType, ILinkTestProvider provider) {
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootEditPart().getChildren().size() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, getRootSemanticModel().getOwnedElements().size() == 0);
+
+ //create the source
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(sourceType, getDiagramEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(new Point(100, 100));
+ Command command = getRootEditPart().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);
+ getDiagramCommandStack().execute(command);
+
+ //create the source player to test reconnect
+ requestcreation = CreateViewRequestFactory.getCreateShapeRequest(sourceType, getDiagramEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(new Point(200, 100));
+ command = getRootEditPart().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);
+ getDiagramCommandStack().execute(command);
+
+ //create the target
+ requestcreation = CreateViewRequestFactory.getCreateShapeRequest(targetType, getDiagramEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(new Point(300, 100));
+ command = getRootEditPart().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);
+ getDiagramCommandStack().execute(command);
+
+ //create the target player to test reconnect
+ requestcreation = CreateViewRequestFactory.getCreateShapeRequest(targetType, getDiagramEditPart().getDiagramPreferencesHint());
+ requestcreation.setLocation(new Point(400, 100));
+ command = getRootEditPart().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);
+ getDiagramCommandStack().execute(command);
+
+ source = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ sourcePlayer = (GraphicalEditPart)getRootEditPart().getChildren().get(1);
+ target = (GraphicalEditPart)getRootEditPart().getChildren().get(2);
+ targetPlayer = (GraphicalEditPart)getRootEditPart().getChildren().get(3);
+
+ provider.setUp();
+ }
+
+ protected GraphicalEditPart createSubNode(GraphicalEditPart parent, IElementType type, Point c) {
+ CreateViewRequest request = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ request.setLocation(c);
+
+ Command command = parent.getCommand(request);
+ assertTrue(CREATION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+ getDiagramCommandStack().execute(command);
+
+ // return last child
+ List list = parent.getChildren();
+ return (GraphicalEditPart)list.get(list.size() - 1);
+ }
+
+ public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, ILinkTestProvider provider) {
+ CreateConnectionViewRequest connectionRequest = CreateViewRequestFactory.getCreateConnectionRequest(type, ((IGraphicalEditPart)getDiagramEditPart()).getDiagramPreferencesHint());
+
+ Point c = provider.getConnectionSourceLocation(source);
+ connectionRequest.setLocation(c);
+
+ connectionRequest.setSourceEditPart(null);
+ connectionRequest.setTargetEditPart(source);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_START);
+ Command cmd = source.getCommand(connectionRequest);
+ // Now, setup the request in preparation to get the connection end command.
+ connectionRequest.setSourceEditPart(source);
+ connectionRequest.setTargetEditPart(target);
+ connectionRequest.setType(RequestConstants.REQ_CONNECTION_END);
+
+ Point t = provider.getConnectionTargetLocation(target);
+ connectionRequest.setLocation(t);
+ return connectionRequest;
+ }
+
+ public void testTargetReconnectAMultiLink(IElementType type, ILinkTestProvider provider) {
+ //target reconnection
+ ReconnectRequest reconnectRequest = new ReconnectRequest();
+ assertTrue(THE_LINK_RECONNECT_EXISTS, (ConnectionEditPart)target.getTargetConnections().get(0) != null);
+ ConnectionEditPart binaryLink = (ConnectionEditPart)target.getTargetConnections().get(0);
+ reconnectRequest.setConnectionEditPart(binaryLink);
+ reconnectRequest.setTargetEditPart(targetPlayer);
+ reconnectRequest.setType(RequestConstants.REQ_RECONNECT_TARGET);
+ reconnectRequest.setLocation(provider.getConnectionSourceLocation(targetPlayer));
+
+ Command cmd = targetPlayer.getCommand(reconnectRequest);
+ assertTrue(RECONNECTION_TARGET + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, cmd.canExecute() == true);
+ int initSemanticSize = provider.getSemanticChildrenSize();
+
+ getDiagramCommandStack().execute(cmd);
+ assertTrue(RECONNECTION_TARGET + TEST_THE_EXECUTION, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_TARGET + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == initSemanticSize);
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_TARGET, binaryLink.getTarget().equals(targetPlayer));
+
+ //undo
+ getDiagramCommandStack().undo();
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_TARGET + TEST_THE_UNDO, binaryLink.getTarget().equals(target));
+ assertTrue(RECONNECTION_TARGET + TEST_THE_UNDO, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_TARGET + TEST_THE_UNDO, provider.getSemanticChildrenSize() == initSemanticSize);
+
+ //redo
+ getDiagramCommandStack().redo();
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_TARGET + TEST_THE_REDO, binaryLink.getTarget().equals(targetPlayer));
+ assertTrue(RECONNECTION_TARGET + TEST_THE_REDO, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_TARGET + TEST_THE_REDO, provider.getSemanticChildrenSize() == initSemanticSize);
+ }
+
+ public void testSourceReconnectAMultiLink(IElementType type, ILinkTestProvider provider) {
+ //target reconnection
+ ReconnectRequest reconnectRequest = new ReconnectRequest();
+ assertTrue(THE_LINK_TO_RECONNECT_EXISTS, (ConnectionEditPart)source.getSourceConnections().get(0) != null);
+ ConnectionEditPart branch = (ConnectionEditPart)source.getSourceConnections().get(0);
+ reconnectRequest.setConnectionEditPart(branch);
+ reconnectRequest.setTargetEditPart(sourcePlayer);
+ reconnectRequest.setType(RequestConstants.REQ_RECONNECT_SOURCE);
+ reconnectRequest.setLocation(provider.getConnectionSourceLocation(sourcePlayer));
+
+ Command cmd = sourcePlayer.getCommand(reconnectRequest);
+ assertTrue(RECONNECTION_SOURCE + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, cmd.canExecute() == true);
+ int initSemanticSize = provider.getSemanticChildrenSize();
+
+ getDiagramCommandStack().execute(cmd);
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_EXECUTION, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == initSemanticSize);
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_SOURCE + TEST_THE_EXECUTION, branch.getSource().equals(sourcePlayer));
+
+ getDiagramCommandStack().undo();
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_UNDO, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_UNDO, provider.getSemanticChildrenSize() == initSemanticSize);
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_SOURCE + TEST_THE_UNDO, branch.getSource().equals(source));
+
+ getDiagramCommandStack().redo();
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_REDO, provider.getEdgesSize() == 1);
+ assertTrue(RECONNECTION_SOURCE + TEST_THE_REDO, provider.getSemanticChildrenSize() == initSemanticSize);
+ assertTrue(LINK_EXISTS_RECONNECTION_ON_SOURCE + TEST_THE_REDO, branch.getSource().equals(sourcePlayer));
+ }
+
+ /**
+ * Test to manage top node.
+ *
+ * @param type
+ * the type
+ * @param provider
+ * the container type
+ */
+ public void testToManageLink(IElementType sourceType, IElementType targetType, IElementType linkType, ILinkTestProvider provider, boolean allowedOntheSame) {
+ installEnvironment(sourceType, targetType, provider);
+ testToCreateALink(linkType, provider);
+ testDestroy(linkType, provider);
+
+ getEMFCommandStack().undo();
+ testViewDeletion(linkType, provider);
+
+ getEMFCommandStack().undo();
+ testSourceReconnectAMultiLink(linkType, provider);
+
+ getDiagramCommandStack().undo();
+ testTargetReconnectAMultiLink(linkType, provider);
+
+ testToCreateAlinkOnTheSame(linkType, provider, allowedOntheSame); // self link
+ }
+
+ /**
+ * test the creation of a link where the source and the target are the same objects
+ *
+ * @param linkType
+ * @param provider
+ * @param allowed
+ */
+ protected void testToCreateAlinkOnTheSame(IElementType linkType, ILinkTestProvider provider, boolean allowed) {
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 4);
+ int initSemanticSize = provider.getSemanticChildrenSize();
+
+ CreateConnectionViewRequest request = createConnectionViewRequest(linkType, source, source, provider);
+ request.setLocation(request.getLocation().translate(0, 10));
+
+ Command command = source.getCommand(request);
+ assertNotNull(CREATION + COMMAND_NULL, command);
+ if(allowed) {
+ assertTrue(CONTAINER_CREATION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == allowed);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEdgesSize() == 1);
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEdgesSize() == 2);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == initSemanticSize);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getEdgesSize() == 1);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getViewChildrenSize() == 4);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, provider.getEdgesSize() == 2);
+ }
+ }
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramChildNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramChildNode.java
new file mode 100644
index 00000000000..d0434720167
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramChildNode.java
@@ -0,0 +1,210 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.ActionExecutionSpecification;
+import org.eclipse.uml2.uml.BehaviorExecutionSpecification;
+import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InteractionFragment;
+import org.eclipse.uml2.uml.Lifeline;
+import org.junit.Test;
+
+
+public class TestSequenceDiagramChildNode extends TestChildNode {
+
+ @Override
+ protected CreateViewRequest createViewRequestShapeContainer() {
+ return CreateViewRequestFactory.getCreateShapeRequest(UMLElementTypes.Lifeline_3001, getDiagramEditPart().getDiagramPreferencesHint());
+ }
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testToManageActionExecution() {
+ testToManageChildNode(UMLElementTypes.ActionExecutionSpecification_3006, lifelineProvider);
+ }
+
+ @Test
+ public void testToManageBehaviorExecution() {
+ testToManageChildNode(UMLElementTypes.BehaviorExecutionSpecification_3003, lifelineProvider);
+ }
+
+ @Test
+ public void testToManageDestructionOccurrence() {
+ testToManageChildNode(UMLElementTypes.DestructionOccurrenceSpecification_3022, lifelineProvider);
+ }
+
+ @Test
+ public void testToManageCoRegion() {
+ semanticChild = false;
+ testToManageChildNode(UMLElementTypes.CombinedFragment_3018, lifelineProvider);
+ semanticChild = true;
+ }
+
+ @Test
+ public void testToManageStateInvariant() {
+ semanticChild = false;
+ testToManageChildNode(UMLElementTypes.StateInvariant_3017, lifelineProvider);
+ semanticChild = true;
+ }
+
+
+ @Test
+ public void testToManageTimeConstraint() {
+ createChildNode(UMLElementTypes.ActionExecutionSpecification_3006, lifelineProvider);
+ semanticChild = false;
+ testToManageChildNode(UMLElementTypes.TimeConstraint_3019, executionProvider);
+ semanticChild = true;
+ }
+
+ @Test
+ public void testToManageDurationConstraint() {
+ createChildNode(UMLElementTypes.ActionExecutionSpecification_3006, lifelineProvider);
+ semanticChild = false;
+
+ testToCreateChildNode(UMLElementTypes.ActionExecutionSpecification_3006, executionProvider);
+ {
+ //DESTROY SEMANTIC+ VIEW
+ IChildTestProvider provider = executionProvider;
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getViewChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, !provider.hasSemanticChild() || provider.getSemanticChildrenSize() == 1);
+
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = provider.getDestroyEditPart().getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getViewChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 0);
+ }
+
+ // the node has been destroyed, the UML element also
+ getEMFCommandStack().undo();
+
+ // the node and the UML element are present
+ testViewDeletion(UMLElementTypes.ActionExecutionSpecification_3006, executionProvider);
+
+ semanticChild = true;
+ }
+
+ GraphicalEditPart containerEditPart;
+
+ boolean semanticChild = true;
+
+ IChildTestProvider executionProvider = new IChildTestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return TestSequenceDiagramChildNode.this.lifelineProvider.getEditPartChildrenSize() - 1; // ignore ActionExecution
+ }
+
+ public int getSemanticChildrenSize() {
+ return TestSequenceDiagramChildNode.this.lifelineProvider.getSemanticChildrenSize() - 1;
+ }
+
+ public int getViewChildrenSize() {
+ return TestSequenceDiagramChildNode.this.lifelineProvider.getViewChildrenSize() - 1;
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return TestSequenceDiagramChildNode.this.lifelineProvider.getParentEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return (GraphicalEditPart)getParentEditPart().getChildren().get(2);
+ }
+
+ public boolean hasSemanticChild() {
+ return semanticChild;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ return TestSequenceDiagramChildNode.this.lifelineProvider.getChildLocation(parentEditPart);
+ }
+ };
+
+ IChildTestProvider lifelineProvider = new IChildTestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return getParentEditPart().getChildren().size() - 1; // ignore LifelineNameEditPart
+ }
+
+ public int getSemanticChildrenSize() {
+ Lifeline lifeline = ((Lifeline)getParentEditPart().getNotationView().getElement());
+ int count = 0;
+ for(InteractionFragment f : lifeline.getCoveredBys())
+ if(f instanceof DestructionOccurrenceSpecification || f instanceof ActionExecutionSpecification || f instanceof BehaviorExecutionSpecification)
+ count++;
+
+ return count;
+ }
+
+ public int getViewChildrenSize() {
+ return getParentEditPart().getNotationView().getChildren().size() - 1; // ignore LifelineNameEditPart view
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ if(containerEditPart == null) {
+ GraphicalEditPart ep = (GraphicalEditPart)getRootEditPart().getChildren().get(0);
+ containerEditPart = ep;
+ }
+ return containerEditPart;
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return (GraphicalEditPart)getParentEditPart().getChildren().get(1);
+ }
+
+ public boolean hasSemanticChild() {
+ return semanticChild;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ IFigure f = ((LifelineEditPart)parentEditPart).getPrimaryShape().getFigureLifelineDotLineFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ return b.getCenter().getCopy().translate(0, 50);
+ }
+ };
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramLink.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramLink.java
new file mode 100644
index 00000000000..08b7fdd4cea
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramLink.java
@@ -0,0 +1,252 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification;
+import org.eclipse.uml2.uml.MessageEnd;
+import org.junit.Test;
+
+public class TestSequenceDiagramLink extends TestLink {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testToManageGeneralOrdering() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.GeneralOrdering_4012, executionProvider, false);
+ }
+
+ @Test
+ public void testToManageMessageSync_4003() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4003, executionProvider, false);
+ }
+
+ @Test
+ public void testToManageMessageReply_4005() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4005, executionProvider, false);
+ }
+
+ @Test
+ public void testToManageMessageFound_4009() {
+ installEnvironment(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, lifelineProvider);
+ source = (GraphicalEditPart)source.getParent().getParent();
+ testToCreateALink(UMLElementTypes.Message_4009, lifelineProvider);
+
+ testDestroy(UMLElementTypes.Message_4009, lifelineProvider);
+ getEMFCommandStack().undo();
+ testViewDeletion(UMLElementTypes.Message_4009, lifelineProvider);
+ }
+
+ @Test
+ public void testToManageMessageLost_4008() {
+ installEnvironment(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, lifelineProvider);
+
+ target = (GraphicalEditPart)target.getParent().getParent();
+ testToCreateALink(UMLElementTypes.Message_4008, lifelineProvider);
+
+ testDestroy(UMLElementTypes.Message_4008, lifelineProvider);
+ getEMFCommandStack().undo();
+ testViewDeletion(UMLElementTypes.Message_4008, lifelineProvider);
+ }
+
+ @Test
+ public void testToManageCommentLink() {
+ testToManageLink(UMLElementTypes.Comment_3009, UMLElementTypes.Lifeline_3001, UMLElementTypes.CommentAnnotatedElement_4010, lifelineProvider, true);
+ }
+
+ @Test
+ public void testToManageConstraintLink() {
+ testToManageLink(UMLElementTypes.Constraint_3008, UMLElementTypes.Lifeline_3001, UMLElementTypes.ConstraintConstrainedElement_4011, lifelineProvider, true);
+ }
+
+ @Test
+ public void testToManageMessageAsync_4004() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4004, lifelineProvider, true);
+ }
+
+ @Test
+ public void testToManageMessageDelete_4007() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4007, lifelineProvider, true);
+ }
+
+ @Test
+ public void testToManageMessageCreate_4006() {
+ testToManageLink(UMLElementTypes.Lifeline_3001, UMLElementTypes.Lifeline_3001, UMLElementTypes.Message_4006, lifelineProvider, false);
+ }
+
+ @Override
+ public CreateConnectionViewRequest createConnectionViewRequest(IElementType type, EditPart source, EditPart target, ILinkTestProvider provider) {
+ CreateConnectionViewRequest request = super.createConnectionViewRequest(type, source, target, provider);
+
+ EObject container = getRootEditPart().resolveSemanticElement();
+ request.getExtendedData().put(SOURCE_MODEL_CONTAINER, container);
+ request.getExtendedData().put(TARGET_MODEL_CONTAINER, container);
+ return request;
+ }
+
+ private Point getCenter(IFigure f) {
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getCenter().getCopy();
+ return c;
+ }
+
+ protected ILinkTestProvider executionProvider = new ILinkTestProvider() {
+
+
+ public boolean hasSemanticChild() {
+ return TestSequenceDiagramLink.this.lifelineProvider.hasSemanticChild();
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ return TestSequenceDiagramLink.this.lifelineProvider.getChildLocation(parentEditPart);
+ }
+
+ public int getEditPartChildrenSize() {
+ return TestSequenceDiagramLink.this.lifelineProvider.getEditPartChildrenSize();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public int getSemanticChildrenSize() {
+ return TestSequenceDiagramLink.this.lifelineProvider.getSemanticChildrenSize() - 4; // ignore ActionExecution
+ }
+
+ public int getViewChildrenSize() {
+ return TestSequenceDiagramLink.this.lifelineProvider.getViewChildrenSize();
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return TestSequenceDiagramLink.this.lifelineProvider.getParentEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return null;
+ }
+
+ public int getEdgesSize() {
+ return TestSequenceDiagramLink.this.lifelineProvider.getEdgesSize();
+ }
+
+ public Point getConnectionSourceLocation(EditPart source) {
+ return TestSequenceDiagramLink.this.lifelineProvider.getConnectionSourceLocation(source);
+ }
+
+ public Point getConnectionTargetLocation(EditPart target) {
+ return TestSequenceDiagramLink.this.lifelineProvider.getConnectionTargetLocation(target);
+ }
+
+ public void setUp() {
+ IElementType childNodeType = UMLElementTypes.ActionExecutionSpecification_3006;
+ source = createSubNode(source, childNodeType, getChildLocation(source));
+ sourcePlayer = createSubNode(sourcePlayer, childNodeType, getChildLocation(sourcePlayer));
+
+ target = createSubNode(target, childNodeType, getChildLocation(target).translate(0, 50));
+ targetPlayer = createSubNode(targetPlayer, childNodeType, getChildLocation(targetPlayer).translate(0, 50));
+ }
+
+ };
+
+ protected ILinkTestProvider lifelineProvider = new ILinkTestProvider() {
+
+ public int getEdgesSize() {
+ return getDiagramEditPart().getDiagramView().getEdges().size();
+ }
+
+ public int getEditPartChildrenSize() {
+ return getRootEditPart().getChildren().size();
+ }
+
+ public int getSemanticChildrenSize() {
+ int count = 0;
+ EList<Element> elems = ((Element)getRootEditPart().getNotationView().getElement()).getOwnedElements();
+ for(Element f : elems)
+ if(!(f instanceof MessageEnd) && !(f instanceof ExecutionOccurrenceSpecification))
+ count++;
+
+ return count;
+ }
+
+ public int getViewChildrenSize() {
+ return getRootEditPart().getNotationView().getChildren().size();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return getRootEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return null;
+ }
+
+ public Point getConnectionSourceLocation(EditPart part) {
+ if(part instanceof LifelineEditPart) {
+ IFigure f = ((LifelineEditPart)part).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f);
+ }
+ if(part instanceof AbstractExecutionSpecificationEditPart || part instanceof InteractionEditPart) { // found message
+ return getAbsoluteBounds((IGraphicalEditPart)part).getTopLeft();
+ }
+ return new Point(0, 0);
+ }
+
+ public Point getConnectionTargetLocation(EditPart part) {
+ if(part instanceof LifelineEditPart) {
+ IFigure f = ((LifelineEditPart)part).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f);
+ }
+ if(part instanceof AbstractExecutionSpecificationEditPart || part instanceof InteractionEditPart) {
+ Rectangle r = getAbsoluteBounds((IGraphicalEditPart)part);
+ return r.getBottom();
+ }
+ return new Point(0, 0);
+ }
+
+ public boolean hasSemanticChild() {
+ return true;
+ }
+
+ public Point getChildLocation(GraphicalEditPart parentEditPart) {
+ IFigure f = ((LifelineEditPart)parentEditPart).getPrimaryShape().getFigureLifelineDotLineFigure();
+ return getCenter(f).translate(0, 1);
+ }
+
+ public void setUp() {
+ }
+ };
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramTopNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramTopNode.java
new file mode 100644
index 00000000000..f382b81a928
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramTopNode.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.tests.bug.PopupUtil;
+import org.eclipse.uml2.uml.Element;
+import org.junit.Test;
+
+
+public class TestSequenceDiagramTopNode extends TestTopNode {
+
+ @Override
+ protected ICreationCommand getDiagramCommandCreation() {
+ return new CreateSequenceDiagramCommand();
+ }
+
+ @Test
+ public void testToManageLifeline() {
+ testToManageTopNode(UMLElementTypes.Lifeline_3001, provider);
+ }
+
+ /**
+ * Test to manage constraint.
+ */
+ @Test
+ public void testToManageConstraint() {
+ testToManageTopNode(UMLElementTypes.Constraint_3008, provider);
+ }
+
+ /**
+ * Test to manage comment.
+ */
+ @Test
+ public void testToManageComment() {
+ testToManageTopNode(UMLElementTypes.Comment_3009, provider);
+ }
+
+ @Test
+ public void testToManageInteractionUse() {
+ testToManageTopNode(UMLElementTypes.InteractionUse_3002, provider);
+ }
+
+// @Test
+// public void testToManageConsiderIgnoreFragment() { // popup menu when delete
+// PopupUtil.addMenuListener(0);
+// testToManageTopNode(UMLElementTypes.ConsiderIgnoreFragment_3007, provider);
+//
+// waitForComplete();
+// PopupUtil.removeMenuListener();
+// }
+//
+// @Test
+// public void testToManageCombinedFragment() { // popup menu when delete
+// PopupUtil.addMenuListener(0);
+// testToManageTopNode(UMLElementTypes.CombinedFragment_3004, provider);
+//
+// waitForComplete();
+// PopupUtil.removeMenuListener();
+// }
+
+ @Test
+ public void testToManageTimeObservation() {
+ testToManageTopNode(UMLElementTypes.TimeObservation_3020, observationProvider);
+ }
+
+ @Test
+ public void testToManageDurationObservation() {
+ testToManageTopNode(UMLElementTypes.DurationObservation_3024, observationProvider);
+ }
+
+ ITestProvider provider = new ITestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return getRootEditPart().getChildren().size();
+ }
+
+ public int getSemanticChildrenSize() {
+ return getRootSemanticModel().getOwnedElements().size();
+ }
+
+ public int getViewChildrenSize() {
+ return getRootView().getChildren().size();
+ }
+
+ public Element getDropElement() {
+ return getRootSemanticModel().getOwnedElements().get(0);
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return getRootEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return (GraphicalEditPart)getParentEditPart().getChildren().get(0);
+ }
+
+ };
+
+ ITestProvider observationProvider = new ITestProvider() {
+
+ public int getEditPartChildrenSize() {
+ return getRootEditPart().getChildren().size();
+ }
+
+ public int getSemanticChildrenSize() {
+ return getPackage().getPackagedElements().size() - 1;
+ }
+
+ public int getViewChildrenSize() {
+ return getRootView().getChildren().size();
+ }
+
+ public Element getDropElement() {
+ return null;
+ }
+
+ public GraphicalEditPart getParentEditPart() {
+ return getRootEditPart();
+ }
+
+ public GraphicalEditPart getDestroyEditPart() {
+ return (GraphicalEditPart)getParentEditPart().getChildren().get(0);
+ }
+ };
+}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestTopNode.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestTopNode.java
new file mode 100644
index 00000000000..b7fbd528364
--- /dev/null
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestTopNode.java
@@ -0,0 +1,316 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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.diagram.sequence.tests.canonical;
+
+import java.util.ArrayList;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.diagram.tests.canonical.AbstractPapyrusTestCase;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+
+/**
+ * The Class TestTopNode.
+ */
+public abstract class TestTopNode extends AbstractPapyrusTestCase {
+
+ protected GraphicalEditPart rootPart;
+
+ protected GraphicalEditPart getRootEditPart() {
+ if(rootPart == null) {
+ GraphicalEditPart part = (GraphicalEditPart)getDiagramEditPart().getChildren().get(0);
+ rootPart = (GraphicalEditPart)part.getChildren().get(1); // compart
+ }
+ return rootPart;
+ }
+
+ protected View getRootView() {
+ return getRootEditPart().getNotationView();
+ }
+
+ protected Element getRootSemanticModel() {
+ return (Element)getRootView().getElement();
+ }
+
+ protected org.eclipse.emf.common.command.CommandStack getEMFCommandStack() {
+ return getRootEditPart().getEditingDomain().getCommandStack();
+ }
+
+ protected DiagramCommandStack getDiagramCommandStack() {
+ return getRootEditPart().getDiagramEditDomain().getDiagramCommandStack();
+ }
+
+ protected Package getPackage() {
+ Element container = (Element)getDiagramEditPart().getNotationView().getElement();
+ while(container != null && !(container instanceof Package)) {
+ container = (Element)container.eContainer();
+ }
+ return (Package)container;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ protected void waitForComplete() {
+ boolean run = true;
+ while(run) {
+ try {
+ run = Display.getDefault().readAndDispatch();
+ } catch (Exception e) {
+ run = true;
+ }
+ }
+ }
+
+ protected Point getAbsoluteCenter(IGraphicalEditPart part) {
+ IFigure f = part.getFigure();
+ Rectangle b = f.getBounds().getCopy();
+ f.translateToAbsolute(b);
+ Point c = b.getCenter().getCopy();
+ return c;
+ }
+
+ /**
+ * Get the bounds of an edit part
+ *
+ * @param part
+ * edit part to find bounds
+ * @return part's bounds in absolute coordinates
+ */
+ public static Rectangle getAbsoluteBounds(IGraphicalEditPart part) {
+ // take bounds from figure
+ Rectangle bounds = part.getFigure().getBounds().getCopy();
+
+ if(part.getNotationView() instanceof Node) {
+ // rather update with up to date model bounds
+ Node node = (Node)part.getNotationView();
+ LayoutConstraint cst = node.getLayoutConstraint();
+ if(cst instanceof Bounds) {
+ Bounds b = (Bounds)cst;
+ Point parentLoc = part.getFigure().getParent().getBounds().getLocation();
+ if(b.getX() > 0) {
+ bounds.x = b.getX() + parentLoc.x;
+ }
+ if(b.getY() > 0) {
+ bounds.y = b.getY() + parentLoc.y;
+ }
+ if(b.getHeight() != -1) {
+ bounds.height = b.getHeight();
+ }
+ if(b.getWidth() != -1) {
+ bounds.width = b.getWidth();
+ }
+ }
+ }
+
+ part.getFigure().getParent().translateToAbsolute(bounds);
+ return bounds;
+ }
+
+ /**
+ * Test view deletion.
+ *
+ * @param type
+ * the type
+ * @param provider
+ */
+ public void testViewDeletion(IElementType type, ITestProvider provider) {
+ //DELETION OF THE VIEW
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + INITIALIZATION_TEST, provider.getSemanticChildrenSize() == 1);
+
+ Request deleteViewRequest = new GroupRequest(RequestConstants.REQ_DELETE);
+ Command command = provider.getDestroyEditPart().getCommand(deleteViewRequest);
+ assertNotNull(VIEW_DELETION + COMMAND_NULL, command);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(VIEW_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(VIEW_DELETION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == 1);
+
+ getDiagramCommandStack().redo();
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 0);
+ assertTrue(VIEW_DELETION + TEST_THE_REDO, provider.getSemanticChildrenSize() == 1);
+
+ }
+
+ /**
+ * Retrieves the TransactionalEditingDomain
+ *
+ * @return the editing domain (can be null)
+ */
+ protected TransactionalEditingDomain getEditingDomain() {
+ ServiceUtilsForActionHandlers serviceUtils = new ServiceUtilsForActionHandlers();
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ editingDomain = serviceUtils.getTransactionalEditingDomain();
+
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+
+ return editingDomain;
+ }
+
+ /**
+ * Test destroy.
+ *
+ * @param type
+ * the type
+ * @param provider
+ */
+ public void testDestroy(IElementType type, ITestProvider provider) {
+ //DESTROY SEMANTIC+ VIEW
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + INITIALIZATION_TEST, provider.getSemanticChildrenSize() == 1);
+
+ Request deleteViewRequest = new EditCommandRequestWrapper(new DestroyElementRequest(false));
+ Command command = provider.getDestroyEditPart().getCommand(deleteViewRequest);
+ assertNotNull(DESTROY_DELETION + COMMAND_NULL, command);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DESTROY_DELETION + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getEMFCommandStack().execute(new GEFtoEMFCommandWrapper(command));
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 0);
+
+ getEMFCommandStack().undo();
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(DESTROY_DELETION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == 1);
+
+ getEMFCommandStack().redo();
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DESTROY_DELETION + TEST_THE_REDO, provider.getSemanticChildrenSize() == 0);
+ }
+
+
+ /**
+ * Test drop.
+ *
+ * @param type
+ * the type
+ * @param provider
+ */
+ public void testDrop(IElementType type, ITestProvider provider) {
+ if(provider.getDropElement() == null)
+ return;
+ //DROP
+ assertTrue(DROP + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DROP + INITIALIZATION_TEST, provider.getSemanticChildrenSize() == 1);
+
+ DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
+ ArrayList<Element> list = new ArrayList<Element>();
+ list.add(provider.getDropElement());
+ dropObjectsRequest.setObjects(list);
+ dropObjectsRequest.setLocation(new Point(20, 20));
+ Command command = getRootEditPart().getCommand(dropObjectsRequest);
+ assertNotNull(DROP + COMMAND_NULL, command);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_IS_CREATED, command != UnexecutableCommand.INSTANCE);
+ assertTrue(DROP + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, command.canExecute() == true);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(DROP + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() != 0);
+ assertTrue(DROP + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() != 0);
+
+ getDiagramCommandStack().undo();
+ assertTrue(DROP + TEST_THE_UNDO, provider.getEditPartChildrenSize() == 0);
+ assertTrue(DROP + TEST_THE_UNDO, provider.getSemanticChildrenSize() != 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(DROP + TEST_THE_REDO, provider.getEditPartChildrenSize() != 0);
+ assertTrue(DROP + TEST_THE_REDO, provider.getSemanticChildrenSize() != 0);
+ }
+
+
+ public void testToCreateANode(IElementType type, ITestProvider provider) {
+ //CREATION
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getEditPartChildrenSize() == 0);
+ assertTrue(CREATION + INITIALIZATION_TEST, provider.getSemanticChildrenSize() == 0);
+
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());
+ Command command = provider.getParentEditPart().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);
+
+ getDiagramCommandStack().execute(command);
+ assertTrue(CREATION + TEST_THE_EXECUTION, provider.getViewChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, provider.getSemanticChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_EXECUTION, provider.getEditPartChildrenSize() == 1);
+
+ getDiagramCommandStack().undo();
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getViewChildrenSize() == 0);
+ assertTrue(CREATION + TEST_THE_UNDO, provider.getSemanticChildrenSize() == 0);
+
+ getDiagramCommandStack().redo();
+ assertTrue(CREATION + TEST_THE_REDO, provider.getEditPartChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_REDO, provider.getSemanticChildrenSize() == 1);
+ assertTrue(CREATION + TEST_THE_REDO, provider.getViewChildrenSize() == 1);
+ }
+
+ /**
+ * Test to manage top node.
+ *
+ * @param type
+ * the type
+ * @param containerType
+ * the container type
+ */
+ public void testToManageTopNode(IElementType type, ITestProvider provider) {
+ testToCreateANode(type, provider);
+ testDestroy(type, provider);
+
+ getEMFCommandStack().undo();
+ testViewDeletion(type, provider);
+
+ testDrop(type, provider);
+ }
+}

Back to the top