View Javadoc
1   package fr.ifremer.dali.ui.swing.content.home;
2   
3   /*
4    * #%L
5    * Dali :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import com.google.common.collect.ImmutableList;
27  import fr.ifremer.dali.ui.swing.action.AbstractCheckModelAction;
28  import fr.ifremer.dali.ui.swing.action.AbstractDaliSaveAction;
29  import fr.ifremer.quadrige3.ui.swing.model.AbstractBeanUIModel;
30  import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler;
31  
32  import java.util.List;
33  
34  /**
35   * Action permettant d effacer la recherche les obervations.
36   */
37  public class ClearAction extends AbstractCheckModelAction<HomeUIModel, HomeUI, HomeUIHandler> {
38  
39      /**
40       * Constructor.
41       *
42       * @param handler Controller
43       */
44      public ClearAction(final HomeUIHandler handler) {
45          super(handler, false);
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public void doAction() throws Exception {
51  
52          // Delete filter model
53          getModel().setCampaign(null);
54          getModel().setProgram(null);
55          getModel().setLocation(null);
56          getModel().setSearchDate(null);
57          getModel().setStartDate(null);
58          getModel().setEndDate(null);
59          getUI().getEndDateEditor().setEnabled(false);
60          getUI().getEndDateEditor().setVisible(false);
61          getUI().getAndLabel().setVisible(false);
62          getModel().setState(null);
63          getModel().setSynchronizationStatus(null);
64          getModel().setName(null);
65          getModel().setComment(null);
66  
67          // Clear result
68          getModel().getSurveysTableUIModel().setBeans(null);
69  
70          getUI().getProgramCombo().requestFocus();
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      protected Class<? extends AbstractDaliSaveAction> getSaveActionClass() {
76          return SaveAction.class;
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      protected boolean isModelModify() {
82          return getModel().isModify();
83      }
84  
85      /** {@inheritDoc} */
86      @Override
87      protected void setModelModify(boolean modelModify) {
88          getModel().setModify(modelModify);
89      }
90  
91      /** {@inheritDoc} */
92      @Override
93      protected boolean isModelValid() {
94          return getModel().isValid();
95      }
96  
97      /** {@inheritDoc} */
98      @Override
99      protected AbstractApplicationUIHandler<?, ?> getSaveHandler() {
100         return getHandler();
101     }
102 
103     @Override
104     protected List<AbstractBeanUIModel> getOtherModelsToModify() {
105         return ImmutableList.of(
106                 getModel().getSurveysTableUIModel(),
107                 getModel().getOperationsTableUIModel()
108         );
109     }
110 
111 }