|
@@ -15,14 +15,22 @@ import org.leumasjaffe.observer.ObservableController;
|
|
|
import org.leumasjaffe.observer.ObserverDispatch;
|
|
import org.leumasjaffe.observer.ObserverDispatch;
|
|
|
import org.leumasjaffe.recipe.model.Ingredient;
|
|
import org.leumasjaffe.recipe.model.Ingredient;
|
|
|
|
|
|
|
|
|
|
+import lombok.AccessLevel;
|
|
|
|
|
+import lombok.Getter;
|
|
|
|
|
+import lombok.experimental.FieldDefaults;
|
|
|
|
|
+
|
|
|
import javax.swing.JFormattedTextField;
|
|
import javax.swing.JFormattedTextField;
|
|
|
import java.awt.Font;
|
|
import java.awt.Font;
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JLabel;
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
@SuppressWarnings("serial")
|
|
|
|
|
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentListenable {
|
|
|
ObservableController<JTextField, Ingredient> controller;
|
|
ObservableController<JTextField, Ingredient> controller;
|
|
|
- private JTextField txtName;
|
|
|
|
|
|
|
+ @Getter(AccessLevel.PACKAGE) JTextField txtName;
|
|
|
|
|
+ @Getter(AccessLevel.PACKAGE) JFormattedTextField txtAmount;
|
|
|
|
|
+ @Getter(AccessLevel.PACKAGE) JTextField txtUnit;
|
|
|
|
|
+ @Getter(AccessLevel.PACKAGE) JTextField txtPreparation;
|
|
|
|
|
|
|
|
public IngredientPanel(final Ingredient ingredient) {
|
|
public IngredientPanel(final Ingredient ingredient) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
@@ -53,7 +61,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
NumberFormatter fmtDone = new NumberFormatter(NumberFormat.getNumberInstance(Locale.getDefault()));
|
|
NumberFormatter fmtDone = new NumberFormatter(NumberFormat.getNumberInstance(Locale.getDefault()));
|
|
|
fmtDone.setMinimum(0.0);
|
|
fmtDone.setMinimum(0.0);
|
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
fmtDone.setCommitsOnValidEdit(true);
|
|
|
- JFormattedTextField txtAmount = new JFormattedTextField(fmtDone);
|
|
|
|
|
|
|
+ txtAmount = new JFormattedTextField(fmtDone);
|
|
|
txtAmount.setValue(ingredient.getAmount().getValue());
|
|
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();
|
|
@@ -64,7 +72,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
add(txtAmount, gbc_txtAmount);
|
|
add(txtAmount, gbc_txtAmount);
|
|
|
txtAmount.setColumns(4);
|
|
txtAmount.setColumns(4);
|
|
|
|
|
|
|
|
- JTextField txtUnit = new JTextField(ingredient.getAmount().unitName());
|
|
|
|
|
|
|
+ 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.insets = new Insets(0, 0, 0, 5);
|
|
@@ -75,7 +83,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.DocumentLis
|
|
|
add(txtUnit, gbc_txtUnit);
|
|
add(txtUnit, gbc_txtUnit);
|
|
|
txtUnit.setColumns(6);
|
|
txtUnit.setColumns(6);
|
|
|
|
|
|
|
|
- JTextField txtPreparation = new JTextField(ingredient.getPreparation());
|
|
|
|
|
|
|
+ txtPreparation = new JTextField(ingredient.getPreparation());
|
|
|
txtPreparation.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
txtPreparation.setFont(new Font("Source Code Pro", Font.PLAIN, 10));
|
|
|
GridBagConstraints gbc_txtPreparation = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtPreparation = new GridBagConstraints();
|
|
|
gbc_txtPreparation.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
gbc_txtPreparation.anchor = GridBagConstraints.ABOVE_BASELINE;
|