Coverage Report - org.jtheque.films.view.impl.panels.config.JPanelConfigAuto
 
Classes in this File Line Coverage Branch Coverage Complexity
JPanelConfigAuto
0 %
0/17
N/A
1
 
 1  
 package org.jtheque.films.view.impl.panels.config;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.managers.beans.IBeansManager;
 21  
 import org.jtheque.core.managers.error.JThequeError;
 22  
 import org.jtheque.core.managers.language.ILanguageManager;
 23  
 import org.jtheque.core.managers.view.impl.components.config.ConfigTabComponent;
 24  
 import org.jtheque.core.utils.ui.PanelBuilder;
 25  
 import org.jtheque.core.utils.ui.ValidationUtils;
 26  
 import org.jtheque.films.IFilmsModule;
 27  
 import org.jtheque.films.services.impl.utils.config.Configuration;
 28  
 import org.jtheque.utils.ui.GridBagUtils;
 29  
 
 30  
 import javax.swing.JComponent;
 31  
 import javax.swing.JPanel;
 32  
 import javax.swing.JTextField;
 33  
 import java.util.Collection;
 34  
 
 35  
 /**
 36  
  * A config panel to configure the automatic add of film.
 37  
  *
 38  
  * @author Baptiste Wicht
 39  
  */
 40  
 public final class JPanelConfigAuto extends JPanel implements ConfigTabComponent {
 41  
     private JTextField fieldNumberOfActors;
 42  
 
 43  
     /**
 44  
      * Construct a new JPanelConfigAuto. 
 45  
      */
 46  
     public JPanelConfigAuto() {
 47  0
         super();
 48  
 
 49  0
         build();
 50  0
         cancel();
 51  0
     }
 52  
 
 53  
     @Override
 54  
     public String getTitle() {
 55  0
         return Managers.getManager(ILanguageManager.class).getMessage("config.view.tab.auto");
 56  
     }
 57  
 
 58  
     /**
 59  
      * Build the view.
 60  
      */
 61  
     private void build() {
 62  0
         PanelBuilder builder = new PanelBuilder(this);
 63  
 
 64  0
         builder.addI18nLabel("config.auto.actors",
 65  
                 builder.gbcSet(0, 0, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING));
 66  
 
 67  0
         fieldNumberOfActors = builder.add(new JTextField(4),
 68  
                 builder.gbcSet(1, 0, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 1.0));
 69  0
     }
 70  
 
 71  
     @Override
 72  
     public void apply() {
 73  0
         getConfig().setNumberOfActors(Integer.parseInt(fieldNumberOfActors.getText()));
 74  0
     }
 75  
 
 76  
     @Override
 77  
     public void cancel() {
 78  0
         fieldNumberOfActors.setText(Integer.toString(getConfig().getNumberOfActors()));
 79  0
     }
 80  
 
 81  
     @Override
 82  
     public void validate(Collection<JThequeError> errors) {
 83  0
         ValidationUtils.rejectIfNotNumerical(fieldNumberOfActors.getText(), "config.auto.actors", errors);
 84  0
     }
 85  
 
 86  
     @Override
 87  
     public JComponent getComponent() {
 88  0
         return this;
 89  
     }
 90  
 
 91  
     /**
 92  
      * Return the configuration of the films module.
 93  
      *
 94  
      * @return The configuration of the films module.
 95  
      */
 96  
     private static Configuration getConfig() {
 97  0
         return Managers.getManager(IBeansManager.class).<IFilmsModule>getBean("filmsModule").getConfiguration();
 98  
     }
 99  
 }