Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
2907a002
by Tony Chemit at 2020-06-25T12:34:43+02:00
-
d57d7761
by Tony Chemit at 2020-06-25T12:35:52+02:00
-
8d6d355e
by Tony Chemit at 2020-06-25T12:36:50+02:00
10 changed files:
- client-datasource-editor-ps/src/main/dcp-presets/ps/logbook/01-deployment-preset.yml
- client-datasource-editor-ps/src/main/dcp-presets/ps/logbook/04-abandonned-preset.yml
- client-datasource-editor-ps/src/main/dcp-presets/ps/observation/01-deployment-preset.yml
- client-datasource-editor-ps/src/main/i18n/getters/java.getter
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUI.jaxx
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUI.jcss
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUIHandler.java
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectUIInitializer.java
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/observation/FloatingObjectUIHandler.java
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/observation/actions/FloatingObjectUIAddFloatingObjectPreset.java
Changes:
| 1 | 1 |
buoy1:
|
| 2 | 2 |
transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416
|
| 3 |
- transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1
|
|
| 3 |
+ transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3
|
|
| 4 | 4 |
label1: Draft deployment (DFAD)
|
| 5 | 5 |
label2: Mise à l'eau de radeau dérivant (DFAD)
|
| 6 | 6 |
label3: Draft deployment (DFAD) #TODO
|
| 1 | 1 |
buoy1:
|
| 2 | 2 |
transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416
|
| 3 |
- transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1
|
|
| 3 |
+ transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3
|
|
| 4 | 4 |
label1: Buoy abandonned (DFAD)
|
| 5 | 5 |
label2: Perte/fin de transmission de balise (DFAD)
|
| 6 | 6 |
label3: Buoy abandonned (DFAD) #TODO
|
| 1 | 1 |
buoy1:
|
| 2 | 2 |
transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416
|
| 3 |
- transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1
|
|
| 3 |
+ transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3
|
|
| 4 | 4 |
label1: Draft deployment (DFAD)
|
| 5 | 5 |
label2: Mise à l'eau de radeau dérivant (DFAD)
|
| 6 | 6 |
label3: Draft deployment (DFAD) #TODO
|
| ... | ... | @@ -12,8 +12,8 @@ observe.choice.cancel |
| 12 | 12 |
observe.choice.confirm.delete
|
| 13 | 13 |
observe.choice.continue
|
| 14 | 14 |
observe.choice.dcp.default
|
| 15 |
-observe.choice.quit
|
|
| 16 | 15 |
observe.choice.save
|
| 16 |
+observe.common.boolean.true
|
|
| 17 | 17 |
observe.content.map.legend.tripBetweenTwoDays
|
| 18 | 18 |
observe.content.map.legend.tripDay
|
| 19 | 19 |
observe.data.ll.common.GearUseFeatures.action.addMeasurement
|
| ... | ... | @@ -146,7 +146,7 @@ |
| 146 | 146 |
</row>
|
| 147 | 147 |
<row>
|
| 148 | 148 |
<cell>
|
| 149 |
- <JPanel id="buoys" layout="{new GridLayout(0,1)}">
|
|
| 149 |
+ <JPanel id="buoys" layout="{new GridLayout(1,0)}">
|
|
| 150 | 150 |
<FloatingObjectBuoyPresetUI id="buoy1"/>
|
| 151 | 151 |
<FloatingObjectBuoyPresetUI id="buoy2"/>
|
| 152 | 152 |
<JLabel id='noBaliseEditor' styleClass="skipI18n"/>
|
| ... | ... | @@ -32,10 +32,6 @@ JLabel { |
| 32 | 32 |
border:{new TitledBorder(t("observe.data.ps.observation.FloatingObject.materialsTab"))};
|
| 33 | 33 |
}
|
| 34 | 34 |
|
| 35 |
-/*#buoys {
|
|
| 36 |
- border:{new TitledBorder(t("observe.data.ps.observation.FloatingObject.buoysTab"))};
|
|
| 37 |
-}*/
|
|
| 38 |
- |
|
| 39 | 35 |
#keepObjectOperation {
|
| 40 | 36 |
selected:true;
|
| 41 | 37 |
enabled:false;
|
| ... | ... | @@ -23,17 +23,21 @@ package fr.ird.observe.client.datasource.dcp.presets.observation; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableSet;
|
| 26 |
+import fr.ird.observe.client.util.BeanCheckBox;
|
|
| 27 |
+import fr.ird.observe.dto.data.ps.dcp.FloatingObjectBuoyPreset;
|
|
| 26 | 28 |
import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPreset;
|
| 27 |
-import io.ultreia.java4all.i18n.I18n;
|
|
| 28 | 29 |
import org.nuiton.jaxx.validator.swing.SwingValidatorUtil;
|
| 29 | 30 |
|
| 30 | 31 |
import javax.swing.DefaultListModel;
|
| 31 | 32 |
import javax.swing.ListSelectionModel;
|
| 33 |
+import java.beans.Introspector;
|
|
| 32 | 34 |
import java.util.LinkedList;
|
| 33 | 35 |
import java.util.List;
|
| 34 | 36 |
import java.util.Map;
|
| 35 | 37 |
import java.util.Optional;
|
| 36 | 38 |
|
| 39 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 40 |
+ |
|
| 37 | 41 |
/**
|
| 38 | 42 |
* Created on 06/07/19.
|
| 39 | 43 |
*
|
| ... | ... | @@ -45,28 +49,21 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje |
| 45 | 49 |
@Override
|
| 46 | 50 |
public void afterInit(FloatingObjectPresetUI ui) {
|
| 47 | 51 |
new FloatingObjectUIInitializer<>(ui).initUI();
|
| 48 |
- ui.getBuoy1().getValidator().setParentValidator(ui.getValidator());
|
|
| 49 |
- ui.getBuoy2().getValidator().setParentValidator(ui.getValidator());
|
|
| 52 |
+ FloatingObjectBuoyPresetUI buoy1 = ui.getBuoy1();
|
|
| 53 |
+ buoy1.getValidator().setParentValidator(ui.getValidator());
|
|
| 54 |
+ FloatingObjectBuoyPresetUI buoy2 = ui.getBuoy2();
|
|
| 55 |
+ buoy2.getValidator().setParentValidator(ui.getValidator());
|
|
| 50 | 56 |
|
| 51 | 57 |
FloatingObjectPreset floatingObjectPreset = ui.getContextValue(FloatingObjectPreset.class);
|
| 52 | 58 |
floatingObjectPreset.copy(ui.getModel().getBean());
|
| 59 |
+ disabledIfNull(ui, "keepSupplyName");
|
|
| 53 | 60 |
|
| 54 | 61 |
ui.getBuoys().removeAll();
|
| 55 | 62 |
SwingValidatorUtil.setValidatorBean(ui, ui.getModel().getBean());
|
| 56 | 63 |
ui.getBuoys().add(ui.getNoBaliseEditor());
|
| 57 |
- Optional.ofNullable(floatingObjectPreset.getBuoy1()).ifPresent(t -> {
|
|
| 58 |
- t.copy(ui.getBuoy1().getModel().getBean());
|
|
| 59 |
- ui.getBuoys().remove(ui.getNoBaliseEditor());
|
|
| 60 |
- ui.getBuoys().add(ui.getBuoy1());
|
|
| 61 |
- SwingValidatorUtil.setValidatorBean(ui.getBuoy1(), ui.getBuoy1().getModel().getBean());
|
|
| 62 |
- |
|
| 63 |
- });
|
|
| 64 |
- Optional.ofNullable(floatingObjectPreset.getBuoy2()).ifPresent(t -> {
|
|
| 65 |
- t.copy(ui.getBuoy2().getModel().getBean());
|
|
| 66 |
- ui.getBuoys().remove(ui.getNoBaliseEditor());
|
|
| 67 |
- ui.getBuoys().add(ui.getBuoy2());
|
|
| 68 |
- SwingValidatorUtil.setValidatorBean(ui.getBuoy2(), ui.getBuoy2().getModel().getBean());
|
|
| 69 |
- });
|
|
| 64 |
+ |
|
| 65 |
+ Optional.ofNullable(floatingObjectPreset.getBuoy1()).ifPresent(t -> prepareBuoy(t, buoy1));
|
|
| 66 |
+ Optional.ofNullable(floatingObjectPreset.getBuoy2()).ifPresent(t -> prepareBuoy(t, buoy2));
|
|
| 70 | 67 |
|
| 71 | 68 |
DefaultListModel<String> materialsListModel = new DefaultListModel<>();
|
| 72 | 69 |
List<String> materialsList = buildMaterialsList(ui);
|
| ... | ... | @@ -75,6 +72,7 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje |
| 75 | 72 |
ui.getMaterialsList().setRequestFocusEnabled(false);
|
| 76 | 73 |
ui.getMaterialsList().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
| 77 | 74 |
|
| 75 |
+ |
|
| 78 | 76 |
}
|
| 79 | 77 |
|
| 80 | 78 |
private List<String> buildMaterialsList(FloatingObjectPresetUI ui) {
|
| ... | ... | @@ -87,18 +85,63 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje |
| 87 | 85 |
String values = "";
|
| 88 | 86 |
String whenArrivingValue = whenArrivingMaterials.get(id);
|
| 89 | 87 |
if (whenArrivingValue != null) {
|
| 90 |
- values += I18n.t("observe.Id.whenArriving") + " - " + whenArrivingValue;
|
|
| 88 |
+ if ("true".equals(whenArrivingValue)) {
|
|
| 89 |
+ whenArrivingValue = t("observe.common.boolean.true");
|
|
| 90 |
+ }
|
|
| 91 |
+ values += t("observe.Id.whenArriving") + " - " + whenArrivingValue;
|
|
| 91 | 92 |
}
|
| 92 | 93 |
String whenLeavingValue = whenLeavingMaterials.get(id);
|
| 93 | 94 |
if (whenLeavingValue != null) {
|
| 94 | 95 |
if (!values.isEmpty()) {
|
| 95 | 96 |
values += " - ";
|
| 96 | 97 |
}
|
| 97 |
- values += I18n.t("observe.Id.whenLeaving") + " - " + whenLeavingValue;
|
|
| 98 |
+ if ("true".equals(whenLeavingValue)) {
|
|
| 99 |
+ whenLeavingValue = t("observe.common.boolean.true");
|
|
| 100 |
+ }
|
|
| 101 |
+ values += t("observe.Id.whenLeaving") + " - " + whenLeavingValue;
|
|
| 98 | 102 |
}
|
| 99 | 103 |
materials.add(label + " ( " + values + " )");
|
| 100 | 104 |
}
|
| 101 | 105 |
return materials;
|
| 102 | 106 |
}
|
| 103 | 107 |
|
| 108 |
+ private void prepareBuoy(FloatingObjectBuoyPreset preset, FloatingObjectBuoyPresetUI buoyUI) {
|
|
| 109 |
+ preset.copy(buoyUI.getModel().getBean());
|
|
| 110 |
+ ui.getBuoys().remove(ui.getNoBaliseEditor());
|
|
| 111 |
+ ui.getBuoys().add(buoyUI);
|
|
| 112 |
+ SwingValidatorUtil.setValidatorBean(buoyUI, buoyUI.getModel().getBean());
|
|
| 113 |
+ disableIfNull(buoyUI);
|
|
| 114 |
+ }
|
|
| 115 |
+ |
|
| 116 |
+ private void disableIfNull(FloatingObjectBuoyPresetUI ui) {
|
|
| 117 |
+ disabledIfNull(ui, "keepVesselId");
|
|
| 118 |
+ disabledIfNull(ui, "keepCountryId");
|
|
| 119 |
+ disabledIfNull(ui, "keepCode");
|
|
| 120 |
+ disabledIfNull(ui, "keepComment");
|
|
| 121 |
+ disabledIfNull(ui, "keepTransmittingBuoyOwnershipId");
|
|
| 122 |
+ disabledIfNull(ui, "keepTransmittingBuoyTypeId");
|
|
| 123 |
+ disabledIfNull(ui, "keepVesselId");
|
|
| 124 |
+ }
|
|
| 125 |
+ |
|
| 126 |
+ private void disabledIfNull(FloatingObjectBuoyPresetUI ui, String uiProperty) {
|
|
| 127 |
+ String beanProperty = Introspector.decapitalize(uiProperty.substring(4));
|
|
| 128 |
+ Object value = ui.getBean().get(beanProperty);
|
|
| 129 |
+ if (value == null || value.toString().trim().isEmpty()) {
|
|
| 130 |
+ ui.getModel().set(uiProperty, false);
|
|
| 131 |
+ BeanCheckBox editor = (BeanCheckBox) ui.getObjectById(uiProperty);
|
|
| 132 |
+ editor.setSelected(false);
|
|
| 133 |
+ editor.setEnabled(false);
|
|
| 134 |
+ }
|
|
| 135 |
+ }
|
|
| 136 |
+ |
|
| 137 |
+ private void disabledIfNull(FloatingObjectPresetUI ui, String uiProperty) {
|
|
| 138 |
+ String beanProperty = Introspector.decapitalize(uiProperty.substring(4));
|
|
| 139 |
+ Object value = ui.getBean().get(beanProperty);
|
|
| 140 |
+ if (value == null || value.toString().trim().isEmpty()) {
|
|
| 141 |
+ ui.getModel().set(uiProperty, false);
|
|
| 142 |
+ BeanCheckBox editor = (BeanCheckBox) ui.getObjectById(uiProperty);
|
|
| 143 |
+ editor.setSelected(false);
|
|
| 144 |
+ editor.setEnabled(false);
|
|
| 145 |
+ }
|
|
| 146 |
+ }
|
|
| 104 | 147 |
}
|
| ... | ... | @@ -78,11 +78,7 @@ public class FloatingObjectUIInitializer<UI extends JAXXObject & JAXXValidator> |
| 78 | 78 |
void initUI() {
|
| 79 | 79 |
|
| 80 | 80 |
Set<String> doNotBlockComponentIds = new HashSet<>();
|
| 81 |
-// FIXME Check if this is still ok while commenting this code
|
|
| 82 |
-// ((JComponent) ui).getActionMap().setParent(actionMap);
|
|
| 83 |
-// ((JComponent) ui).setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
|
|
| 84 |
- |
|
| 85 |
- log.info("Init widgets - first pass for: " + ui);
|
|
| 81 |
+ log.info(String.format("Init widgets - first pass for: %s", ui));
|
|
| 86 | 82 |
Set<Object> done = new LinkedHashSet<>();
|
| 87 | 83 |
for (String name : ui.get$objectMap().keySet()) {
|
| 88 | 84 |
Object o = ui.getObjectById(name);
|
| ... | ... | @@ -134,7 +130,7 @@ public class FloatingObjectUIInitializer<UI extends JAXXObject & JAXXValidator> |
| 134 | 130 |
}
|
| 135 | 131 |
}
|
| 136 | 132 |
|
| 137 |
- log.info("Init widgets - second pass for: " + ui);
|
|
| 133 |
+ log.info(String.format("Init widgets - second pass for: %s", ui));
|
|
| 138 | 134 |
|
| 139 | 135 |
}
|
| 140 | 136 |
|
| ... | ... | @@ -214,7 +214,7 @@ public class FloatingObjectUIHandler extends ContentEditUIHandler<FloatingObject |
| 214 | 214 |
}
|
| 215 | 215 |
}
|
| 216 | 216 |
|
| 217 |
- model.setModified(false);
|
|
| 217 |
+ model.setModified(model.isCreatingMode());
|
|
| 218 | 218 |
}
|
| 219 | 219 |
|
| 220 | 220 |
private void recomputeComputedValues() {
|
| ... | ... | @@ -67,7 +67,7 @@ public class FloatingObjectUIAddFloatingObjectPreset extends ContentUIActionSupp |
| 67 | 67 |
FloatingObjectPresetUI configPanel = FloatingObjectPresetUIModel.init(applicationContext, floatingObjectPreset);
|
| 68 | 68 |
|
| 69 | 69 |
String replaceText = t("observe.choice.save");
|
| 70 |
- Object[] options = {replaceText, t("observe.choice.quit")};
|
|
| 70 |
+ Object[] options = {replaceText, t("observe.choice.cancel")};
|
|
| 71 | 71 |
JOptionPane pane = new JOptionPane(configPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);
|
| 72 | 72 |
JButton saveButton = Objects.requireNonNull(findButton(pane, replaceText));
|
| 73 | 73 |
configPanel.getValidator().addPropertyChangeListener(AbstractValidator.VALID_PROPERTY, e -> onValidChanged(saveButton, (Boolean) e.getNewValue()));
|