Skip to content

Commit

Permalink
Add support for triggering subapp events
Browse files Browse the repository at this point in the history
  • Loading branch information
mx990 committed Nov 6, 2024
1 parent ad58159 commit cc3bf68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ public final Object execute(final ExecutionEvent event) throws ExecutionExceptio

private void execute(final Object selectedElement, final Shell shell)
throws DeploymentException, ExecutionException {
final T target = getTarget(selectedElement);
if (target == null) {
final List<T> targets = getTargets(selectedElement);
if (targets == null) {
return;
}
for (final T target : targets) {
execute(target, shell);
}
}

private void execute(final T target, final Shell shell) throws DeploymentException, ExecutionException {
final Resource resource = DeploymentDebugWatchUtils.getResource(target);
if (resource == null) {
throw new DeploymentException(MessageFormat.format(Messages.AbstractDeploymentHandler_ElementNotInResource,
Expand Down Expand Up @@ -109,7 +115,7 @@ protected void perform(final T target, final Resource resource, final Shell shel
protected abstract void perform(T target, Resource resource, IDeviceManagementInteractor interactor, Shell shell)
throws DeploymentException;

protected abstract T getTarget(Object selectedElement);
protected abstract List<T> getTargets(Object selectedElement);

protected static ILaunch launch(final AutomationSystem system) throws DeploymentException {
final Optional<IResource> resource = getResource(system);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.fordiac.ide.deployment.debug.ui.handler;

import java.util.List;

import org.eclipse.core.runtime.Adapters;
import org.eclipse.fordiac.ide.deployment.debug.watch.DeploymentDebugWatchUtils;
import org.eclipse.fordiac.ide.deployment.exceptions.DeploymentException;
Expand All @@ -30,7 +32,9 @@ protected void perform(final Event target, final Resource resource, final IDevic
}

@Override
protected Event getTarget(final Object selectedElement) {
return Adapters.adapt(selectedElement, IInterfaceElement.class) instanceof final Event event ? event : null;
protected List<Event> getTargets(final Object selectedElement) {
return Adapters.adapt(selectedElement, IInterfaceElement.class) instanceof final Event event
? DeploymentDebugWatchUtils.resolveSubappInterfaceConnections(event).toList()
: null;
}
}

0 comments on commit cc3bf68

Please sign in to comment.