|
|
@@ -30,7 +30,10 @@ public class SummaryPanel extends JPanel {
|
|
|
ObservableListener<CollatedDurationPanel, RecipeCard> durationListener;
|
|
|
ObservableListener<JPanel, RecipeCard> childListener;
|
|
|
|
|
|
- public SummaryPanel(final RecipeCard card) {
|
|
|
+ JTextField txtTitle;
|
|
|
+ JTextArea txaDesription;
|
|
|
+
|
|
|
+ public SummaryPanel() {
|
|
|
controller = new ReplaceChildrenController<>(RecipeCard::getElements, element -> {
|
|
|
JPanel wrapper = new JPanel(new VerticalLayout());
|
|
|
wrapper.add(new ElementPanel(element));
|
|
|
@@ -60,8 +63,7 @@ public class SummaryPanel extends JPanel {
|
|
|
gbl_panelHeader.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
|
|
panelHeader.setLayout(gbl_panelHeader);
|
|
|
|
|
|
- JTextField txtTitle = new JTextField();
|
|
|
- txtTitle.setText(card.getTitle());
|
|
|
+ txtTitle = new JTextField();
|
|
|
GridBagConstraints gbc_txtTitle = new GridBagConstraints();
|
|
|
gbc_txtTitle.insets = new Insets(0, 0, 0, 5);
|
|
|
gbc_txtTitle.fill = GridBagConstraints.HORIZONTAL;
|
|
|
@@ -107,11 +109,10 @@ public class SummaryPanel extends JPanel {
|
|
|
gbc_panelPhoto.gridy = 0;
|
|
|
panel.add(panelPhoto, gbc_panelPhoto);
|
|
|
|
|
|
- JTextArea txaDesription = new JTextArea(5, 20);
|
|
|
+ txaDesription = new JTextArea(5, 20);
|
|
|
txaDesription.setFont(new Font("Verdana", Font.PLAIN, 10));
|
|
|
txaDesription.setWrapStyleWord(true);
|
|
|
txaDesription.setLineWrap(true);
|
|
|
- txaDesription.setText(card.getDescription());
|
|
|
GridBagConstraints gbc_txaDesription = new GridBagConstraints();
|
|
|
gbc_txaDesription.insets = new Insets(0, 0, 5, 0);
|
|
|
gbc_txaDesription.fill = GridBagConstraints.BOTH;
|
|
|
@@ -125,7 +126,16 @@ public class SummaryPanel extends JPanel {
|
|
|
// This indirection allows for testing of controller
|
|
|
childListener = new ObservableListener<>(panelIngredients,
|
|
|
(c, v) -> controller.accept(c, v));
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ public SummaryPanel(final RecipeCard card) {
|
|
|
+ this();
|
|
|
+ setModel(card);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setModel(final RecipeCard card) {
|
|
|
+ txtTitle.setText(card.getTitle());
|
|
|
+ txaDesription.setText(card.getDescription());
|
|
|
durationListener.setObserved(card);
|
|
|
childListener.setObserved(card);
|
|
|
}
|