|
|
@@ -19,6 +19,7 @@ import org.jdesktop.swingx.VerticalLayout;
|
|
|
import org.leumasjaffe.observer.ObservableListener;
|
|
|
import org.leumasjaffe.observer.ObserverDispatch;
|
|
|
import org.leumasjaffe.recipe.controller.ReplaceChildrenAction;
|
|
|
+import org.leumasjaffe.recipe.controller.SetImageAction;
|
|
|
import org.leumasjaffe.recipe.controller.SpinnerBinding;
|
|
|
import org.leumasjaffe.recipe.controller.TextBinding;
|
|
|
import org.leumasjaffe.recipe.model.Element;
|
|
|
@@ -36,6 +37,7 @@ import javax.swing.JSpinner;
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE)
|
|
|
public class SummaryPanel extends JPanel {
|
|
|
ReplaceChildrenAction<RecipeCard, Element> controller;
|
|
|
+ SetImageAction setImage;
|
|
|
TextBinding<RecipeCard> titleBinding;
|
|
|
SpinnerBinding<RecipeCard, Integer> servingsBinding;
|
|
|
SpinnerBinding<ScaleFactor, Integer> servingsToMakeBinding;
|
|
|
@@ -43,6 +45,7 @@ public class SummaryPanel extends JPanel {
|
|
|
ObservableListener<CollatedDurationPanel, RecipeCard> durationListener;
|
|
|
ObservableListener<JPanel, RecipeCard> childListener;
|
|
|
|
|
|
+ ImagePanel panelPhoto;
|
|
|
JTextField txtTitle;
|
|
|
JTextArea txaDescription;
|
|
|
TagInputPanel panelTags;
|
|
|
@@ -151,7 +154,7 @@ public class SummaryPanel extends JPanel {
|
|
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
|
panel.setLayout(gbl_panel);
|
|
|
|
|
|
- JPanel panelPhoto = new ImagePanel();
|
|
|
+ panelPhoto = new ImagePanel();
|
|
|
GridBagConstraints gbc_panelPhoto = new GridBagConstraints();
|
|
|
gbc_panelPhoto.fill = GridBagConstraints.BOTH;
|
|
|
gbc_panelPhoto.insets = new Insets(0, 0, 5, 0);
|
|
|
@@ -179,6 +182,9 @@ public class SummaryPanel extends JPanel {
|
|
|
gbc_txaDescription.gridy = 2;
|
|
|
panel.add(txaDescription, gbc_txaDescription);
|
|
|
|
|
|
+ setImage = new SetImageAction(panelPhoto::setImage);
|
|
|
+ panelPhoto.addMouseListener(setImage);
|
|
|
+
|
|
|
titleBinding = new TextBinding<>(txtTitle,
|
|
|
RecipeCard::getTitle, RecipeCard::setTitle);
|
|
|
|
|
|
@@ -209,6 +215,9 @@ public class SummaryPanel extends JPanel {
|
|
|
}
|
|
|
|
|
|
public void setModel(final RecipeCard card) {
|
|
|
+ // We need to always update the image
|
|
|
+ panelPhoto.setImage(card.getPhoto().orElse(null));
|
|
|
+ setImage.setModel(card);
|
|
|
panelTags.setModel(card.getTags());
|
|
|
titleBinding.setModel(card);
|
|
|
servingsBinding.setModel(card);
|