View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.referential;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
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.ifremer.tutti.persistence.entities.referential.Gear;
26  import fr.ifremer.tutti.persistence.entities.referential.Person;
27  import fr.ifremer.tutti.persistence.entities.referential.Species;
28  import fr.ifremer.tutti.persistence.entities.referential.Vessel;
29  import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
30  import jaxx.runtime.validator.swing.SwingValidator;
31  import org.apache.commons.logging.Log;
32  import org.apache.commons.logging.LogFactory;
33  
34  import javax.swing.JComponent;
35  import java.util.List;
36  
37  /**
38   * @author Tony Chemit - chemit@codelutin.com
39   * @since 1.0
40   */
41  public class ManageTemporaryReferentialUIHandler extends AbstractTuttiUIHandler<ManageTemporaryReferentialUIModel, ManageTemporaryReferentialUI> {
42  
43      /** Logger. */
44      private static final Log log =
45              LogFactory.getLog(ManageTemporaryReferentialUIHandler.class);
46  
47      //------------------------------------------------------------------------//
48      //-- AbstractTuttiUIHandler methods                                     --//
49      //------------------------------------------------------------------------//
50  
51      @Override
52      public void beforeInit(ManageTemporaryReferentialUI ui) {
53          super.beforeInit(ui);
54  
55          ManageTemporaryReferentialUIModel model = new ManageTemporaryReferentialUIModel();
56  
57          List<Species> temporarySpecies = getContext().getReferentialTemporarySpeciesService().getTemporarySpeciess();
58          model.setNbTemporarySpecies(temporarySpecies.size());
59  
60          List<Vessel> temporaryVessels = getContext().getReferentialTemporaryVesselService().getTemporaryVessels();
61          model.setNbTemporaryVessels(temporaryVessels.size());
62  
63          List<Gear> temporaryGears = getContext().getReferentialTemporaryGearService().getTemporaryGears();
64          model.setNbTemporaryGears(temporaryGears.size());
65  
66          List<Person> temporaryPersons = getContext().getReferentialTemporaryPersonService().getTemporaryPersons();
67          model.setNbTemporaryPersons(temporaryPersons.size());
68  
69          ui.setContextValue(model);
70      }
71  
72      @Override
73      public void afterInit(ManageTemporaryReferentialUI ui) {
74  
75          initUI(ui);
76  
77      }
78  
79      @Override
80      protected JComponent getComponentToFocus() {
81          return null;
82      }
83  
84      @Override
85      public void onCloseUI() {
86          if (log.isDebugEnabled()) {
87              log.debug("closing: " + ui);
88          }
89      }
90  
91      @Override
92      public SwingValidator<ManageTemporaryReferentialUIModel> getValidator() {
93          return null;
94      }
95  
96  }