elements.add(copyAction);
}
}
}
if (node instanceof SwimlanedNode) {
Swimlane swimlane = ((SwimlanedNode) node).getSwimlane();
if (swimlane != null) {
CopySwimlaneAction copyAction = new CopySwimlaneAction(swimlane);
elements.add(copyAction);
}
}
if (node instanceof Active) {
List<? extends org.jbpm.ui.common.model.Action> actions = ((Active) node).getActions();
for (org.jbpm.ui.common.model.Action action : actions) {
AddActionHandlerAction copyAction = new AddActionHandlerAction((Active) copy, action);
elements.add(copyAction);
}
}
}
}
// add transitions
GEFElementCreationFactory trFactory = new GEFElementCreationFactory("transition", targetDefinition);
for (Node node : sourceNodeList) {
List<Transition> transitions = node.getChildren(Transition.class);
for (Transition transition : transitions) {
Node source = targetNodeList.get(transition.getSource().getName());
Node target = targetNodeList.get(transition.getTarget().getName());
if (source != null && target != null) {
Transition tr = (Transition) trFactory.getNewObject(source);
tr.setName(transition.getName());
tr.setTarget(target);
for (Bendpoint bp : transition.getBendpoints()) {
tr.getBendpoints().add(new Bendpoint(bp.getX(), bp.getY()));
}
source.addLeavingTransition(tr);
for (org.jbpm.ui.common.model.Action action : transition.getActions()) {
AddActionHandlerAction copyAction = new AddActionHandlerAction(tr, action);
elements.add(copyAction);
}
}
}
}
List<ExtraCopyAction> userConfirmedActions = new ArrayList<ExtraCopyAction>();
for (ExtraCopyAction copyAction : elements) {
if (copyAction.isUserConfirmationRequired()) {
copyAction.setEnabled(false);
userConfirmedActions.add(copyAction);
}
}
if (userConfirmedActions.size() > 0) {
// display dialog with collisions
CopyGraphRewriteDialog dialog = new CopyGraphRewriteDialog(userConfirmedActions);
dialog.open();
}
// run copy actions
for (ExtraCopyAction copyAction : elements) {
if (copyAction.isEnabled()) {
copyAction.execute();
executedActionsList.add(copyAction);
}
}
// set swimlanes
for (Node node : targetNodeList.values()) {
if (node instanceof SwimlanedNode) {
SwimlanedNode sourceNode = (SwimlanedNode) copyBuffer.getSourceDefinition().getNodeByNameNotNull(node.getName());
Swimlane swimlane = targetDefinition.getSwimlaneByName(sourceNode.getSwimlaneName());
((SwimlanedNode) node).setSwimlane(swimlane);
}
}
} catch (Exception e) {
DesignerLogger.logError("'Paste' operation failed", e);