|
|
@@ -12,6 +12,7 @@ import lombok.experimental.FieldDefaults;
|
|
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
|
|
+import javax.swing.JComboBox;
|
|
|
import javax.swing.JFormattedTextField;
|
|
|
import javax.swing.JLabel;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
@@ -22,7 +23,10 @@ import java.awt.Insets;
|
|
|
public class RestPanel extends JPanel {
|
|
|
ObservableListener<JFormattedTextField, Rest> durationController;
|
|
|
|
|
|
- JLabel lblLocation;
|
|
|
+ JComboBox<Rest.Where> jcbLocation;
|
|
|
+
|
|
|
+ // TODO
|
|
|
+ Rest model;
|
|
|
|
|
|
public RestPanel() {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
@@ -39,12 +43,12 @@ public class RestPanel extends JPanel {
|
|
|
gbc_lblRest.gridy = 0;
|
|
|
add(lblRest, gbc_lblRest);
|
|
|
|
|
|
- lblLocation = new JLabel();
|
|
|
+ jcbLocation = new JComboBox<>(Rest.Where.values());
|
|
|
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);
|
|
|
+ add(jcbLocation, gbc_lblLocation);
|
|
|
|
|
|
DurationPanel panelDuration = new DurationPanel("");
|
|
|
GridBagConstraints gbc_panelDuration = new GridBagConstraints();
|
|
|
@@ -52,8 +56,14 @@ public class RestPanel extends JPanel {
|
|
|
gbc_panelDuration.gridy = 0;
|
|
|
add(panelDuration, gbc_panelDuration);
|
|
|
|
|
|
+ jcbLocation.addItemListener(e -> {
|
|
|
+ panelDuration.txtTime.setEditable(!e.getItem().equals(Rest.Where.NONE));
|
|
|
+ this.model.setWhere(Rest.Where.class.cast(e.getItem()));
|
|
|
+ });
|
|
|
durationController = ObservableController.from(panelDuration.txtTime,
|
|
|
Rest::getDuration, Rest::setDuration);
|
|
|
+
|
|
|
+ panelDuration.txtTime.setEditable(false);
|
|
|
}
|
|
|
|
|
|
public RestPanel(final Rest rest) {
|
|
|
@@ -62,7 +72,8 @@ public class RestPanel extends JPanel {
|
|
|
}
|
|
|
|
|
|
public void setModel(final Rest rest) {
|
|
|
- lblLocation.setText(rest.getWhere().getHumanReadable());
|
|
|
+ this.model = rest;
|
|
|
+ jcbLocation.setSelectedItem(rest.getWhere());
|
|
|
durationController.setObserved(rest);
|
|
|
}
|
|
|
|