Skip to content
Snippets Groups Projects
Commit 73e78336 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Throw error for multiple cart actions in settings view

parent 2d0a662a
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,9 @@ import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.*;
import org.controlsfx.control.SegmentedButton;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* Diese View ist die Basis für die Einstellunge für eine CartAction. Dabei enthällt diese View ein Grid aus Buttons (Carts), eine
......@@ -113,17 +115,21 @@ public class CartActionTypeViewController extends NVC {
int currentY = data[1];
try {
List<Action> cartActions = mapping.getActionsForType(actionType);
for (Action action : cartActions) {
if (CartAction.getX(action) == currentX && CartAction.getY(action) == currentY) {
final List<Action> cartActions = mapping.getActionsForType(actionType).stream()
.filter(action -> CartAction.getX(action) == currentX && CartAction.getY(action) == currentY)
.collect(Collectors.toList());
if (cartActions.size() > 1) {
throw new IllegalArgumentException("Only one action allowed per pad. Currently " + cartActions.size() + " are registered for pad coordinate " + Arrays.toString(data));
}
final Action action = cartActions.get(0);
if (actionViewController != null) {
cartActionContainer.getChildren().setAll(actionViewController.getParent());
cartActionContainer.setVisible(true);
actionViewController.setCartAction(action);
}
parentController.showMapperFor(action);
}
}
} catch (NoSuchComponentException e) {
Logger.error(e);
}
......
package de.tobias.playpad.viewcontroller.actions;
import de.thecodelabs.midi.action.Action;
import de.thecodelabs.utils.ui.NVC;
import de.thecodelabs.utils.util.Localization;
import de.tobias.playpad.Strings;
import de.tobias.playpad.action.actions.CartAction;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment