Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

13 changed files:

Changes:

  • client/configuration/src/main/java/fr/ird/observe/client/datasource/dcp/FloatingObjectPresetsManager.java
    ... ... @@ -50,7 +50,6 @@ public class FloatingObjectPresetsManager {
    50 50
         private final ClientConfig config;
    
    51 51
         private Map<Path, FloatingObjectPreset> psObservation;
    
    52 52
         private Map<Path, FloatingObjectPreset> psLogbook;
    
    53
    -    private FloatingObjectPreset referenceToUse;
    
    54 53
     
    
    55 54
         public FloatingObjectPresetsManager(ClientConfig config) {
    
    56 55
             this.config = Objects.requireNonNull(config);
    
    ... ... @@ -87,7 +86,6 @@ public class FloatingObjectPresetsManager {
    87 86
                 default:
    
    88 87
                     throw new IllegalStateException("Can't deal with model: " + model);
    
    89 88
             }
    
    90
    -
    
    91 89
             try {
    
    92 90
                 Path nextFilename = FloatingObjectPresetStorage.getNextFilename(directory);
    
    93 91
                 Path file = directory.resolve(nextFilename);
    
    ... ... @@ -100,14 +98,6 @@ public class FloatingObjectPresetsManager {
    100 98
             }
    
    101 99
         }
    
    102 100
     
    
    103
    -    public FloatingObjectPreset getReferenceToUse() {
    
    104
    -        return referenceToUse;
    
    105
    -    }
    
    106
    -
    
    107
    -    public void setReferenceToUse(FloatingObjectPreset referenceToUse) {
    
    108
    -        this.referenceToUse = referenceToUse;
    
    109
    -    }
    
    110
    -
    
    111 101
         public int size() {
    
    112 102
             return getPsLogbook().size() + getPsObservation().size();
    
    113 103
         }
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/ActivityUI.jaxx
    ... ... @@ -24,6 +24,7 @@
    24 24
       <import>
    
    25 25
         fr.ird.observe.dto.data.ll.logbook.ActivityDto
    
    26 26
         fr.ird.observe.dto.data.ll.logbook.SetDto
    
    27
    +    fr.ird.observe.dto.data.ll.observation.ActivityReference
    
    27 28
         fr.ird.observe.dto.data.ll.pairing.ActivityPairingResultItem
    
    28 29
         fr.ird.observe.dto.referential.common.FpaZoneReference
    
    29 30
         fr.ird.observe.dto.referential.common.WindReference
    
    ... ... @@ -170,7 +171,7 @@
    170 171
                 <JLabel id='relatedObservedActivityLabel'/>
    
    171 172
               </cell>
    
    172 173
               <cell anchor='east' fill="both">
    
    173
    -            <JaxxComboBox id='relatedObservedActivity' genericType='fr.ird.observe.dto.data.ll.observation.ActivityReference' constructorParams='this'/>
    
    174
    +            <JaxxComboBox id='relatedObservedActivity' genericType='ActivityReference' constructorParams='this'/>
    
    174 175
               </cell>
    
    175 176
             </row>
    
    176 177
     
    
    ... ... @@ -183,10 +184,7 @@
    183 184
           </Table>
    
    184 185
         </JScrollPane>
    
    185 186
       </JPanel>
    
    186
    -
    
    187
    -  <!-- surcharge des actions (pour appliquer la css specifique) -->
    
    188 187
       <JButton id='actionDown'/>
    
    189
    -
    
    190 188
       <JMenuItem id='addSet'/>
    
    191 189
       <JMenuItem id='addSample'/>
    
    192 190
     </fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI>

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/ActivityUIHandler.java
    ... ... @@ -22,18 +22,8 @@ package fr.ird.observe.client.datasource.editor.ll.data.logbook;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    -import fr.ird.observe.client.datasource.editor.api.content.ContentUIInitializer;
    
    26
    -import fr.ird.observe.client.datasource.editor.api.content.actions.open.ContentOpen;
    
    27
    -import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIOpenExecutor;
    
    28 25
     import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveOpenable;
    
    29
    -import fr.ird.observe.client.util.init.DefaultUIInitializerResult;
    
    30 26
     import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    31
    -import fr.ird.observe.dto.data.ll.logbook.SampleDto;
    
    32
    -import fr.ird.observe.dto.data.ll.logbook.SetDto;
    
    33
    -import fr.ird.observe.dto.form.Form;
    
    34
    -import fr.ird.observe.services.service.data.ll.pairing.ActivityPairingEngine;
    
    35
    -
    
    36
    -import java.util.List;
    
    37 27
     
    
    38 28
     /**
    
    39 29
      * Created on 8/29/14.
    
    ... ... @@ -43,43 +33,6 @@ import java.util.List;
    43 33
      */
    
    44 34
     class ActivityUIHandler extends GeneratedActivityUIHandler {
    
    45 35
     
    
    46
    -    private ActivityPairingEngine pairingEngine;
    
    47
    -
    
    48
    -    @Override
    
    49
    -    protected ContentOpen<ActivityUI> createContentOpen(ActivityUI ui) {
    
    50
    -        ContentOpenableUIOpenExecutor<ActivityDto, ActivityUI> executor = new ContentOpenableUIOpenExecutor<>() {
    
    51
    -            @Override
    
    52
    -            public void openModel(ActivityUI ui) {
    
    53
    -                ActivityUIModel model = getModel();
    
    54
    -                List<fr.ird.observe.dto.data.ll.observation.ActivityReference> allActivityLonglineObs = getLlObservationActivityService().getChildren(model.getStates().getSelectedParentId()).toList();
    
    55
    -                Form<ActivityDto> form = model.openForm(allActivityLonglineObs, pairingEngine);
    
    56
    -                onOpenForm(form);
    
    57
    -                onOpenAfterOpenModel();
    
    58
    -            }
    
    59
    -        };
    
    60
    -        return new ContentOpen<>(ui, executor, executor) {
    
    61
    -            @Override
    
    62
    -            public DefaultUIInitializerResult init(ContentUIInitializer<ActivityUI> initializer) {
    
    63
    -                //FIXME Bug in Jaxx
    
    64
    -                this.getUi().getRelatedObservedActivity().setBeanType(fr.ird.observe.dto.data.ll.observation.ActivityReference.class);
    
    65
    -                return super.init(initializer);
    
    66
    -            }
    
    67
    -        };
    
    68
    -    }
    
    69
    -
    
    70
    -    @Override
    
    71
    -    public void onInit(ActivityUI ui) {
    
    72
    -        super.onInit(ui);
    
    73
    -        pairingEngine = new ActivityPairingEngine(getClientConfig().getReferentialLocale(), getLlCommonTripService(), getLlLogbookActivityService());
    
    74
    -    }
    
    75
    -
    
    76
    -    @Override
    
    77
    -    protected void installCreateNewAction() {
    
    78
    -        super.installCreateNewAction();
    
    79
    -        installCreateNewEditableAction(SetDto.class, getModel().getSource()::addEmptySetUINavigationNode);
    
    80
    -        installCreateNewEditableAction(SampleDto.class, getModel().getSource()::addEmptyActivitySampleUINavigationNode);
    
    81
    -    }
    
    82
    -
    
    83 36
         @Override
    
    84 37
         protected void installSaveAction() {
    
    85 38
             SaveOpenable.installAction(ui, ActivityDto::isSetOperation, ActivityUI::getAddSet);
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/ActivityUIModel.java
    ... ... @@ -59,7 +59,6 @@ public class ActivityUIModel extends GeneratedActivityUIModel {
    59 59
     
    
    60 60
         private static final Logger log = LogManager.getLogger(ActivityUIModel.class);
    
    61 61
     
    
    62
    -    private boolean opening = false;
    
    63 62
         private List<ActivityReference> activityObs;
    
    64 63
         private TripPairingContext pairingContext;
    
    65 64
     
    
    ... ... @@ -68,22 +67,19 @@ public class ActivityUIModel extends GeneratedActivityUIModel {
    68 67
             getStates().getBean().attachSetOperationListener();
    
    69 68
             getStates().getBean().addPropertyChangeListener(evt -> {
    
    70 69
                 String propertyName = evt.getPropertyName();
    
    71
    -            if (opening || !PROPERTIES_FOR_UPDATE_ACTIVITIES_OBS_LIST.contains(propertyName)) {
    
    70
    +            if (!getStates().isOpened() || !PROPERTIES_FOR_UPDATE_ACTIVITIES_OBS_LIST.contains(propertyName)) {
    
    72 71
                     return;
    
    73 72
                 }
    
    74 73
                 updateActivityObsCandidates();
    
    75 74
             });
    
    76 75
         }
    
    77 76
     
    
    78
    -    public Form<ActivityDto> openForm(List<ActivityReference> allActivityObs, ActivityPairingEngine pairingEngine) {
    
    77
    +    @Override
    
    78
    +    public Form<ActivityDto> openForm(String selectedId) {
    
    79
    +        List<fr.ird.observe.dto.data.ll.observation.ActivityReference> allActivityObs = getReferenceCache().getDataSource().getLlObservationActivityService().getChildren(getStates().getSelectedParentId()).toList();
    
    80
    +        ActivityPairingEngine pairingEngine = new ActivityPairingEngine(getClientUIContext().getClientConfig().getReferentialLocale(), getReferenceCache().getDataSource().getLlCommonTripService(), getReferenceCache().getDataSource().getLlLogbookActivityService());
    
    79 81
             this.pairingContext = pairingEngine.newTripContext(getStates().getSelectedParentId(), ImmutableList.copyOf(allActivityObs));
    
    80
    -        opening = true;
    
    81
    -        Form<ActivityDto> form;
    
    82
    -        try {
    
    83
    -            form = super.openForm(getStates().getSelectedId());
    
    84
    -        } finally {
    
    85
    -            opening = false;
    
    86
    -        }
    
    82
    +        Form<ActivityDto> form = super.openForm(selectedId);
    
    87 83
             updateActivityObsCandidates();
    
    88 84
             return form;
    
    89 85
         }
    
    ... ... @@ -97,14 +93,14 @@ public class ActivityUIModel extends GeneratedActivityUIModel {
    97 93
             this.activityObs = Objects.requireNonNull(activityObs);
    
    98 94
             boolean removeRelatedObservedActivity = relatedObservedActivity != null && !activityObs.contains(relatedObservedActivity);
    
    99 95
             firePropertyChange(PROPERTY_ACTIVITY_OBS, null, activityObs);
    
    100
    -        if (removeRelatedObservedActivity) {
    
    96
    +        if (getStates().isOpened() && removeRelatedObservedActivity) {
    
    101 97
                 log.info(String.format("%s Removed not matching related observed activity: %s", getPrefix(), relatedObservedActivity));
    
    102 98
                 getStates().getBean().setRelatedObservedActivity(null);
    
    103 99
             }
    
    104 100
         }
    
    105 101
     
    
    106 102
         private void updateActivityObsCandidates() {
    
    107
    -        if (opening) {
    
    103
    +        if (!getStates().isOpened()) {
    
    108 104
                 return;
    
    109 105
             }
    
    110 106
             log.info(String.format("%s Will update release observed activities...", getPrefix()));
    

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/ActivityUIHandler.java
    ... ... @@ -24,7 +24,6 @@ package fr.ird.observe.client.datasource.editor.ll.data.observation;
    24 24
     
    
    25 25
     import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveOpenable;
    
    26 26
     import fr.ird.observe.dto.data.ll.observation.ActivityDto;
    
    27
    -import fr.ird.observe.dto.data.ll.observation.SetDto;
    
    28 27
     
    
    29 28
     /**
    
    30 29
      * Created on 8/29/14.
    
    ... ... @@ -40,12 +39,6 @@ class ActivityUIHandler extends GeneratedActivityUIHandler {
    40 39
             super.onInit(ui);
    
    41 40
         }
    
    42 41
     
    
    43
    -    @Override
    
    44
    -    protected void installCreateNewAction() {
    
    45
    -        super.installCreateNewAction();
    
    46
    -        installCreateNewEditableAction(SetDto.class, getModel().getSource()::addEmptySetUINavigationNode);
    
    47
    -    }
    
    48
    -
    
    49 42
         @Override
    
    50 43
         protected void installSaveAction() {
    
    51 44
             SaveOpenable.installAction(ui, ActivityDto::isSetOperation, ActivityUI::getAddSet);
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/ActivityUIHandler.java
    ... ... @@ -21,34 +21,12 @@
    21 21
      */
    
    22 22
     package fr.ird.observe.client.datasource.editor.ps.data.observation;
    
    23 23
     
    
    24
    -import fr.ird.observe.client.ClientUIContext;
    
    25
    -import fr.ird.observe.client.datasource.dcp.FloatingObjectPresetsManager;
    
    26 24
     import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.SaveOpenable;
    
    27
    -import fr.ird.observe.client.datasource.editor.ps.ObservePsKeyStrokes;
    
    28
    -import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPreset;
    
    29
    -import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPresetModel;
    
    30 25
     import fr.ird.observe.dto.data.ps.observation.ActivityDto;
    
    31
    -import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
    
    32
    -import fr.ird.observe.dto.data.ps.observation.SetDto;
    
    33
    -import fr.ird.observe.dto.decoration.WithDecoratorService;
    
    34 26
     import fr.ird.observe.dto.referential.ps.common.VesselActivityReference;
    
    35
    -import org.apache.logging.log4j.LogManager;
    
    36
    -import org.apache.logging.log4j.Logger;
    
    37 27
     
    
    38
    -import javax.swing.AbstractAction;
    
    39
    -import javax.swing.JButton;
    
    40
    -import javax.swing.JComponent;
    
    41
    -import javax.swing.JOptionPane;
    
    42
    -import javax.swing.JPanel;
    
    43
    -import javax.swing.KeyStroke;
    
    44
    -import java.awt.Font;
    
    45
    -import java.awt.GridLayout;
    
    46
    -import java.awt.event.ActionEvent;
    
    47 28
     import java.util.List;
    
    48
    -import java.util.Objects;
    
    49
    -import java.util.Set;
    
    50 29
     
    
    51
    -import static fr.ird.observe.client.datasource.editor.api.content.referential.usage.UsageUIHandlerSupport.findButton;
    
    52 30
     import static io.ultreia.java4all.i18n.I18n.t;
    
    53 31
     
    
    54 32
     /**
    
    ... ... @@ -57,36 +35,6 @@ import static io.ultreia.java4all.i18n.I18n.t;
    57 35
      */
    
    58 36
     class ActivityUIHandler extends GeneratedActivityUIHandler {
    
    59 37
     
    
    60
    -    private static final Logger log = LogManager.getLogger(ActivityUIHandler.class);
    
    61
    -
    
    62
    -    private static class UsePresetAction extends AbstractAction implements WithDecoratorService {
    
    63
    -
    
    64
    -        private final FloatingObjectPreset preset;
    
    65
    -        private final KeyStroke keyStroke;
    
    66
    -        private JOptionPane pane;
    
    67
    -
    
    68
    -        public UsePresetAction(FloatingObjectPreset preset, int index) {
    
    69
    -            this.preset = Objects.requireNonNull(preset);
    
    70
    -            this.keyStroke = Objects.requireNonNull(KeyStroke.getKeyStroke("F" + index));
    
    71
    -            putValue(UsePresetAction.class.getName(), getClass().getName() + "_" + index);
    
    72
    -            putValue(NAME, getDecoratorService().getDecoratorByType(preset.getClass()).toString(preset));
    
    73
    -        }
    
    74
    -
    
    75
    -        public void install(JButton parent, JOptionPane pane) {
    
    76
    -            this.pane = pane;
    
    77
    -            String actionMapKey = (String) getValue(UsePresetAction.class.getName());
    
    78
    -            pane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, actionMapKey);
    
    79
    -            pane.getActionMap().put(actionMapKey, this);
    
    80
    -            ObservePsKeyStrokes.addKeyStroke(parent, keyStroke);
    
    81
    -        }
    
    82
    -
    
    83
    -        @Override
    
    84
    -        public void actionPerformed(ActionEvent e) {
    
    85
    -            log.info(String.format("Choose dcp preset: %s", preset.getLabel1()));
    
    86
    -            pane.setValue(preset);
    
    87
    -        }
    
    88
    -    }
    
    89
    -
    
    90 38
         @Override
    
    91 39
         public void onInit(ActivityUI ui) {
    
    92 40
             super.onInit(ui);
    
    ... ... @@ -96,64 +44,22 @@ class ActivityUIHandler extends GeneratedActivityUIHandler {
    96 44
             ui.vesselActivityInformation.setToolTipText(text);
    
    97 45
         }
    
    98 46
     
    
    99
    -    @Override
    
    100
    -    protected void installCreateNewAction() {
    
    101
    -        super.installCreateNewAction();
    
    102
    -        installCreateNewEditableAction(SetDto.class, ui.getModel().getSource()::addEmptySetUINavigationNode);
    
    103
    -        installCreateNewEditableAction(FloatingObjectDto.class, this::chooseFloatingObjectPreset, ui.getModel().getSource()::addEmptyFloatingObjectUINavigationNode);
    
    104
    -    }
    
    105
    -
    
    106 47
         @Override
    
    107 48
         protected void installSaveAction() {
    
    108 49
             SaveOpenable.installAction(ui, ActivityDto::isStrongSetOperation, ActivityUI::getAddSet);
    
    109 50
         }
    
    110 51
     
    
    111 52
         private String getActivity6Label() {
    
    112
    -
    
    113 53
             List<VesselActivityReference> activities = getReferentialReferences(VesselActivityReference.class);
    
    114
    -
    
    115 54
             for (VesselActivityReference vesselActivity : activities) {
    
    116 55
                 if (ActivityDto.isFishingOperation(vesselActivity)) {
    
    117
    -                return getDecoratorService().getReferentialReferenceDecorator(VesselActivityReference.class).toString(vesselActivity);
    
    56
    +                return vesselActivity.toString();
    
    57
    +//                return getDecoratorService().getReferentialReferenceDecorator(VesselActivityReference.class).toString(vesselActivity);
    
    118 58
                 }
    
    119 59
             }
    
    120 60
             throw new IllegalStateException(t("observe.data.ps.observation.Activity.error.no.activity.6"));
    
    121 61
         }
    
    122 62
     
    
    123
    -    private boolean chooseFloatingObjectPreset(ActivityDto bean) {
    
    124
    -
    
    125
    -        FloatingObjectPresetsManager floatingObjectPresetsManager = getClientUIContext().getFloatingObjectPresetsManager();
    
    126
    -        Set<FloatingObjectPreset> psObservation = floatingObjectPresetsManager.getPresets(FloatingObjectPresetModel.ps_observation);
    
    127
    -        if (!psObservation.isEmpty()) {
    
    128
    -
    
    129
    -            JPanel userConfigs = new JPanel(new GridLayout(0, 2));
    
    130
    -
    
    131
    -            String replaceText = t("observe.ui.choice.dcp.default") + " (Enter)";
    
    132
    -            Object[] options = {replaceText};
    
    133
    -            JOptionPane pane = new JOptionPane(userConfigs, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);
    
    134
    -            JButton jButton = Objects.requireNonNull(findButton(pane, replaceText));
    
    135
    -            Font font = jButton.getFont().deriveFont(18f);
    
    136
    -            jButton.setFont(font.deriveFont(Font.ITALIC));
    
    137
    -            int index = 0;
    
    138
    -            for (FloatingObjectPreset preset : psObservation) {
    
    139
    -                UsePresetAction a = new UsePresetAction(preset, ++index);
    
    140
    -                JButton b = new JButton(a);
    
    141
    -                b.setFont(font);
    
    142
    -                userConfigs.add(b);
    
    143
    -                a.install(b, pane);
    
    144
    -            }
    
    145
    -            int response = ClientUIContext.askUser(pane, t("observe.data.ps.observation.FloatingObjectReference.choose.title"), options);
    
    146
    -            Object value = pane.getValue();
    
    147
    -            if (value instanceof FloatingObjectPreset) {
    
    148
    -                floatingObjectPresetsManager.setReferenceToUse((FloatingObjectPreset) value);
    
    149
    -            } else {
    
    150
    -                return response != JOptionPane.CLOSED_OPTION;
    
    151
    -            }
    
    152
    -        }
    
    153
    -        return true;
    
    154
    -    }
    
    155
    -
    
    156
    -
    
    157 63
     //    @Override
    
    158 64
     //    protected ContentOpenableUILayoutFocusTraversalPolicy<ActivityUI> createFocusTraversalPolicy() {
    
    159 65
     //        return new ContentOpenableUILayoutFocusTraversalPolicy<ActivityUI>() {
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/ActivityUIModel.java
    ... ... @@ -44,15 +44,6 @@ public class ActivityUIModel extends GeneratedActivityUIModel {
    44 44
                 boolean newValue = ActivityDto.isChangedZoneOperation(newActivitySeine);
    
    45 45
                 firePropertyChange(PROPERTY_CHANGED_ZONE_OPERATION, oldValue, newValue);
    
    46 46
             });
    
    47
    -
    
    48
    -    }
    
    49
    -
    
    50
    -    public boolean isSetOperation() {
    
    51
    -        return getStates().getBean().isSetOperation();
    
    52
    -    }
    
    53
    -
    
    54
    -    public boolean isDcpOperation() {
    
    55
    -        return getStates().getBean().isDcpOperation();
    
    56 47
         }
    
    57 48
     
    
    58 49
         public boolean isChangedZoneOperation() {
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/FloatingObjectUI.jcss
    ... ... @@ -35,6 +35,10 @@
    35 35
       enabled:{model.isLeaving() && model.isArriving()};
    
    36 36
     }
    
    37 37
     
    
    38
    +#addFloatingObjectPreset {
    
    39
    +  enabled:{states.isUpdatingMode() && getModel().getReference() == null};
    
    40
    +}
    
    41
    +
    
    38 42
     #objectOperation {
    
    39 43
       enabled:{states.isCreatingMode()};
    
    40 44
     }
    
    ... ... @@ -68,11 +72,6 @@
    68 72
       text:{model.getComputedWhenLeavingSimplifiedObjectTypeValue()};
    
    69 73
     }
    
    70 74
     
    
    71
    -/*#addFloatingObjectReference {
    
    72
    -  visible:{states.isUpdatingMode()};
    
    73
    -  focusable:false;
    
    74
    -}*/
    
    75
    -
    
    76 75
     #typeOperation {
    
    77 76
       selectedItem:{bean.getTypeTransmittingBuoyOperation()};
    
    78 77
       _skipBindingToBean:true;
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/FloatingObjectUIHandler.java
    ... ... @@ -280,29 +280,21 @@ public class FloatingObjectUIHandler extends GeneratedFloatingObjectUIHandler {
    280 280
                                     TransmittingBuoyDto transmittingBuoy) {
    
    281 281
     
    
    282 282
             if (transmittingBuoy == null) {
    
    283
    -
    
    284 283
                 TransmittingBuoyDto.newDto(new Date()).copy(editBean);
    
    285 284
                 editBean.setCreateDate(new Date());
    
    286 285
                 editBean.setTransmittingBuoyOperation(operation);
    
    287
    -
    
    288 286
                 log.debug(String.format("Reuse an empty balise lue for objectOperation %s", operation.getLabel()));
    
    289
    -
    
    290 287
                 if (isBalisePose(operation)) {
    
    291
    -
    
    292 288
                     // objectOperation de pose
    
    293 289
                     // toujours appartient au navire
    
    294 290
                     TransmittingBuoyOwnershipReference r = getModel().getReferenceCache().<TransmittingBuoyOwnershipReference>tryGetReferentialReferenceById(TransmittingBuoyDto.PROPERTY_TRANSMITTING_BUOY_OWNERSHIP, ProtectedIdsPs.PS_COMMON_TRANSMITTING_BUOY_OWNERSHIP_THIS_SHIP_ID).orElse(null);
    
    295 291
                     log.info("Using ownership this vessel: " + r);
    
    296 292
                     editBean.setTransmittingBuoyOwnership(r);
    
    297 293
                 }
    
    298
    -
    
    299 294
             } else {
    
    300
    -
    
    301 295
                 editBean.copy(transmittingBuoy);
    
    302 296
     //            TransmittingBuoyHelper.copyTransmittingBuoyDto(editBean, transmittingBuoy);
    
    303
    -
    
    304 297
             }
    
    305
    -
    
    306 298
             getModel().getStates().getBean().getTransmittingBuoy().add(editBean);
    
    307 299
         }
    
    308 300
     
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/FloatingObjectUIModel.java
    ... ... @@ -23,16 +23,22 @@ package fr.ird.observe.client.datasource.editor.ps.data.observation;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26
    +import fr.ird.observe.client.ClientUIContext;
    
    26 27
     import fr.ird.observe.client.WithClientUIContext;
    
    28
    +import fr.ird.observe.client.datasource.dcp.FloatingObjectPresetsManager;
    
    29
    +import fr.ird.observe.client.datasource.editor.ps.ObservePsKeyStrokes;
    
    27 30
     import fr.ird.observe.dto.I18nEnumHelper;
    
    28 31
     import fr.ird.observe.dto.data.ps.DcpComputedValue;
    
    29 32
     import fr.ird.observe.dto.data.ps.consolidate.dcp.ConsolidateFloatingObjectResult;
    
    30 33
     import fr.ird.observe.dto.data.ps.consolidate.dcp.SimplifiedObjectTypeSpecializedRules;
    
    31 34
     import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPreset;
    
    35
    +import fr.ird.observe.dto.data.ps.dcp.FloatingObjectPresetModel;
    
    36
    +import fr.ird.observe.dto.data.ps.observation.ActivityDto;
    
    32 37
     import fr.ird.observe.dto.data.ps.observation.FloatingObjectDto;
    
    33 38
     import fr.ird.observe.dto.data.ps.observation.FloatingObjectPartDto;
    
    34 39
     import fr.ird.observe.dto.data.ps.observation.TransmittingBuoyDto;
    
    35 40
     import fr.ird.observe.dto.data.ps.observation.consolidate.ConsolidateFloatingObjectRequest;
    
    41
    +import fr.ird.observe.dto.decoration.WithDecoratorService;
    
    36 42
     import fr.ird.observe.dto.form.Form;
    
    37 43
     import fr.ird.observe.dto.form.FormDefinition;
    
    38 44
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    ... ... @@ -42,6 +48,15 @@ import fr.ird.observe.spi.module.ObserveBusinessProject;
    42 48
     import org.apache.logging.log4j.LogManager;
    
    43 49
     import org.apache.logging.log4j.Logger;
    
    44 50
     
    
    51
    +import javax.swing.AbstractAction;
    
    52
    +import javax.swing.JButton;
    
    53
    +import javax.swing.JComponent;
    
    54
    +import javax.swing.JOptionPane;
    
    55
    +import javax.swing.JPanel;
    
    56
    +import javax.swing.KeyStroke;
    
    57
    +import java.awt.Font;
    
    58
    +import java.awt.GridLayout;
    
    59
    +import java.awt.event.ActionEvent;
    
    45 60
     import java.io.File;
    
    46 61
     import java.io.IOException;
    
    47 62
     import java.util.Date;
    
    ... ... @@ -53,6 +68,7 @@ import java.util.Optional;
    53 68
     import java.util.Set;
    
    54 69
     import java.util.stream.Collectors;
    
    55 70
     
    
    71
    +import static fr.ird.observe.client.datasource.editor.api.content.referential.usage.UsageUIHandlerSupport.findButton;
    
    56 72
     import static io.ultreia.java4all.i18n.I18n.t;
    
    57 73
     
    
    58 74
     /**
    
    ... ... @@ -85,6 +101,34 @@ public class FloatingObjectUIModel extends GeneratedFloatingObjectUIModel implem
    85 101
             this.whenLeaving = new LinkedHashMap<>();
    
    86 102
         }
    
    87 103
     
    
    104
    +    private static class UsePresetAction extends AbstractAction implements WithDecoratorService {
    
    105
    +
    
    106
    +        private final FloatingObjectPreset preset;
    
    107
    +        private final KeyStroke keyStroke;
    
    108
    +        private JOptionPane pane;
    
    109
    +
    
    110
    +        public UsePresetAction(FloatingObjectPreset preset, int index) {
    
    111
    +            this.preset = Objects.requireNonNull(preset);
    
    112
    +            this.keyStroke = Objects.requireNonNull(KeyStroke.getKeyStroke("F" + index));
    
    113
    +            putValue(UsePresetAction.class.getName(), getClass().getName() + "_" + index);
    
    114
    +            putValue(NAME, getDecoratorService().getDecoratorByType(preset.getClass()).toString(preset));
    
    115
    +        }
    
    116
    +
    
    117
    +        public void install(JButton parent, JOptionPane pane) {
    
    118
    +            this.pane = pane;
    
    119
    +            String actionMapKey = (String) getValue(UsePresetAction.class.getName());
    
    120
    +            pane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, actionMapKey);
    
    121
    +            pane.getActionMap().put(actionMapKey, this);
    
    122
    +            ObservePsKeyStrokes.addKeyStroke(parent, keyStroke);
    
    123
    +        }
    
    124
    +
    
    125
    +        @Override
    
    126
    +        public void actionPerformed(ActionEvent e) {
    
    127
    +            log.info(String.format("Choose dcp preset: %s", preset.getLabel1()));
    
    128
    +            pane.setValue(preset);
    
    129
    +        }
    
    130
    +    }
    
    131
    +
    
    88 132
         public ImmutableSet<FloatingObjectPartDto> toParts() {
    
    89 133
             ImmutableSet.Builder<FloatingObjectPartDto> result = ImmutableSet.builder();
    
    90 134
             Date now = new Date();
    
    ... ... @@ -131,13 +175,14 @@ public class FloatingObjectUIModel extends GeneratedFloatingObjectUIModel implem
    131 175
     
    
    132 176
         @Override
    
    133 177
         public void open() {
    
    134
    -        Optional<FloatingObjectPreset> floatingObjectReference = Optional.ofNullable(getClientUIContext().getFloatingObjectPresetsManager().getReferenceToUse());
    
    135
    -        setReference(floatingObjectReference.orElse(null));
    
    136 178
             if (reference != null) {
    
    137 179
                 log.info(String.format("%s Will use dcp preset: %s", getPrefix(), reference));
    
    138 180
             }
    
    139
    -        getClientUIContext().getFloatingObjectPresetsManager().setReferenceToUse(null);
    
    140 181
             super.open();
    
    182
    +        if (getStates().isCreatingMode()) {
    
    183
    +            FloatingObjectPreset reference = chooseFloatingObjectPreset();
    
    184
    +            setReference(reference);
    
    185
    +        }
    
    141 186
         }
    
    142 187
     
    
    143 188
         @Override
    
    ... ... @@ -152,6 +197,37 @@ public class FloatingObjectUIModel extends GeneratedFloatingObjectUIModel implem
    152 197
             fireComputedValuesChanged();
    
    153 198
         }
    
    154 199
     
    
    200
    +    private FloatingObjectPreset chooseFloatingObjectPreset() {
    
    201
    +
    
    202
    +        FloatingObjectPresetsManager floatingObjectPresetsManager = getClientUIContext().getFloatingObjectPresetsManager();
    
    203
    +        Set<FloatingObjectPreset> psObservation = floatingObjectPresetsManager.getPresets(FloatingObjectPresetModel.ps_observation);
    
    204
    +        if (!psObservation.isEmpty()) {
    
    205
    +
    
    206
    +            JPanel userConfigs = new JPanel(new GridLayout(0, 2));
    
    207
    +
    
    208
    +            String replaceText = t("observe.ui.choice.dcp.default") + " (Enter)";
    
    209
    +            Object[] options = {replaceText};
    
    210
    +            JOptionPane pane = new JOptionPane(userConfigs, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);
    
    211
    +            JButton jButton = Objects.requireNonNull(findButton(pane, replaceText));
    
    212
    +            Font font = jButton.getFont().deriveFont(18f);
    
    213
    +            jButton.setFont(font.deriveFont(Font.ITALIC));
    
    214
    +            int index = 0;
    
    215
    +            for (FloatingObjectPreset preset : psObservation) {
    
    216
    +                UsePresetAction a = new UsePresetAction(preset, ++index);
    
    217
    +                JButton b = new JButton(a);
    
    218
    +                b.setFont(font);
    
    219
    +                userConfigs.add(b);
    
    220
    +                a.install(b, pane);
    
    221
    +            }
    
    222
    +            ClientUIContext.askUser(pane, t("observe.data.ps.observation.FloatingObjectReference.choose.title"), options);
    
    223
    +            Object value = pane.getValue();
    
    224
    +            if (value instanceof FloatingObjectPreset) {
    
    225
    +                return (FloatingObjectPreset) value;
    
    226
    +            }
    
    227
    +        }
    
    228
    +        return null;
    
    229
    +    }
    
    230
    +
    
    155 231
         public void fireComputedValuesChanged() {
    
    156 232
             firePropertyChange("computedWhenArrivingBiodegradableValue", getComputedWhenArrivingBiodegradableValue());
    
    157 233
             firePropertyChange("computedWhenArrivingNonEntanglingValue", getComputedWhenArrivingNonEntanglingValue());
    
    ... ... @@ -244,7 +320,6 @@ public class FloatingObjectUIModel extends GeneratedFloatingObjectUIModel implem
    244 320
             return arriving;
    
    245 321
         }
    
    246 322
     
    
    247
    -
    
    248 323
         public void setArriving(boolean arriving) {
    
    249 324
             this.arriving = arriving;
    
    250 325
             log.debug("setArriving: " + arriving);
    
    ... ... @@ -301,4 +376,5 @@ public class FloatingObjectUIModel extends GeneratedFloatingObjectUIModel implem
    301 376
                 map.put(dto, value);
    
    302 377
             }
    
    303 378
         }
    
    379
    +
    
    304 380
     }

  • client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/CapabilityDescriptor.java
    ... ... @@ -111,6 +111,8 @@ public class CapabilityDescriptor {
    111 111
                 "        }\n";
    
    112 112
         public static final String INSTALL_CREATE_NEW_TABLE_ACTION = "" +
    
    113 113
                 "        installCreateNewTableEntryAction(%1$s.class);\n";
    
    114
    +    public static final String INSTALL_CREATE_NEW_EDIT_ACTION = "" +
    
    115
    +            "        installCreateNewEditableAction(%1$sDto.class, getModel().getSource()::addEmpty%2$s);\n";
    
    114 116
         public static final String INSTALL_CREATE_NEW_ACTION = "" +
    
    115 117
                 "        installCreateNewOpenableAction(t-> true);\n";
    
    116 118
         public static final String INSTALL_CREATE_NEW_ACTION_WITH_PREDICATE = "" +
    
    ... ... @@ -386,8 +388,12 @@ public class CapabilityDescriptor {
    386 388
                 case TABLE:
    
    387 389
                     imports.add(CreateNewContentTableUIEntry.class.getName());
    
    388 390
                     return String.format(INSTALL_CREATE_NEW_TABLE_ACTION, getNodeTypeName());
    
    391
    +
    
    389 392
                 case EDIT:
    
    390
    -                break;
    
    393
    +                if (dtoType!=null) {
    
    394
    +                    imports.add(dtoType.getName());
    
    395
    +                    return String.format(INSTALL_CREATE_NEW_EDIT_ACTION, dtoType.getSimpleName().replace("Dto", ""), getNodeTypeSimpleName());
    
    396
    +                }
    
    391 397
                 case SIMPLE:
    
    392 398
                 case ROOT:
    
    393 399
                 case REFERENTIAL_HOME:
    

  • client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/ContentNodeType.java
    ... ... @@ -156,7 +156,7 @@ public enum ContentNodeType {
    156 156
     
    
    157 157
     
    
    158 158
         public Class<? extends IdDto> getDto(BusinessProject businessProject, String nodeTypeName) {
    
    159
    -        return null;
    
    159
    +        return getDto0(businessProject, nodeTypeName);
    
    160 160
         }
    
    161 161
     
    
    162 162
         Class<? extends IdDto> getDto0(BusinessProject businessProject, String nodeTypeName) {
    

  • client/datasource/editor/spi/src/main/java/fr/ird/observe/client/datasource/editor/spi/content/helper/ContentUIHandlerHelper.java
    ... ... @@ -91,8 +91,15 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport {
    91 91
             }
    
    92 92
             if (generator.capabilitiesDescriptor != null) {
    
    93 93
                 for (CapabilityDescriptor capabilityDescriptor : generator.capabilitiesDescriptor) {
    
    94
    -                if (editNode != null && editNode.getType().equals(capabilityDescriptor.getOptionalDtoType())) {
    
    95
    -                    continue;
    
    94
    +
    
    95
    +                ContentNodeType contentNodeType = capabilityDescriptor.getContentNodeType();
    
    96
    +
    
    97
    +                Class<? extends IdDto> optionalDtoType = capabilityDescriptor.getOptionalDtoType();
    
    98
    +
    
    99
    +                if (editNode != null) {
    
    100
    +                    if (editNode.getType().equals(optionalDtoType)) {
    
    101
    +                        continue;
    
    102
    +                    }
    
    96 103
                     }
    
    97 104
                     String method = capabilityDescriptor.generateAddNewAction(imports, generator);
    
    98 105
                     createChildrenMethodBuilder.append(method);
    
    ... ... @@ -160,6 +167,11 @@ public class ContentUIHandlerHelper extends ContentUIHelperSupport {
    160 167
             }
    
    161 168
             extraMethods += generateListCreateNewAction(imports, generator);
    
    162 169
             extraMethods += String.format(INSTALL_MOVE_ACTION, methodName);
    
    170
    +        generator.capabilitiesDescriptor.forEach(c-> {
    
    171
    +            if (c.getContentNodeType()==ContentNodeType.EDIT) {
    
    172
    +                // add
    
    173
    +            }
    
    174
    +        });
    
    163 175
             return generate(ContentUIHandlerHelper.UI_HANDLER_GENERATED2, imports, generator.cleanClassName, uiHandler, dtoType, extraType, extraMethods);
    
    164 176
         }
    
    165 177