|
|
@@ -4,6 +4,10 @@ import java.awt.Dimension;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.GridBagLayout;
|
|
|
import java.awt.Insets;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.function.Predicate;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
import javax.swing.JSeparator;
|
|
|
@@ -46,7 +50,10 @@ public class SummaryPanel extends JPanel {
|
|
|
JSpinner spnServingsToMake;
|
|
|
|
|
|
public SummaryPanel(final ScaleFactor scale) {
|
|
|
- controller = new ReplaceChildrenAction<>(RecipeCard::getElements, element -> {
|
|
|
+ final Predicate<Element> hasIngredients = e -> !e.getIngredients().isEmpty();
|
|
|
+ final Function<RecipeCard, Collection<Element>> func =
|
|
|
+ rc -> rc.getComponents().filter(hasIngredients).collect(Collectors.toList());
|
|
|
+ controller = new ReplaceChildrenAction<>(func, element -> {
|
|
|
JPanel wrapper = new JPanel(new VerticalLayout());
|
|
|
wrapper.add(new ElementPanel(element, scale));
|
|
|
wrapper.add(new JSeparator());
|