| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package org.leumasjaffe.recipe.view;
- import javax.swing.JSplitPane;
- import org.jdesktop.swingx.VerticalLayout;
- import org.leumasjaffe.recipe.controller.FileController;
- import org.leumasjaffe.recipe.model.Element;
- import org.leumasjaffe.recipe.model.RecipeCard;
- import org.leumasjaffe.recipe.view.summary.SummaryPanel;
- import lombok.AccessLevel;
- import lombok.experimental.FieldDefaults;
- import javax.swing.JPanel;
- @SuppressWarnings("serial")
- @FieldDefaults(level=AccessLevel.PRIVATE)
- public class RecipeCardPanel extends JSplitPane implements FileController.ViewModel {
- SummaryPanel summaryPanel;
- JPanel rightPanel;
-
- public RecipeCardPanel() {
- rightPanel = new JPanel();
- rightPanel.setLayout(new VerticalLayout(5));
- setRightComponent(rightPanel);
-
- summaryPanel = new SummaryPanel();
- setLeftComponent(summaryPanel);
- }
- @Override
- public void setModel(final RecipeCard card) {
- rightPanel.removeAll();
- summaryPanel.removeElements();
- summaryPanel.setCollatedDuration(card.getCollatedDuration());
- card.getElements().forEach(this::addElement);
- }
-
- private void addElement(final Element comp) {
- summaryPanel.addElement(comp);
- rightPanel.add(new ElementPanel(comp));
- }
- }
|