|
@@ -32,7 +32,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
@Getter(AccessLevel.PACKAGE) JFormattedTextField txtAmount;
|
|
@Getter(AccessLevel.PACKAGE) JFormattedTextField txtAmount;
|
|
|
@Getter(AccessLevel.PACKAGE) JTextField txtPreparation;
|
|
@Getter(AccessLevel.PACKAGE) JTextField txtPreparation;
|
|
|
|
|
|
|
|
- public IngredientPanel() {
|
|
|
|
|
|
|
+ public IngredientPanel(boolean editable) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
@@ -49,6 +49,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
add(label, gbc_label);
|
|
add(label, gbc_label);
|
|
|
|
|
|
|
|
txtName = new JTextField();
|
|
txtName = new JTextField();
|
|
|
|
|
+ txtName.setEditable(editable);
|
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtName = new GridBagConstraints();
|
|
|
gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_txtName.insets = new Insets(0, 0, 0, 5);
|
|
gbc_txtName.insets = new Insets(0, 0, 0, 5);
|
|
@@ -58,6 +59,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
txtName.setColumns(15);
|
|
txtName.setColumns(15);
|
|
|
|
|
|
|
|
txtAmount = new JFormattedTextField(new AmountFormatter());
|
|
txtAmount = new JFormattedTextField(new AmountFormatter());
|
|
|
|
|
+ txtAmount.setEditable(editable);
|
|
|
GridBagConstraints gbc_txtAmount = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtAmount = new GridBagConstraints();
|
|
|
gbc_txtAmount.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtAmount.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_txtAmount.insets = new Insets(0, 0, 0, 5);
|
|
gbc_txtAmount.insets = new Insets(0, 0, 0, 5);
|
|
@@ -67,6 +69,7 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
txtAmount.setColumns(6);
|
|
txtAmount.setColumns(6);
|
|
|
|
|
|
|
|
txtPreparation = new JTextField();
|
|
txtPreparation = new JTextField();
|
|
|
|
|
+ txtPreparation.setEditable(editable);
|
|
|
GridBagConstraints gbc_txtPreparation = new GridBagConstraints();
|
|
GridBagConstraints gbc_txtPreparation = new GridBagConstraints();
|
|
|
gbc_txtPreparation.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
gbc_txtPreparation.anchor = GridBagConstraints.ABOVE_BASELINE;
|
|
|
gbc_txtPreparation.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_txtPreparation.fill = GridBagConstraints.HORIZONTAL;
|
|
@@ -75,8 +78,6 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
add(txtPreparation, gbc_txtPreparation);
|
|
add(txtPreparation, gbc_txtPreparation);
|
|
|
txtPreparation.setColumns(10);
|
|
txtPreparation.setColumns(10);
|
|
|
|
|
|
|
|
- // I technically don't need to listen here as of this change,
|
|
|
|
|
- // but if I ever restore support for it, it will be convenient.
|
|
|
|
|
nameController = ObservableController.from(txtName,
|
|
nameController = ObservableController.from(txtName,
|
|
|
Ingredient::getName, Ingredient::setName);
|
|
Ingredient::getName, Ingredient::setName);
|
|
|
amountController = ObservableController.from(txtAmount,
|
|
amountController = ObservableController.from(txtAmount,
|
|
@@ -89,8 +90,8 @@ public class IngredientPanel extends JPanel implements AutoGrowPanel.ChildCompon
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IngredientPanel(final Ingredient ingredient) {
|
|
|
|
|
- this();
|
|
|
|
|
|
|
+ public IngredientPanel(final Ingredient ingredient, boolean editable) {
|
|
|
|
|
+ this(editable);
|
|
|
setModel(ingredient);
|
|
setModel(ingredient);
|
|
|
}
|
|
}
|
|
|
|
|
|