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

Commits:

24 changed files:

Changes:

  • client-core/src/main/i18n/getters/java.getter
    ... ... @@ -783,6 +783,7 @@ observe.message.db.loaded
    783 783
     observe.message.db.loading
    
    784 784
     observe.message.delete
    
    785 785
     observe.message.delete.directory
    
    786
    +observe.message.delete.list
    
    786 787
     observe.message.delete.new
    
    787 788
     observe.message.goto.site
    
    788 789
     observe.message.help.usage
    
    ... ... @@ -881,7 +882,6 @@ observe.ui.tree.data.ll.trip.unsaved
    881 882
     observe.ui.tree.data.ps.activity.list
    
    882 883
     observe.ui.tree.data.ps.activity.unsaved
    
    883 884
     observe.ui.tree.data.ps.discardedTargetCatch
    
    884
    -observe.ui.tree.data.ps.discardedTargetSample
    
    885 885
     observe.ui.tree.data.ps.floatingObject.unsaved
    
    886 886
     observe.ui.tree.data.ps.keptTargetCatch
    
    887 887
     observe.ui.tree.data.ps.keptTargetSample
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/api/data/list/ContentListUI.jaxx
    ... ... @@ -86,11 +86,12 @@ public abstract ContentListUIHandler<E, C, R, U> getHandler();
    86 86
           </cell>
    
    87 87
         </row>
    
    88 88
         <row>
    
    89
    -      <cell fill='both'>
    
    90
    -        <JButton id='move'/>
    
    91
    -      </cell>
    
    92
    -      <cell>
    
    93
    -        <JButton id='create'/>
    
    89
    +      <cell columns="3">
    
    90
    +        <JPanel layout="{new GridLayout(1, 0)}">
    
    91
    +          <JButton id='delete'/>
    
    92
    +          <JButton id='move'/>
    
    93
    +          <JButton id='create'/>
    
    94
    +        </JPanel>
    
    94 95
           </cell>
    
    95 96
         </row>
    
    96 97
       </Table>
    

  • client-core/src/main/java/fr/ird/observe/client/ui/content/api/data/list/ContentListUI.jcss
    ... ... @@ -93,6 +93,10 @@
    93 93
       enabled:{model.isOneOrMoreSelectedData()};
    
    94 94
     }
    
    95 95
     
    
    96
    +#delete {
    
    97
    +  enabled:{model.isOneOrMoreSelectedData()};
    
    98
    +}
    
    99
    +
    
    96 100
     #showTechnicalInformation {
    
    97 101
       enabled:{model.isOneSelectedData()};
    
    98 102
     }

  • client-core/src/main/java/fr/ird/observe/client/ui/content/api/data/list/actions/DeleteActionSupport.java
    1
    +package fr.ird.observe.client.ui.content.api.data.list.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.ObserveKeyStrokes;
    
    26
    +import fr.ird.observe.client.ui.content.api.actions.ContentUIActionSupport;
    
    27
    +import fr.ird.observe.client.ui.content.api.data.list.ContentListUI;
    
    28
    +import fr.ird.observe.client.ui.tree.navigation.NavigationTree;
    
    29
    +import fr.ird.observe.client.ui.util.UIHelper;
    
    30
    +import fr.ird.observe.dto.IdDto;
    
    31
    +import fr.ird.observe.dto.data.DataDto;
    
    32
    +import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
    
    33
    +import fr.ird.observe.dto.reference.DataDtoReference;
    
    34
    +import fr.ird.observe.dto.reference.DtoReference;
    
    35
    +import fr.ird.observe.navigation.model.edit.CloseEditNodeVetoException;
    
    36
    +import fr.ird.observe.navigation.model.edit.ObserveEditNode;
    
    37
    +import fr.ird.observe.navigation.tree.MultipleReferenceContainerNode;
    
    38
    +import org.apache.logging.log4j.LogManager;
    
    39
    +import org.apache.logging.log4j.Logger;
    
    40
    +
    
    41
    +import javax.swing.SwingUtilities;
    
    42
    +import javax.swing.tree.MutableTreeNode;
    
    43
    +import javax.swing.tree.TreeNode;
    
    44
    +import java.awt.event.ActionEvent;
    
    45
    +import java.util.List;
    
    46
    +import java.util.stream.Collectors;
    
    47
    +
    
    48
    +import static fr.ird.observe.client.ui.content.api.ContentUIHandler.getNavigationTree;
    
    49
    +import static io.ultreia.java4all.i18n.I18n.n;
    
    50
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    51
    +
    
    52
    +public abstract class DeleteActionSupport<E extends IdDto, D extends DataDto, R extends DataDtoReference<D, R>, U extends ContentListUI<E, D, R, U>> extends ContentUIActionSupport<U> {
    
    53
    +
    
    54
    +    private static final Logger log = LogManager.getLogger(Close.class);
    
    55
    +
    
    56
    +    protected final String typeI18nKey;
    
    57
    +
    
    58
    +    protected abstract void doDelete(U ui, List<R> beanList);
    
    59
    +
    
    60
    +    public DeleteActionSupport(Class<D> beanType) {
    
    61
    +        super(
    
    62
    +                n("observe.action.delete"),
    
    63
    +                null,
    
    64
    +                "delete",
    
    65
    +                ObserveKeyStrokes.KEY_STROKE_DELETE_DATA_GLOBAL);
    
    66
    +        this.typeI18nKey = t(ObserveI18nDecoratorHelper.getTypeI18nKey(beanType));
    
    67
    +        setTooltipText(t("observe.action.delete.data.tip", typeI18nKey));
    
    68
    +    }
    
    69
    +
    
    70
    +    @Override
    
    71
    +    protected void doActionPerformed(ActionEvent event, U ui) {
    
    72
    +
    
    73
    +        List<R> selectedData = ui.getModel().getSelectedDatas();
    
    74
    +
    
    75
    +        ObserveEditNode editNode = ui.getModel().getEditNode();
    
    76
    +        try {
    
    77
    +            fr.ird.observe.client.ui.content.api.data.open.actions.Close.closeData(editNode);
    
    78
    +        } catch (CloseEditNodeVetoException e1) {
    
    79
    +            UIHelper.handlingError(e1);
    
    80
    +            return;
    
    81
    +        }
    
    82
    +        boolean canDelete = askToDelete(ui, selectedData);
    
    83
    +        if (canDelete) {
    
    84
    +            getMainUIModel().setBusy(true);
    
    85
    +            try {
    
    86
    +                doDelete(ui, selectedData);
    
    87
    +            } finally {
    
    88
    +                SwingUtilities.invokeLater(() -> afterDelete(selectedData));
    
    89
    +            }
    
    90
    +        }
    
    91
    +    }
    
    92
    +
    
    93
    +    private boolean askToDelete(U ui, List<R> bean) {
    
    94
    +        return UIHelper.confirmForEntityDelete(ui, ui.getModel().getReferenceType(), bean);
    
    95
    +    }
    
    96
    +
    
    97
    +    private void afterDelete(List<R> selectedData) {
    
    98
    +
    
    99
    +        try {
    
    100
    +
    
    101
    +            log.info("After delete: " + selectedData.stream().map(DtoReference::getId).collect(Collectors.joining()));
    
    102
    +            getDataSource().setModified(true);
    
    103
    +            NavigationTree tree = getNavigationTree();
    
    104
    +
    
    105
    +            MultipleReferenceContainerNode<D, R> parentNode = (MultipleReferenceContainerNode<D, R>) tree.getSelectedNode();
    
    106
    +            for (R selectedDatum : selectedData) {
    
    107
    +                int nodePosition = parentNode.getNodePosition(selectedDatum);
    
    108
    +                TreeNode nodeToDelete = parentNode.getChildAt(nodePosition);
    
    109
    +                tree.removeNode((MutableTreeNode) nodeToDelete);
    
    110
    +            }
    
    111
    +            tree.reloadNode(parentNode, false);
    
    112
    +            tree.selectSafeNode(parentNode.getParent());
    
    113
    +            tree.selectSafeNode(parentNode);
    
    114
    +        } finally {
    
    115
    +            getMainUIModel().setBusy(false);
    
    116
    +        }
    
    117
    +
    
    118
    +    }
    
    119
    +
    
    120
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/common/TripListUI.jaxx
    ... ... @@ -41,4 +41,5 @@
    41 41
       <JButton id='close'/>
    
    42 42
       <JButton id='move'/>
    
    43 43
       <JButton id='create'/>
    
    44
    +  <JButton id='delete'/>
    
    44 45
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/common/actions/TripListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ll.common.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ll.common.TripListUI;
    
    27
    +import fr.ird.observe.dto.data.ll.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ll.common.TripReference;
    
    29
    +import fr.ird.observe.dto.referential.common.ProgramDto;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class TripListUIDelete extends DeleteActionSupport<ProgramDto, TripDto, TripReference, TripListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(TripListUIDelete.class);
    
    38
    +
    
    39
    +    public TripListUIDelete() {
    
    40
    +        super(TripDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(TripListUI ui, List<TripReference> beanList) {
    
    45
    +        for (TripReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getLlCommonTripService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +        }
    
    50
    +    }
    
    51
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/landing/LandingListUI.jaxx
    ... ... @@ -41,4 +41,5 @@
    41 41
       <JButton id='close'/>
    
    42 42
       <JButton id='move'/>
    
    43 43
       <JButton id='create'/>
    
    44
    +  <JButton id='delete'/>
    
    44 45
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/landing/actions/LandingListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ll.landing.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ll.landing.LandingListUI;
    
    27
    +import fr.ird.observe.dto.data.ll.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ll.landing.LandingDto;
    
    29
    +import fr.ird.observe.dto.data.ll.landing.LandingReference;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class LandingListUIDelete extends DeleteActionSupport<TripDto, LandingDto, LandingReference, LandingListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(LandingListUIDelete.class);
    
    38
    +
    
    39
    +    public LandingListUIDelete() {
    
    40
    +        super(LandingDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(LandingListUI ui, List<LandingReference> beanList) {
    
    45
    +        for (LandingReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getLlLandingLandingService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/logbook/ActivityListUI.jaxx
    ... ... @@ -42,4 +42,5 @@
    42 42
       <JButton id='close'/>
    
    43 43
       <JButton id='move'/>
    
    44 44
       <JButton id='create'/>
    
    45
    +  <JButton id='delete'/>
    
    45 46
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/logbook/TripSampleListUI.jaxx
    ... ... @@ -42,4 +42,5 @@
    42 42
       <JButton id='close'/>
    
    43 43
       <JButton id='move'/>
    
    44 44
       <JButton id='create'/>
    
    45
    +  <JButton id='delete'/>
    
    45 46
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/logbook/actions/ActivityListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ll.logbook.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ll.logbook.ActivityListUI;
    
    27
    +import fr.ird.observe.dto.data.ll.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    29
    +import fr.ird.observe.dto.data.ll.logbook.ActivityReference;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class ActivityListUIDelete extends DeleteActionSupport<TripDto, ActivityDto, ActivityReference, ActivityListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(ActivityListUIDelete.class);
    
    38
    +
    
    39
    +    public ActivityListUIDelete() {
    
    40
    +        super(ActivityDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(ActivityListUI ui, List<ActivityReference> beanList) {
    
    45
    +        for (ActivityReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getLlLogbookActivityService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/logbook/actions/TripSampleListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ll.logbook.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ll.logbook.TripSampleListUI;
    
    27
    +import fr.ird.observe.dto.data.ll.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ll.logbook.SampleDto;
    
    29
    +import fr.ird.observe.dto.data.ll.logbook.SampleReference;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class TripSampleListUIDelete extends DeleteActionSupport<TripDto, SampleDto, SampleReference, TripSampleListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(TripSampleListUIDelete.class);
    
    38
    +
    
    39
    +    public TripSampleListUIDelete() {
    
    40
    +        super(SampleDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(TripSampleListUI ui, List<SampleReference> beanList) {
    
    45
    +        String parentId = ui.getModel().getSelectedParentId();
    
    46
    +        for (SampleReference bean : beanList) {
    
    47
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    48
    +            getServicesProvider().getLlLogbookTripSampleService().delete(parentId, bean.getId());
    
    49
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    50
    +
    
    51
    +        }
    
    52
    +    }
    
    53
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/observation/ActivityListUI.jaxx
    ... ... @@ -42,4 +42,5 @@
    42 42
       <JButton id='close'/>
    
    43 43
       <JButton id='move'/>
    
    44 44
       <JButton id='create'/>
    
    45
    +  <JButton id='delete'/>
    
    45 46
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ll/observation/actions/ActivityListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ll.observation.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ll.observation.ActivityListUI;
    
    27
    +import fr.ird.observe.dto.data.ll.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ll.observation.ActivityDto;
    
    29
    +import fr.ird.observe.dto.data.ll.observation.ActivityReference;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class ActivityListUIDelete extends DeleteActionSupport<TripDto, ActivityDto, ActivityReference, ActivityListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(ActivityListUIDelete.class);
    
    38
    +
    
    39
    +    public ActivityListUIDelete() {
    
    40
    +        super(ActivityDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(ActivityListUI ui, List<ActivityReference> beanList) {
    
    45
    +        for (ActivityReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getLlObservationActivityService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/common/TripListUI.jaxx
    ... ... @@ -43,4 +43,5 @@
    43 43
       <JButton id='close'/>
    
    44 44
       <JButton id='move'/>
    
    45 45
       <JButton id='create'/>
    
    46
    +  <JButton id='delete'/>
    
    46 47
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/common/actions/TripListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ps.common.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ps.common.TripListUI;
    
    27
    +import fr.ird.observe.dto.data.ps.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ps.common.TripReference;
    
    29
    +import fr.ird.observe.dto.referential.common.ProgramDto;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class TripListUIDelete extends DeleteActionSupport<ProgramDto, TripDto, TripReference, TripListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(TripListUIDelete.class);
    
    38
    +
    
    39
    +    public TripListUIDelete() {
    
    40
    +        super(TripDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(TripListUI ui, List<TripReference> beanList) {
    
    45
    +        for (TripReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getPsCommonTripService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/ActivityListUI.jaxx
    ... ... @@ -42,4 +42,5 @@
    42 42
       <JButton id='close'/>
    
    43 43
       <JButton id='move'/>
    
    44 44
       <JButton id='create'/>
    
    45
    +  <JButton id='delete'/>
    
    45 46
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/RouteListUI.jaxx
    ... ... @@ -43,5 +43,5 @@
    43 43
       <JButton id='close'/>
    
    44 44
       <JButton id='move'/>
    
    45 45
       <JButton id='create'/>
    
    46
    -
    
    46
    +  <JButton id='delete'/>
    
    47 47
     </fr.ird.observe.client.ui.content.api.data.list.ContentListUI>

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/actions/ActivityListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ps.observation.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ps.observation.ActivityListUI;
    
    27
    +import fr.ird.observe.dto.data.ps.observation.ActivityDto;
    
    28
    +import fr.ird.observe.dto.data.ps.observation.ActivityReference;
    
    29
    +import fr.ird.observe.dto.data.ps.observation.RouteDto;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class ActivityListUIDelete extends DeleteActionSupport<RouteDto, ActivityDto, ActivityReference, ActivityListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(ActivityListUIDelete.class);
    
    38
    +
    
    39
    +    public ActivityListUIDelete() {
    
    40
    +        super(ActivityDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(ActivityListUI ui, List<ActivityReference> beanList) {
    
    45
    +        for (ActivityReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getPsObservationActivityService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/content/data/ps/observation/actions/RouteListUIDelete.java
    1
    +package fr.ird.observe.client.ui.content.data.ps.observation.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Client core
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + * 
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + * 
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.client.ui.content.api.data.list.actions.DeleteActionSupport;
    
    26
    +import fr.ird.observe.client.ui.content.data.ps.observation.RouteListUI;
    
    27
    +import fr.ird.observe.dto.data.ps.common.TripDto;
    
    28
    +import fr.ird.observe.dto.data.ps.observation.RouteDto;
    
    29
    +import fr.ird.observe.dto.data.ps.observation.RouteReference;
    
    30
    +import org.apache.logging.log4j.LogManager;
    
    31
    +import org.apache.logging.log4j.Logger;
    
    32
    +
    
    33
    +import java.util.List;
    
    34
    +
    
    35
    +public class RouteListUIDelete extends DeleteActionSupport<TripDto, RouteDto, RouteReference, RouteListUI> {
    
    36
    +
    
    37
    +    private static final Logger log = LogManager.getLogger(RouteListUIDelete.class);
    
    38
    +
    
    39
    +    public RouteListUIDelete() {
    
    40
    +        super(RouteDto.class);
    
    41
    +    }
    
    42
    +
    
    43
    +    @Override
    
    44
    +    protected void doDelete(RouteListUI ui, List<RouteReference> beanList) {
    
    45
    +        for (RouteReference bean : beanList) {
    
    46
    +            log.info(String.format("Will delete `%s`: %s",typeI18nKey, bean.getId()));
    
    47
    +            getServicesProvider().getPsObservationRouteService().delete(bean.getId());
    
    48
    +            log.info(String.format("Delete done for `%s`: %s",typeI18nKey, bean.getId()));
    
    49
    +
    
    50
    +        }
    
    51
    +    }
    
    52
    +}

  • client-core/src/main/java/fr/ird/observe/client/ui/util/UIHelper.java
    ... ... @@ -69,6 +69,7 @@ import java.awt.event.ComponentEvent;
    69 69
     import java.awt.event.WindowAdapter;
    
    70 70
     import java.awt.event.WindowEvent;
    
    71 71
     import java.beans.PropertyChangeListener;
    
    72
    +import java.util.List;
    
    72 73
     import java.util.Objects;
    
    73 74
     
    
    74 75
     import static io.ultreia.java4all.i18n.I18n.t;
    
    ... ... @@ -323,6 +324,61 @@ public class UIHelper extends UIHelperSupport {
    323 324
             return response == 0;
    
    324 325
         }
    
    325 326
     
    
    327
    +    public static <E extends IdDto> boolean confirmForEntityDelete(JAXXObject parent, Class<E> beanClass, List<E> beanList) {
    
    328
    +        return confirmForEntityDelete(parent, beanClass, beanList, null);
    
    329
    +    }
    
    330
    +
    
    331
    +    /**
    
    332
    +     * Ouvre une demande de confirmation, avant suppression d'une entité.
    
    333
    +     *
    
    334
    +     * @param <E>          le type de l'entité à supprimer
    
    335
    +     * @param parent       le component graphique demande l'action
    
    336
    +     * @param beanClass    le tyê de l'entité à supprimer
    
    337
    +     * @param beanList     la liste d'entité à supprimer
    
    338
    +     * @param extraMessage un message supplémentaire a ajouter
    
    339
    +     * @return {@code true} si l'utilisateur a confitmé la suppression,
    
    340
    +     * {@code false} sinon.
    
    341
    +     */
    
    342
    +    public static <E extends IdDto> boolean confirmForEntityDelete(JAXXObject parent, Class<E> beanClass, List<E> beanList, String extraMessage) {
    
    343
    +        JFrame mainUI = ObserveSwingApplicationContextSupport.get().getMainUI();
    
    344
    +
    
    345
    +        if (parent == null) {
    
    346
    +            // on cherche l'ui principale
    
    347
    +            parent = (JAXXObject) mainUI;
    
    348
    +        }
    
    349
    +
    
    350
    +        ObserveSwingApplicationContextSupport.get().getMainUIModel().setBusy(true);
    
    351
    +        int response;
    
    352
    +        try {
    
    353
    +            DecoratorService decoratorService = ObserveSwingApplicationContextSupport.get().getDecoratorService();
    
    354
    +            Decorator<E> decorator = decoratorService.getDecoratorByType(beanClass);
    
    355
    +            String messageDelete;
    
    356
    +            String type = ObserveI18nDecoratorHelper.getTypeI18nKey(beanClass);
    
    357
    +            type = t(type);
    
    358
    +
    
    359
    +            StringBuilder beanStr = new StringBuilder();
    
    360
    +            // delete existing entity
    
    361
    +            for (E e : beanList) {
    
    362
    +                beanStr.append("\n\t").append(decorator.toString(e));
    
    363
    +            }
    
    364
    +            messageDelete = t("observe.message.delete.list", type, beanStr.toString());
    
    365
    +
    
    366
    +            if (extraMessage != null) {
    
    367
    +                messageDelete += '\n' + extraMessage;
    
    368
    +            }
    
    369
    +
    
    370
    +            response = askUser((Component) parent,
    
    371
    +                               t("observe.title.delete"),
    
    372
    +                               messageDelete,
    
    373
    +                               JOptionPane.WARNING_MESSAGE,
    
    374
    +                               new Object[]{t("observe.choice.confirm.delete"),
    
    375
    +                                       t("observe.choice.cancel")},
    
    376
    +                               1);
    
    377
    +        } finally {
    
    378
    +            ObserveSwingApplicationContextSupport.get().getMainUIModel().setBusy(false);
    
    379
    +        }
    
    380
    +        return response == 0;
    
    381
    +    }
    
    326 382
     
    
    327 383
         public static void handlingError(Exception e) {
    
    328 384
             handlingError(e.getMessage(), e);
    

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -2302,6 +2302,7 @@ observe.message.db.none.loaded=< No data source loaded >
    2302 2302
     observe.message.db.none.loaded.tip=No data source loaded...
    
    2303 2303
     observe.message.delete=Confirm to delete object\:\n\n    '%1$s' - '%2$s'\n
    
    2304 2304
     observe.message.delete.directory=Delete directory %1$s
    
    2305
    +observe.message.delete.list=Confirm to delete object '%1$s'\:\n%2$s\n
    
    2305 2306
     observe.message.delete.new=Confirm to delete object\:\n\n    '%1$s'\n
    
    2306 2307
     observe.message.goto.site=Go to ObServe site (%1$s)
    
    2307 2308
     observe.message.h2.server.login=Login
    

  • observe-i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -2302,6 +2302,7 @@ observe.message.db.none.loaded=No hay fuente de datos cargada
    2302 2302
     observe.message.db.none.loaded.tip=No hay fuente de datos cargada...
    
    2303 2303
     observe.message.delete=Confirmar la eliminación del objeto \:\n\n    '%1$s' - '%2$s'\n
    
    2304 2304
     observe.message.delete.directory=Eliminación del directorio %1$s
    
    2305
    +observe.message.delete.list=Confirmar la eliminación del objeto '%1$s' \:\n%2$s\n
    
    2305 2306
     observe.message.delete.new=Confirme la eliminación del objeto \:\n\n    '%1$s'\n
    
    2306 2307
     observe.message.goto.site=Acceder al sitio de d'Observe (%1$s)
    
    2307 2308
     observe.message.h2.server.login=Iniciar sesión
    

  • observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -2302,6 +2302,7 @@ observe.message.db.none.loaded=Aucune source de données chargée
    2302 2302
     observe.message.db.none.loaded.tip=Aucune source de données chargée...
    
    2303 2303
     observe.message.delete=Confirmer la suppression de l'objet \:\n\n    '%1$s' - '%2$s'\n
    
    2304 2304
     observe.message.delete.directory=Suppresion du répertoire %1$s
    
    2305
    +observe.message.delete.list=Confirmer la suppression des objets de type '%1$s' \:\n%2$s\n
    
    2305 2306
     observe.message.delete.new=Confirmer la suppression de l'objet \:\n\n    '%1$s'\n
    
    2306 2307
     observe.message.goto.site=Accéder au site d'Observe (%1$s)
    
    2307 2308
     observe.message.h2.server.login=Identifiant