|
@@ -11,6 +11,8 @@ import java.util.Locale;
|
|
|
import javax.swing.event.DocumentListener;
|
|
import javax.swing.event.DocumentListener;
|
|
|
import javax.swing.text.NumberFormatter;
|
|
import javax.swing.text.NumberFormatter;
|
|
|
|
|
|
|
|
|
|
+import org.leumasjaffe.recipe.model.Ingredient;
|
|
|
|
|
+
|
|
|
import javax.swing.JFormattedTextField;
|
|
import javax.swing.JFormattedTextField;
|
|
|
import java.awt.Font;
|
|
import java.awt.Font;
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JLabel;
|
|
@@ -19,12 +21,13 @@ import javax.swing.JLabel;
|
|
|
public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
|
private JTextField txtName;
|
|
private JTextField txtName;
|
|
|
private JTextField txtUnit;
|
|
private JTextField txtUnit;
|
|
|
|
|
+ private JTextField txtPreparation;
|
|
|
|
|
|
|
|
- public IngredientPanel() {
|
|
|
|
|
|
|
+ public IngredientPanel(final Ingredient ingredient) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
- gridBagLayout.columnWidths = new int[]{0, 100, 40, 40, 0};
|
|
|
|
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
- gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
|
|
|
|
+ gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
setLayout(gridBagLayout);
|
|
setLayout(gridBagLayout);
|
|
|
|
|
|
|
@@ -36,7 +39,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
gbc_label.gridy = 0;
|
|
gbc_label.gridy = 0;
|
|
|
add(label, gbc_label);
|
|
add(label, gbc_label);
|
|
|
|
|
|
|
|
- txtName = new JTextField();
|
|
|
|
|
|
|
+ txtName = new JTextField(ingredient.getName());
|
|
|
txtName.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
txtName.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
|
gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
|
|
@@ -50,6 +53,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
fmtDone.setMinimum(0.0);
|
|
fmtDone.setMinimum(0.0);
|
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
|
JFormattedTextField txtAmount = new JFormattedTextField(fmtDone);
|
|
JFormattedTextField txtAmount = new JFormattedTextField(fmtDone);
|
|
|
|
|
+ txtAmount.setValue(ingredient.getAmount().getValue());
|
|
|
txtAmount.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
txtAmount.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtAmount = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtAmount = new GridBagConstraints();
|
|
|
gbc_txtAmount.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtAmount.fill = GridBagConstraints.HORIZONTAL;
|
|
@@ -59,15 +63,26 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
add(txtAmount, gbc_txtAmount);
|
|
add(txtAmount, gbc_txtAmount);
|
|
|
txtAmount.setColumns(4);
|
|
txtAmount.setColumns(4);
|
|
|
|
|
|
|
|
- txtUnit = new JTextField();
|
|
|
|
|
|
|
+ txtUnit = new JTextField(ingredient.getAmount().unitName());
|
|
|
txtUnit.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
txtUnit.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtUnit = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtUnit = new GridBagConstraints();
|
|
|
|
|
+ gbc_txtUnit.insets = new Insets(0, 0, 0, 5);
|
|
|
gbc_txtUnit.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
gbc_txtUnit.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
|
gbc_txtUnit.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtUnit.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_txtUnit.gridx = 3;
|
|
gbc_txtUnit.gridx = 3;
|
|
|
gbc_txtUnit.gridy = 0;
|
|
gbc_txtUnit.gridy = 0;
|
|
|
add(txtUnit, gbc_txtUnit);
|
|
add(txtUnit, gbc_txtUnit);
|
|
|
- txtUnit.setColumns(10);
|
|
|
|
|
|
|
+ txtUnit.setColumns(6);
|
|
|
|
|
+
|
|
|
|
|
+ txtPreparation = new JTextField(ingredient.getPreparation());
|
|
|
|
|
+ txtPreparation.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
|
|
+ GridBagConstraints gbc_txtPreparation = new GridBagConstraints();
|
|
|
|
|
+ gbc_txtPreparation.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
|
|
|
+ gbc_txtPreparation.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
+ gbc_txtPreparation.gridx = 4;
|
|
|
|
|
+ gbc_txtPreparation.gridy = 0;
|
|
|
|
|
+ add(txtPreparation, gbc_txtPreparation);
|
|
|
|
|
+ txtPreparation.setColumns(10);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|