View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.taxon.menu;
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 fr.ifremer.dali.dto.configuration.filter.FilterDTO;
27  import fr.ifremer.dali.ui.swing.content.manage.filter.element.menu.ApplyFilterUI;
28  import fr.ifremer.dali.ui.swing.content.manage.referential.menu.ReferentialMenuUIHandler;
29  import fr.ifremer.dali.ui.swing.util.DaliUIs;
30  
31  import java.util.List;
32  
33  /**
34   * Controlleur du menu pour la gestion des taxons au niveau National
35   */
36  public class TaxonMenuUIHandler extends ReferentialMenuUIHandler<TaxonMenuUIModel, TaxonMenuUI> {
37  
38      /** {@inheritDoc} */
39      @Override
40      public void beforeInit(final TaxonMenuUI ui) {
41          super.beforeInit(ui);
42  
43          // create model and register to the JAXX context
44          final TaxonMenuUIModel model = new TaxonMenuUIModel();
45          ui.setContextValue(model);
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public void afterInit(final TaxonMenuUI ui) {
51          super.afterInit(ui);
52  
53          // Initialiser les combobox
54          initComboBox();
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public void enableSearch(boolean enabled) {
60          getUI().getLevelCombo().setEnabled(enabled);
61          getUI().getNameEditor().setEnabled(enabled);
62          getUI().getClearButton().setEnabled(enabled);
63          getUI().getSearchButton().setEnabled(enabled);
64          getApplyFilterUI().setEnabled(enabled);
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public List<FilterDTO> getFilters() {
70          return getContext().getContextService().getAllTaxonFilters();
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public ApplyFilterUI getApplyFilterUI() {
76          return getUI().getApplyFilterUI();
77      }
78  
79      /**
80       * Initialisation des combobox
81       */
82      private void initComboBox() {
83  
84          initBeanFilterableComboBox(
85                  getUI().getLevelCombo(),
86                  getContext().getReferentialService().getTaxonomicLevels(),
87                  null);
88  
89          DaliUIs.forceComponentSize(getUI().getLevelCombo());
90      }
91  }