View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.pmfm.parameter.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.decorator.DecoratorService;
27  import fr.ifremer.dali.dto.referential.pmfm.ParameterDTO;
28  import fr.ifremer.dali.service.StatusFilter;
29  import fr.ifremer.dali.ui.swing.util.AbstractDaliUIHandler;
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 Parameters au niveau local
36   */
37  public class ManageParametersMenuUIHandler extends AbstractDaliUIHandler<ManageParametersMenuUIModel, ManageParametersMenuUI> {
38  
39      /** {@inheritDoc} */
40      @Override
41      public void beforeInit(final ManageParametersMenuUI ui) {
42          super.beforeInit(ui);
43  
44          // create model and register to the JAXX context
45          final ManageParametersMenuUIModel model = new ManageParametersMenuUIModel();
46          ui.setContextValue(model);
47      }
48  
49      /** {@inheritDoc} */
50      @Override
51      public void afterInit(final ManageParametersMenuUI ui) {
52          initUI(ui);
53  
54          // Initialiser les combobox
55          initComboBox();
56      }
57  
58  	/**
59  	 * Initialisation des combobox
60  	 */
61  	private void initComboBox() {
62  
63          List<ParameterDTO> parameters = getContext().getReferentialService().getParameters(StatusFilter.ALL);
64  
65  		initBeanFilterableComboBox(
66  				getUI().getLabelCombo(),
67                  parameters,
68  				null,
69                  DecoratorService.NAME);
70  		
71  		initBeanFilterableComboBox(
72  				getUI().getCodeCombo(),
73                  parameters,
74  				null,
75                  null, // {code] is default
76                  DecoratorService.NAME); // Transcribed name as tooltip (Mantis #47110)
77  		
78  		initBeanFilterableComboBox(getUI().getStatusCombo(),
79  				getContext().getReferentialService().getStatus(StatusFilter.ALL),
80  				null);
81  		
82          initBeanFilterableComboBox(getUI().getParameterGroupCombo(), 
83  				getContext().getReferentialService().getParameterGroup(StatusFilter.ACTIVE),
84  				null);
85  
86          DaliUIs.forceComponentSize(getUI().getLabelCombo());
87          DaliUIs.forceComponentSize(getUI().getCodeCombo());
88          DaliUIs.forceComponentSize(getUI().getStatusCombo());
89          DaliUIs.forceComponentSize(getUI().getParameterGroupCombo());
90  	}
91  
92  }