|
|
@@ -7,7 +7,6 @@ import org.leumasjaffe.observer.ObservableListener;
|
|
|
import org.leumasjaffe.recipe.model.Rest;
|
|
|
|
|
|
import lombok.AccessLevel;
|
|
|
-import lombok.Getter;
|
|
|
import lombok.experimental.FieldDefaults;
|
|
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
@@ -18,14 +17,13 @@ import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
-@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
+@FieldDefaults(level=AccessLevel.PRIVATE)
|
|
|
public class RestPanel extends JPanel {
|
|
|
ObservableListener<JFormattedTextField, Rest> durationListener;
|
|
|
|
|
|
- @Getter(AccessLevel.PACKAGE) JLabel lblLocation;
|
|
|
- @Getter(AccessLevel.PACKAGE) DurationPanel lblDuration;
|
|
|
+ JLabel lblLocation;
|
|
|
|
|
|
- public RestPanel(Rest rest) {
|
|
|
+ public RestPanel() {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
@@ -40,22 +38,30 @@ public class RestPanel extends JPanel {
|
|
|
gbc_lblRest.gridy = 0;
|
|
|
add(lblRest, gbc_lblRest);
|
|
|
|
|
|
- lblLocation = new JLabel(rest.getWhere().getHumanReadable());
|
|
|
+ lblLocation = new JLabel();
|
|
|
GridBagConstraints gbc_lblLocation = new GridBagConstraints();
|
|
|
gbc_lblLocation.insets = new Insets(0, 0, 0, 5);
|
|
|
gbc_lblLocation.gridx = 1;
|
|
|
gbc_lblLocation.gridy = 0;
|
|
|
add(lblLocation, gbc_lblLocation);
|
|
|
|
|
|
- lblDuration = new DurationPanel("");
|
|
|
- GridBagConstraints gbc_lblDuration = new GridBagConstraints();
|
|
|
- gbc_lblDuration.gridx = 2;
|
|
|
- gbc_lblDuration.gridy = 0;
|
|
|
- add(lblDuration, gbc_lblDuration);
|
|
|
+ DurationPanel panelDuration = new DurationPanel("");
|
|
|
+ GridBagConstraints gbc_panelDuration = new GridBagConstraints();
|
|
|
+ gbc_panelDuration.gridx = 2;
|
|
|
+ gbc_panelDuration.gridy = 0;
|
|
|
+ add(panelDuration, gbc_panelDuration);
|
|
|
|
|
|
- durationListener = ObservableController.from(lblDuration.txtTime,
|
|
|
+ durationListener = ObservableController.from(panelDuration.txtTime,
|
|
|
Rest::getDuration, Rest::setDuration);
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ public RestPanel(final Rest rest) {
|
|
|
+ this();
|
|
|
+ setModel(rest);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setModel(final Rest rest) {
|
|
|
+ lblLocation.setText(rest.getWhere().getHumanReadable());
|
|
|
durationListener.setObserved(rest);
|
|
|
}
|
|
|
|