From c8c3cf0ffbb626bcb74b8838423490539c0ea702 Mon Sep 17 00:00:00 2001 From: Alois Zoitl Date: Sun, 11 Aug 2024 21:59:57 +0200 Subject: [PATCH] AdapterFBs where not correctly updated in CFBs When changing the adapter type of an adapter of a CFB interface the FB shown in the network was using the wrong type during update. --- .../model/commands/change/ChangeAdapterFBCommand.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeAdapterFBCommand.java b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeAdapterFBCommand.java index b2d3c4fd26..d724329cdc 100644 --- a/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeAdapterFBCommand.java +++ b/plugins/org.eclipse.fordiac.ide.model.commands/src/org/eclipse/fordiac/ide/model/commands/change/ChangeAdapterFBCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2023 Profactor GmbH, fortiss GmbH, + * Copyright (c) 2008, 2024 Profactor GmbH, fortiss GmbH, * Johannes Kepler University Linz * Martin Erich Jobst * @@ -26,7 +26,6 @@ public final class ChangeAdapterFBCommand extends UpdateFBTypeCommand { public ChangeAdapterFBCommand(final AdapterDeclaration adpDecl) { super(adpDecl.getAdapterNetworkFB(), null); - setEntry(adpDecl.getType().getTypeEntry()); } @Override @@ -43,6 +42,8 @@ protected FBNetworkElement createCopiedFBEntry(final FBNetworkElement srcElement @Override public void execute() { + // use the type of the adapterDecl for changing the adapterfbs type + setEntry(getOldElement().getAdapterDecl().getType().getTypeEntry()); super.execute(); setAdapterNetworkFB((AdapterFB) newElement); } @@ -62,4 +63,9 @@ public void redo() { private static void setAdapterNetworkFB(final AdapterFB fb) { fb.getAdapterDecl().setAdapterNetworkFB(fb); } + + @Override + public AdapterFB getOldElement() { + return (AdapterFB) super.getOldElement(); + } }