فهرست منبع

Add Duration to SummaryPanel

Sam Jaffe 5 سال پیش
والد
کامیت
0c79f9bad9

+ 1 - 0
src/main/lombok/org/leumasjaffe/recipe/view/RecipeCardPanel.java

@@ -32,6 +32,7 @@ public class RecipeCardPanel extends JSplitPane implements FileController.ViewMo
 	public void setModel(final RecipeCard card) {
 		rightPanel.removeAll();
 		summaryPanel.removeElements();
+		summaryPanel.setCollatedDuration(card.getCollatedDuration());
 		card.getElements().forEach(this::addElement);
 	}
 	

+ 25 - 11
src/main/lombok/org/leumasjaffe/recipe/view/summary/SummaryPanel.java

@@ -4,23 +4,28 @@ import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
 
-import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JSeparator;
 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.view.CollatedDurationPanel;
 import org.leumasjaffe.recipe.view.ImagePanel;
 
 import lombok.AccessLevel;
 import lombok.experimental.FieldDefaults;
+import lombok.experimental.NonFinal;
 
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 public class SummaryPanel extends JPanel {
 	JPanel panelIngredients;
+	// TODO
+	@NonFinal JPanel panelDuration;
+	JPanel panelHeader;
 	
 	public SummaryPanel() {
 		GridBagLayout gridBagLayout = new GridBagLayout();
@@ -30,7 +35,7 @@ public class SummaryPanel extends JPanel {
 		gridBagLayout.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
 		setLayout(gridBagLayout);
 		
-		JPanel panelHeader = new JPanel();
+		panelHeader = new JPanel();
 		GridBagConstraints gbc_panelHeader = new GridBagConstraints();
 		gbc_panelHeader.gridwidth = 2;
 		gbc_panelHeader.insets = new Insets(0, 0, 5, 0);
@@ -39,10 +44,10 @@ public class SummaryPanel extends JPanel {
 		gbc_panelHeader.gridy = 0;
 		add(panelHeader, gbc_panelHeader);
 		GridBagLayout gbl_panelHeader = new GridBagLayout();
-		gbl_panelHeader.columnWidths = new int[]{0, 0, 0};
-		gbl_panelHeader.rowHeights = new int[]{0, 0};
-		gbl_panelHeader.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
-		gbl_panelHeader.rowWeights = new double[]{0.0, Double.MIN_VALUE};
+		gbl_panelHeader.columnWidths = new int[]{0, 0};
+		gbl_panelHeader.rowHeights = new int[]{0, 0, 0};
+		gbl_panelHeader.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+		gbl_panelHeader.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
 		panelHeader.setLayout(gbl_panelHeader);
 		
 		JTextField txtTitle = new JTextField();
@@ -55,11 +60,11 @@ public class SummaryPanel extends JPanel {
 		panelHeader.add(txtTitle, gbc_txtTitle);
 		txtTitle.setColumns(10);
 		
-		JLabel lblDuration = new JLabel("Duration");
-		GridBagConstraints gbc_lblDuration = new GridBagConstraints();
-		gbc_lblDuration.gridx = 1;
-		gbc_lblDuration.gridy = 0;
-		panelHeader.add(lblDuration, gbc_lblDuration);
+		panelDuration = new JPanel();
+		GridBagConstraints gbc_panelDuration = new GridBagConstraints();
+		gbc_panelDuration.gridx = 0;
+		gbc_panelDuration.gridy = 1;
+		panelHeader.add(panelDuration, gbc_panelDuration);
 		
 		panelIngredients = new JPanel();
 		GridBagConstraints gbc_panelIngredients = new GridBagConstraints();
@@ -108,4 +113,13 @@ public class SummaryPanel extends JPanel {
 	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);
+	}
 }