View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.referential.department.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  import org.apache.commons.logging.Log;
32  import org.apache.commons.logging.LogFactory;
33  
34  import java.util.List;
35  
36  /**
37   * Controlleur du menu pour la gestion des lieux au niveau National
38   */
39  public class DepartmentMenuUIHandler extends ReferentialMenuUIHandler<DepartmentMenuUIModel, DepartmentMenuUI> {
40  
41      /**
42       * Logger.
43       */
44      private static final Log LOG = LogFactory.getLog(DepartmentMenuUIHandler.class);
45      
46      /** {@inheritDoc} */
47      @Override
48      public void beforeInit(final DepartmentMenuUI ui) {
49          super.beforeInit(ui);
50          
51          // create model and register to the JAXX context
52          final DepartmentMenuUIModel model = new DepartmentMenuUIModel();
53          ui.setContextValue(model);
54      }
55  
56      /** {@inheritDoc} */
57      @Override
58      public void afterInit(final DepartmentMenuUI ui) {
59          super.afterInit(ui);
60  
61          // Initialiser les combobox
62          initComboBox();
63  
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public void enableSearch(boolean enabled) {
69          getUI().getCodeEditor().setEnabled(enabled);
70          getUI().getNameEditor().setEnabled(enabled);
71          getUI().getParentCombo().setEnabled(enabled);
72          getUI().getStatusCombo().setEnabled(enabled);
73          getUI().getClearButton().setEnabled(enabled);
74          getUI().getSearchButton().setEnabled(enabled);
75          getApplyFilterUI().setEnabled(enabled);
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public List<FilterDTO> getFilters() {
81          return getContext().getContextService().getAllDepartmentFilters();
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public ApplyFilterUI getApplyFilterUI() {
87          return getUI().getApplyFilterUI();
88      }
89  
90      /**
91  	 * Initialisation des combobox
92  	 */
93  	private void initComboBox() {
94  		
95  		initBeanFilterableComboBox(
96  				getUI().getParentCombo(), 
97  				getContext().getReferentialService().getDepartments(StatusFilter.ALL),
98  				null);
99  		
100 		initBeanFilterableComboBox(getUI().getStatusCombo(), 
101 				getContext().getReferentialService().getStatus(StatusFilter.ALL),
102 				null);
103 		
104 				
105 		// Dimension forcee sur la combobox
106         DaliUIs.forceComponentSize(getUI().getParentCombo());
107         DaliUIs.forceComponentSize(getUI().getStatusCombo());
108         
109 	}
110 
111 }