Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 2907a002 by Tony Chemit at 2020-06-25T12:34:43+02:00 Imperfections sur création de nouveau FOB en utilisant les préconfigurations - See #1501 Correction des préconfiguration - - - - - d57d7761 by Tony Chemit at 2020-06-25T12:35:52+02:00 Imperfections sur création de nouveau FOB en utilisant les préconfigurations - See #1501 Pouvoir enregister un nouveau FOB à partir d'une préconfiguration (le bouton Sauvegarder est actif dès que possible) - - - - - 8d6d355e by Tony Chemit at 2020-06-25T12:36:50+02:00 Imperfections sur création de nouveau FOB en utilisant les préconfigurations - Closes #1501 Amélioration des ui (ne pas pouvoir sélectionner une propriété si elle est nulle ou vide) Renommage de l'action fermer en annuler - - - - - 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: ===================================== client-datasource-editor-ps/src/main/dcp-presets/ps/logbook/01-deployment-preset.yml ===================================== @@ -1,6 +1,6 @@ buoy1: transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416 - transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1 + transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3 label1: Draft deployment (DFAD) label2: Mise à l'eau de radeau dérivant (DFAD) label3: Draft deployment (DFAD) #TODO ===================================== client-datasource-editor-ps/src/main/dcp-presets/ps/logbook/04-abandonned-preset.yml ===================================== @@ -1,6 +1,6 @@ buoy1: transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416 - transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1 + transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3 label1: Buoy abandonned (DFAD) label2: Perte/fin de transmission de balise (DFAD) label3: Buoy abandonned (DFAD) #TODO ===================================== client-datasource-editor-ps/src/main/dcp-presets/ps/observation/01-deployment-preset.yml ===================================== @@ -1,6 +1,6 @@ buoy1: transmittingBuoyOperationId: fr.ird.referential.ps.common.TransmittingBuoyOperation#1239832686238#0.4755624782839416 - transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#1 + transmittingBuoyOwnershipId: fr.ird.referential.ps.common.TransmittingBuoyOwnership#0#3 label1: Draft deployment (DFAD) label2: Mise à l'eau de radeau dérivant (DFAD) label3: Draft deployment (DFAD) #TODO ===================================== client-datasource-editor-ps/src/main/i18n/getters/java.getter ===================================== @@ -12,8 +12,8 @@ observe.choice.cancel observe.choice.confirm.delete observe.choice.continue observe.choice.dcp.default -observe.choice.quit observe.choice.save +observe.common.boolean.true observe.content.map.legend.tripBetweenTwoDays observe.content.map.legend.tripDay observe.data.ll.common.GearUseFeatures.action.addMeasurement ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUI.jaxx ===================================== @@ -146,7 +146,7 @@ </row> <row> <cell> - <JPanel id="buoys" layout="{new GridLayout(0,1)}"> + <JPanel id="buoys" layout="{new GridLayout(1,0)}"> <FloatingObjectBuoyPresetUI id="buoy1"/> <FloatingObjectBuoyPresetUI id="buoy2"/> <JLabel id='noBaliseEditor' styleClass="skipI18n"/> ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUI.jcss ===================================== @@ -32,10 +32,6 @@ JLabel { border:{new TitledBorder(t("observe.data.ps.observation.FloatingObject.materialsTab"))}; } -/*#buoys { - border:{new TitledBorder(t("observe.data.ps.observation.FloatingObject.buoysTab"))}; -}*/ - #keepObjectOperation { selected:true; enabled:false; ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectPresetUIHandler.java ===================================== @@ -23,17 +23,21 @@ package fr.ird.observe.client.datasource.dcp.presets.observation; */ import com.google.common.collect.ImmutableSet; +import fr.ird.observe.client.util.BeanCheckBox; +import fr.ird.observe.dto.data.ps.dcp.FloatingObjectBuoyPreset; import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPreset; -import io.ultreia.java4all.i18n.I18n; import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; import javax.swing.DefaultListModel; import javax.swing.ListSelectionModel; +import java.beans.Introspector; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Optional; +import static io.ultreia.java4all.i18n.I18n.t; + /** * Created on 06/07/19. * @@ -45,28 +49,21 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje @Override public void afterInit(FloatingObjectPresetUI ui) { new FloatingObjectUIInitializer<>(ui).initUI(); - ui.getBuoy1().getValidator().setParentValidator(ui.getValidator()); - ui.getBuoy2().getValidator().setParentValidator(ui.getValidator()); + FloatingObjectBuoyPresetUI buoy1 = ui.getBuoy1(); + buoy1.getValidator().setParentValidator(ui.getValidator()); + FloatingObjectBuoyPresetUI buoy2 = ui.getBuoy2(); + buoy2.getValidator().setParentValidator(ui.getValidator()); FloatingObjectPreset floatingObjectPreset = ui.getContextValue(FloatingObjectPreset.class); floatingObjectPreset.copy(ui.getModel().getBean()); + disabledIfNull(ui, "keepSupplyName"); ui.getBuoys().removeAll(); SwingValidatorUtil.setValidatorBean(ui, ui.getModel().getBean()); ui.getBuoys().add(ui.getNoBaliseEditor()); - Optional.ofNullable(floatingObjectPreset.getBuoy1()).ifPresent(t -> { - t.copy(ui.getBuoy1().getModel().getBean()); - ui.getBuoys().remove(ui.getNoBaliseEditor()); - ui.getBuoys().add(ui.getBuoy1()); - SwingValidatorUtil.setValidatorBean(ui.getBuoy1(), ui.getBuoy1().getModel().getBean()); - - }); - Optional.ofNullable(floatingObjectPreset.getBuoy2()).ifPresent(t -> { - t.copy(ui.getBuoy2().getModel().getBean()); - ui.getBuoys().remove(ui.getNoBaliseEditor()); - ui.getBuoys().add(ui.getBuoy2()); - SwingValidatorUtil.setValidatorBean(ui.getBuoy2(), ui.getBuoy2().getModel().getBean()); - }); + + Optional.ofNullable(floatingObjectPreset.getBuoy1()).ifPresent(t -> prepareBuoy(t, buoy1)); + Optional.ofNullable(floatingObjectPreset.getBuoy2()).ifPresent(t -> prepareBuoy(t, buoy2)); DefaultListModel<String> materialsListModel = new DefaultListModel<>(); List<String> materialsList = buildMaterialsList(ui); @@ -75,6 +72,7 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje ui.getMaterialsList().setRequestFocusEnabled(false); ui.getMaterialsList().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } private List<String> buildMaterialsList(FloatingObjectPresetUI ui) { @@ -87,18 +85,63 @@ public class FloatingObjectPresetUIHandler extends UIHandlerSupport<FloatingObje String values = ""; String whenArrivingValue = whenArrivingMaterials.get(id); if (whenArrivingValue != null) { - values += I18n.t("observe.Id.whenArriving") + " - " + whenArrivingValue; + if ("true".equals(whenArrivingValue)) { + whenArrivingValue = t("observe.common.boolean.true"); + } + values += t("observe.Id.whenArriving") + " - " + whenArrivingValue; } String whenLeavingValue = whenLeavingMaterials.get(id); if (whenLeavingValue != null) { if (!values.isEmpty()) { values += " - "; } - values += I18n.t("observe.Id.whenLeaving") + " - " + whenLeavingValue; + if ("true".equals(whenLeavingValue)) { + whenLeavingValue = t("observe.common.boolean.true"); + } + values += t("observe.Id.whenLeaving") + " - " + whenLeavingValue; } materials.add(label + " ( " + values + " )"); } return materials; } + private void prepareBuoy(FloatingObjectBuoyPreset preset, FloatingObjectBuoyPresetUI buoyUI) { + preset.copy(buoyUI.getModel().getBean()); + ui.getBuoys().remove(ui.getNoBaliseEditor()); + ui.getBuoys().add(buoyUI); + SwingValidatorUtil.setValidatorBean(buoyUI, buoyUI.getModel().getBean()); + disableIfNull(buoyUI); + } + + private void disableIfNull(FloatingObjectBuoyPresetUI ui) { + disabledIfNull(ui, "keepVesselId"); + disabledIfNull(ui, "keepCountryId"); + disabledIfNull(ui, "keepCode"); + disabledIfNull(ui, "keepComment"); + disabledIfNull(ui, "keepTransmittingBuoyOwnershipId"); + disabledIfNull(ui, "keepTransmittingBuoyTypeId"); + disabledIfNull(ui, "keepVesselId"); + } + + private void disabledIfNull(FloatingObjectBuoyPresetUI ui, String uiProperty) { + String beanProperty = Introspector.decapitalize(uiProperty.substring(4)); + Object value = ui.getBean().get(beanProperty); + if (value == null || value.toString().trim().isEmpty()) { + ui.getModel().set(uiProperty, false); + BeanCheckBox editor = (BeanCheckBox) ui.getObjectById(uiProperty); + editor.setSelected(false); + editor.setEnabled(false); + } + } + + private void disabledIfNull(FloatingObjectPresetUI ui, String uiProperty) { + String beanProperty = Introspector.decapitalize(uiProperty.substring(4)); + Object value = ui.getBean().get(beanProperty); + if (value == null || value.toString().trim().isEmpty()) { + ui.getModel().set(uiProperty, false); + BeanCheckBox editor = (BeanCheckBox) ui.getObjectById(uiProperty); + editor.setSelected(false); + editor.setEnabled(false); + } + } } ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/dcp/presets/observation/FloatingObjectUIInitializer.java ===================================== @@ -78,11 +78,7 @@ public class FloatingObjectUIInitializer<UI extends JAXXObject & JAXXValidator> void initUI() { Set<String> doNotBlockComponentIds = new HashSet<>(); -// FIXME Check if this is still ok while commenting this code -// ((JComponent) ui).getActionMap().setParent(actionMap); -// ((JComponent) ui).setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); - - log.info("Init widgets - first pass for: " + ui); + log.info(String.format("Init widgets - first pass for: %s", ui)); Set<Object> done = new LinkedHashSet<>(); for (String name : ui.get$objectMap().keySet()) { Object o = ui.getObjectById(name); @@ -134,7 +130,7 @@ public class FloatingObjectUIInitializer<UI extends JAXXObject & JAXXValidator> } } - log.info("Init widgets - second pass for: " + ui); + log.info(String.format("Init widgets - second pass for: %s", ui)); } ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/observation/FloatingObjectUIHandler.java ===================================== @@ -214,7 +214,7 @@ public class FloatingObjectUIHandler extends ContentEditUIHandler<FloatingObject } } - model.setModified(false); + model.setModified(model.isCreatingMode()); } private void recomputeComputedValues() { ===================================== client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/observation/actions/FloatingObjectUIAddFloatingObjectPreset.java ===================================== @@ -67,7 +67,7 @@ public class FloatingObjectUIAddFloatingObjectPreset extends ContentUIActionSupp FloatingObjectPresetUI configPanel = FloatingObjectPresetUIModel.init(applicationContext, floatingObjectPreset); String replaceText = t("observe.choice.save"); - Object[] options = {replaceText, t("observe.choice.quit")}; + Object[] options = {replaceText, t("observe.choice.cancel")}; JOptionPane pane = new JOptionPane(configPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]); JButton saveButton = Objects.requireNonNull(findButton(pane, replaceText)); configPanel.getValidator().addPropertyChangeListener(AbstractValidator.VALID_PROPERTY, e -> onValidChanged(saveButton, (Boolean) e.getNewValue())); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/a76c291106d973d040c2406dd... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/a76c291106d973d040c2406dd... You're receiving this email because of your account on gitlab.com.