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