Skip to content

Commit

Permalink
Converting a BPMN task creates a new shape
Browse files Browse the repository at this point in the history
Change-Id: I0cc18e33df5ceea88d494880d193799e74954c3e
  • Loading branch information
Stephane Drapeau authored and Stephane Drapeau committed Dec 6, 2023
1 parent 5e6a6e2 commit 10e63e8
Showing 1 changed file with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

import java.util.Collection;

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.diagram.DDiagramElementContainer;
import org.eclipse.sirius.diagram.DNodeContainer;
import org.obeonetwork.dsl.bpmn2.Association;
Expand Down Expand Up @@ -123,22 +125,22 @@ public boolean isLikeChoreographyTask(final EObject eObject) {
public Task convertToTask(final DNodeContainer view) {
Task eObject = (Task) view.getTarget();
if (!eObject.getClass().isAssignableFrom(TaskImpl.class)) {
return (Task) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getTask());
return (Task) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getTask(),view);
}
return eObject;
}

public BusinessRuleTask convertToBusinessRuleTask(final DNodeContainer view) {
return (BusinessRuleTask) convertToSpecificTask((Task) view.getTarget(),
Bpmn2Package.eINSTANCE.getBusinessRuleTask());
Bpmn2Package.eINSTANCE.getBusinessRuleTask(),view);
}

public ManualTask convertToManualTask(final DNodeContainer view) {
return (ManualTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getManualTask());
return (ManualTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getManualTask(),view);
}

public ReceiveTask convertToReceiveTask(final DNodeContainer view) {
return (ReceiveTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getReceiveTask());
return (ReceiveTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getReceiveTask(),view);
}

public ScriptTask convertToScriptTask(final DNodeContainer view) {
Expand All @@ -147,24 +149,15 @@ public ScriptTask convertToScriptTask(final DNodeContainer view) {
}

public SendTask convertToSendTask(final DNodeContainer view) {
return (SendTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getSendTask());
return (SendTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getSendTask(),view);
}

public ServiceTask convertToServiceTask(final DNodeContainer view) {
return (ServiceTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getServiceTask());
return (ServiceTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getServiceTask(),view);
}

public UserTask convertToUserTask(final DNodeContainer view) {
return (UserTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getUserTask());
}

private Task convertToSpecificTask(Task task, EClass eClass) {
if (eClass.equals(task.eClass())) {
return task;
} else {
Task cloneTask = clone(task, (Task) Bpmn2Factory.eINSTANCE.create(eClass));
return cloneTask;
}
return (UserTask) convertToSpecificTask((Task) view.getTarget(), Bpmn2Package.eINSTANCE.getUserTask(),view);
}

private Task convertToSpecificTask(Task task, EClass eClass, DNodeContainer container) {
Expand All @@ -174,9 +167,8 @@ private Task convertToSpecificTask(Task task, EClass eClass, DNodeContainer cont
} else {
Task cloneTask = clone(task, (Task) Bpmn2Factory.eINSTANCE.create(eClass));
result = cloneTask;
}
if (result != null) {
container.setTarget(result);
DialectManager.INSTANCE.refresh(container.getParentDiagram(), new NullProgressMonitor());
}
return result;
}
Expand Down

0 comments on commit 10e63e8

Please sign in to comment.