|
|
@@ -6,28 +6,24 @@ import java.awt.Insets;
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
import javax.swing.JSeparator;
|
|
|
+import javax.swing.JTextArea;
|
|
|
import javax.swing.JTextField;
|
|
|
-import javax.swing.JTextPane;
|
|
|
|
|
|
import org.jdesktop.swingx.VerticalLayout;
|
|
|
-import org.leumasjaffe.recipe.model.CollatedDuration;
|
|
|
import org.leumasjaffe.recipe.model.Element;
|
|
|
+import org.leumasjaffe.recipe.model.RecipeCard;
|
|
|
import org.leumasjaffe.recipe.view.CollatedDurationPanel;
|
|
|
import org.leumasjaffe.recipe.view.ImagePanel;
|
|
|
|
|
|
import lombok.AccessLevel;
|
|
|
import lombok.experimental.FieldDefaults;
|
|
|
-import lombok.experimental.NonFinal;
|
|
|
+import java.awt.Font;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
public class SummaryPanel extends JPanel {
|
|
|
- JPanel panelIngredients;
|
|
|
- // TODO
|
|
|
- @NonFinal JPanel panelDuration;
|
|
|
- JPanel panelHeader;
|
|
|
|
|
|
- public SummaryPanel() {
|
|
|
+ public SummaryPanel(final RecipeCard card) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
|
|
|
@@ -35,7 +31,7 @@ public class SummaryPanel extends JPanel {
|
|
|
gridBagLayout.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
|
|
setLayout(gridBagLayout);
|
|
|
|
|
|
- panelHeader = new JPanel();
|
|
|
+ JPanel panelHeader = new JPanel();
|
|
|
GridBagConstraints gbc_panelHeader = new GridBagConstraints();
|
|
|
gbc_panelHeader.gridwidth = 2;
|
|
|
gbc_panelHeader.insets = new Insets(0, 0, 5, 0);
|
|
|
@@ -51,7 +47,7 @@ public class SummaryPanel extends JPanel {
|
|
|
panelHeader.setLayout(gbl_panelHeader);
|
|
|
|
|
|
JTextField txtTitle = new JTextField();
|
|
|
- txtTitle.setText("Title");
|
|
|
+ txtTitle.setText(card.getTitle());
|
|
|
GridBagConstraints gbc_txtTitle = new GridBagConstraints();
|
|
|
gbc_txtTitle.insets = new Insets(0, 0, 0, 5);
|
|
|
gbc_txtTitle.fill = GridBagConstraints.HORIZONTAL;
|
|
|
@@ -60,13 +56,14 @@ public class SummaryPanel extends JPanel {
|
|
|
panelHeader.add(txtTitle, gbc_txtTitle);
|
|
|
txtTitle.setColumns(10);
|
|
|
|
|
|
- panelDuration = new JPanel();
|
|
|
+ CollatedDurationPanel panelDuration =
|
|
|
+ new CollatedDurationPanel(card.getCollatedDuration());
|
|
|
GridBagConstraints gbc_panelDuration = new GridBagConstraints();
|
|
|
gbc_panelDuration.gridx = 0;
|
|
|
gbc_panelDuration.gridy = 1;
|
|
|
panelHeader.add(panelDuration, gbc_panelDuration);
|
|
|
|
|
|
- panelIngredients = new JPanel();
|
|
|
+ JPanel panelIngredients = new JPanel();
|
|
|
GridBagConstraints gbc_panelIngredients = new GridBagConstraints();
|
|
|
gbc_panelIngredients.insets = new Insets(0, 0, 5, 5);
|
|
|
gbc_panelIngredients.fill = GridBagConstraints.BOTH;
|
|
|
@@ -96,30 +93,22 @@ public class SummaryPanel extends JPanel {
|
|
|
gbc_panelPhoto.gridy = 0;
|
|
|
panel.add(panelPhoto, gbc_panelPhoto);
|
|
|
|
|
|
- JTextPane textpnDesription = new JTextPane();
|
|
|
- GridBagConstraints gbc_textpnDesription = new GridBagConstraints();
|
|
|
- gbc_textpnDesription.insets = new Insets(0, 0, 5, 0);
|
|
|
- gbc_textpnDesription.fill = GridBagConstraints.BOTH;
|
|
|
- gbc_textpnDesription.gridx = 0;
|
|
|
- gbc_textpnDesription.gridy = 1;
|
|
|
- panel.add(textpnDesription, gbc_textpnDesription);
|
|
|
- }
|
|
|
-
|
|
|
- public void addElement(final Element comp) {
|
|
|
- panelIngredients.add(new ElementPanel(comp));
|
|
|
- panelIngredients.add(new JSeparator());
|
|
|
+ JTextArea 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;
|
|
|
+ gbc_txaDesription.gridx = 0;
|
|
|
+ gbc_txaDesription.gridy = 1;
|
|
|
+ panel.add(txaDesription, gbc_txaDesription);
|
|
|
+
|
|
|
+ for (final Element element : card.getElements()) {
|
|
|
+ panelIngredients.add(new ElementPanel(element));
|
|
|
+ panelIngredients.add(new JSeparator());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public void removeElements() {
|
|
|
- panelIngredients.removeAll();
|
|
|
- }
|
|
|
-
|
|
|
- public void setCollatedDuration(CollatedDuration collatedDuration) {
|
|
|
- panelHeader.remove(panelDuration);
|
|
|
- panelDuration = new CollatedDurationPanel(collatedDuration);
|
|
|
- GridBagConstraints gbc_panelDuration = new GridBagConstraints();
|
|
|
- gbc_panelDuration.gridx = 0;
|
|
|
- gbc_panelDuration.gridy = 1;
|
|
|
- panelHeader.add(panelDuration, gbc_panelDuration);
|
|
|
- }
|
|
|
}
|