summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboyko2014-08-05 10:27:56 (EDT)
committerCamille Letavernier2014-08-07 08:24:03 (EDT)
commitd4f84988b194f95a55d0e4e4578bfbcbce31b2e1 (patch)
treeef7c43d1416e223bfbc5dd0a8b843f06d362ad31
parentec9e7064748f00f1cbaea710103064b1738356b8 (diff)
downloadorg.eclipse.papyrus-d4f84988b194f95a55d0e4e4578bfbcbce31b2e1.zip
org.eclipse.papyrus-d4f84988b194f95a55d0e4e4578bfbcbce31b2e1.tar.gz
org.eclipse.papyrus-d4f84988b194f95a55d0e4e4578bfbcbce31b2e1.tar.bz2
[437605] - Export Sequence Diagram to Imagesrefs/changes/47/31047/2
Change-Id: I70b6a5c7efa036fd023c90ee15e63fb98703bbfe Signed-off-by: sboyko <serg.boyko2011@gmail.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContinuationEditPart.java10
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF1
-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.java48
3 files changed, 59 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContinuationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContinuationEditPart.java
index 6dfee63..0cf61fa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContinuationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContinuationEditPart.java
@@ -258,6 +258,16 @@ public class ContinuationEditPart extends AbstractBorderItemEditPart {
*/
@Override
protected void setLineWidth(int width) {
+ /**
+ * Bug 437605 - Export Sequence Diagram to Images
+ *
+ * Guard against negative line width
+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart#setLineWidth(int width)
+ */
+ if (width < 0) {
+ width = 1;
+ }
+
if(primaryShape instanceof Shape) {
((Shape)primaryShape).setLineWidth(width);
}
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
index c37559c..7dff994 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF
@@ -5,6 +5,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.papyrus.editor;bundle-version="1.0.0",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="1.7.0",
org.eclipse.papyrus.uml.diagram.common;bundle-version="1.0.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
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
index 3deceb3..2ce3b08 100644
--- 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
@@ -16,6 +16,9 @@ package org.eclipse.papyrus.uml.diagram.sequence.tests.bug;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.ecore.EAttribute;
@@ -23,6 +26,8 @@ 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.image.ImageFileFormat;
+import org.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUtil;
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;
@@ -34,11 +39,14 @@ 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.CustomConsiderIgnoreFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomContinuationEditPart;
+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.ISequenceDiagramTestsConstants;
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.Continuation;
import org.eclipse.uml2.uml.InteractionOperatorKind;
import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Test;
@@ -57,6 +65,10 @@ public class TestCombinedFragmentKind_364710 extends TestTopNode {
private static final String CHANGE_OPERATOR_KIND = "Change Operator Kind: ";
+ private static final String CHANGE_CONTINUATION_SETTING = "Change Continuation Setting: ";
+
+ private static final String COPY_TO_IMAGE = "Copy To Image: ";
+
@Override
protected ICreationCommand getDiagramCommandCreation() {
return new CreateSequenceDiagramCommand();
@@ -107,6 +119,30 @@ public class TestCombinedFragmentKind_364710 extends TestTopNode {
}
}
+ @Test
+ public void testCombinedFragmentContinuation() throws CoreException {
+ 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);
+
+ CombinedFragment cf = (CombinedFragment)cep.resolveSemanticElement();
+ changeOperatorKind(cep, cf, InteractionOperatorKind.ALT_LITERAL);
+
+ // add continuation
+ InteractionOperandEditPart op = (InteractionOperandEditPart)cfp.getChildren().get(0);
+ createNode(UMLElementTypes.Continuation_3016, op, new Point(1, 1), new Dimension(20, 60));
+ assertTrue(CREATION + TEST_THE_EXECUTION, op.getChildren().size() == 2);
+ CustomContinuationEditPart ccep = (CustomContinuationEditPart)op.getChildren().get(1);
+ Continuation continuation = (Continuation) ccep.resolveSemanticElement();
+ changeContinuationSetting(ccep, continuation, false);
+
+ // export to image
+ CopyToImageUtil copyToImageUtil = new CopyToImageUtil();
+ IPath path = project.getFile(getFileName() + '.' + ImageFileFormat.PNG.getName()).getRawLocation();
+ copyToImageUtil.copyToImage(getDiagramEditPart(), path, ImageFileFormat.PNG, new NullProgressMonitor());
+ assertTrue(COPY_TO_IMAGE + TEST_THE_EXECUTION, path.toFile().exists());
+ }
+
protected void changeOperatorKind(CombinedFragmentEditPart p, CombinedFragment cf, InteractionOperatorKind kind) {
EAttribute feature = UMLPackage.eINSTANCE.getCombinedFragment_InteractionOperator();
IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
@@ -119,6 +155,18 @@ public class TestCombinedFragmentKind_364710 extends TestTopNode {
assertTrue(CHANGE_OPERATOR_KIND + TEST_THE_EXECUTION, cf.getInteractionOperator() == kind);
}
+ protected void changeContinuationSetting(CustomContinuationEditPart p, Continuation cf, Boolean isSetting) {
+ EAttribute feature = UMLPackage.eINSTANCE.getContinuation_Setting();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cf);
+ SetRequest request = new SetRequest(p.getEditingDomain(), cf, feature, isSetting);
+ ICommand createGMFCommand = provider.getEditCommand(request);
+ org.eclipse.emf.common.command.AbstractCommand emfCommand = new GMFtoEMFCommandWrapper(createGMFCommand);
+ assertTrue(CHANGE_CONTINUATION_SETTING + TEST_IF_THE_COMMAND_CAN_BE_EXECUTED, emfCommand.canExecute() == true);
+ getEMFCommandStack().execute(emfCommand);
+ waitForComplete();
+ assertTrue(CHANGE_CONTINUATION_SETTING + TEST_THE_EXECUTION, cf.isSetting() == isSetting);
+ }
+
public void createNode(IElementType type, EditPart parentPart, Point location, Dimension size) {
//CREATION
CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, getRootEditPart().getDiagramPreferencesHint());