|
@@ -0,0 +1,97 @@
|
|
|
|
|
+package org.leumasjaffe.recipe.view;
|
|
|
|
|
+
|
|
|
|
|
+import javax.swing.JPanel;
|
|
|
|
|
+import javax.swing.event.DocumentListener;
|
|
|
|
|
+
|
|
|
|
|
+import org.leumasjaffe.recipe.model.Preparation;
|
|
|
|
|
+
|
|
|
|
|
+import java.awt.GridBagLayout;
|
|
|
|
|
+
|
|
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
|
|
+import java.awt.Insets;
|
|
|
|
|
+
|
|
|
|
|
+import javax.swing.JLabel;
|
|
|
|
|
+import javax.swing.JTextPane;
|
|
|
|
|
+import java.awt.Component;
|
|
|
|
|
+import javax.swing.Box;
|
|
|
|
|
+import java.awt.Dimension;
|
|
|
|
|
+
|
|
|
|
|
+@SuppressWarnings("serial")
|
|
|
|
|
+public class PreparationPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
|
|
|
+ private JLabel lblIndex;
|
|
|
|
|
+ private JTextPane txtpnInstructions;
|
|
|
|
|
+
|
|
|
|
|
+ public PreparationPanel(Preparation step) {
|
|
|
|
|
+ GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
|
|
|
+ gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
|
|
+ gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
+ gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
+ setLayout(gridBagLayout);
|
|
|
|
|
+
|
|
|
|
|
+ JPanel panelLeft = new JPanel();
|
|
|
|
|
+ panelLeft.setPreferredSize(new Dimension(200, 50));
|
|
|
|
|
+ GridBagConstraints gbc_panelLeft = new GridBagConstraints();
|
|
|
|
|
+ gbc_panelLeft.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
+ gbc_panelLeft.fill = GridBagConstraints.BOTH;
|
|
|
|
|
+ gbc_panelLeft.gridx = 0;
|
|
|
|
|
+ gbc_panelLeft.gridy = 0;
|
|
|
|
|
+ add(panelLeft, gbc_panelLeft);
|
|
|
|
|
+ GridBagLayout gbl_panelLeft = new GridBagLayout();
|
|
|
|
|
+ gbl_panelLeft.columnWidths = new int[]{0, 0, 0, 0};
|
|
|
|
|
+ gbl_panelLeft.rowHeights = new int[]{0, 0, 0};
|
|
|
|
|
+ gbl_panelLeft.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
|
|
|
+ gbl_panelLeft.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
+ panelLeft.setLayout(gbl_panelLeft);
|
|
|
|
|
+
|
|
|
|
|
+ lblIndex = new JLabel("");
|
|
|
|
|
+ GridBagConstraints gbc_lblIndex = new GridBagConstraints();
|
|
|
|
|
+ gbc_lblIndex.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
+ gbc_lblIndex.insets = new Insets(0, 0, 5, 5);
|
|
|
|
|
+ gbc_lblIndex.gridx = 0;
|
|
|
|
|
+ gbc_lblIndex.gridy = 0;
|
|
|
|
|
+ panelLeft.add(lblIndex, gbc_lblIndex);
|
|
|
|
|
+
|
|
|
|
|
+ Component horizontalGlue = Box.createHorizontalGlue();
|
|
|
|
|
+ GridBagConstraints gbc_horizontalGlue = new GridBagConstraints();
|
|
|
|
|
+ gbc_horizontalGlue.insets = new Insets(0, 0, 5, 5);
|
|
|
|
|
+ gbc_horizontalGlue.gridx = 1;
|
|
|
|
|
+ gbc_horizontalGlue.gridy = 0;
|
|
|
|
|
+ panelLeft.add(horizontalGlue, gbc_horizontalGlue);
|
|
|
|
|
+
|
|
|
|
|
+ JLabel lblDuration = new JLabel("Duration");
|
|
|
|
|
+ GridBagConstraints gbc_lblDuration = new GridBagConstraints();
|
|
|
|
|
+ gbc_lblDuration.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
+ gbc_lblDuration.gridx = 2;
|
|
|
|
|
+ gbc_lblDuration.gridy = 0;
|
|
|
|
|
+ panelLeft.add(lblDuration, gbc_lblDuration);
|
|
|
|
|
+
|
|
|
|
|
+ AutoGrowPanel panelIngredients = new AutoGrowPanel(IngredientPanel::new);
|
|
|
|
|
+ GridBagConstraints gbc_panelIngredients = new GridBagConstraints();
|
|
|
|
|
+ gbc_panelIngredients.gridwidth = 3;
|
|
|
|
|
+ gbc_panelIngredients.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
+ gbc_panelIngredients.fill = GridBagConstraints.BOTH;
|
|
|
|
|
+ gbc_panelIngredients.gridx = 0;
|
|
|
|
|
+ gbc_panelIngredients.gridy = 1;
|
|
|
|
|
+ panelLeft.add(panelIngredients, gbc_panelIngredients);
|
|
|
|
|
+
|
|
|
|
|
+ txtpnInstructions = new JTextPane();
|
|
|
|
|
+ txtpnInstructions.setPreferredSize(new Dimension(200, 30));
|
|
|
|
|
+ txtpnInstructions.setText("Instructions");
|
|
|
|
|
+ GridBagConstraints gbc_txtpnInstructions = new GridBagConstraints();
|
|
|
|
|
+ gbc_txtpnInstructions.fill = GridBagConstraints.BOTH;
|
|
|
|
|
+ gbc_txtpnInstructions.gridx = 1;
|
|
|
|
|
+ gbc_txtpnInstructions.gridy = 0;
|
|
|
|
|
+ add(txtpnInstructions, gbc_txtpnInstructions);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void addDocumentListener(DocumentListener dl) {
|
|
|
|
|
+ this.txtpnInstructions.getDocument().addDocumentListener(dl);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void removeDocumentListener(DocumentListener dl) {
|
|
|
|
|
+ this.txtpnInstructions.getDocument().removeDocumentListener(dl);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|