Coverage Report - org.jtheque.films.view.impl.frames.LendFilmView
 
Classes in this File Line Coverage Branch Coverage Complexity
LendFilmView
0 %
0/20
N/A
1
 
 1  
 package org.jtheque.films.view.impl.frames;
 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.view.impl.frame.abstraction.SwingDialogView;
 23  
 import org.jtheque.core.utils.ui.PanelBuilder;
 24  
 import org.jtheque.films.persistence.od.able.Film;
 25  
 import org.jtheque.films.services.able.IFilmsService;
 26  
 import org.jtheque.films.view.able.ILendFilmView;
 27  
 import org.jtheque.films.view.impl.actions.CloseViewAction;
 28  
 import org.jtheque.films.view.impl.actions.lend.AcValidateLendView;
 29  
 import org.jtheque.primary.od.able.Person;
 30  
 import org.jtheque.primary.services.able.IBorrowersService;
 31  
 import org.jtheque.primary.view.impl.models.DataContainerCachedComboBoxModel;
 32  
 import org.jtheque.utils.ui.GridBagUtils;
 33  
 
 34  
 import javax.annotation.PostConstruct;
 35  
 import javax.annotation.Resource;
 36  
 import javax.swing.Action;
 37  
 import java.awt.Container;
 38  
 import java.awt.Frame;
 39  
 import java.util.Collection;
 40  
 
 41  
 /**
 42  
  * The JFrame for lend a film.
 43  
  *
 44  
  * @author Baptiste Wicht
 45  
  */
 46  
 public final class LendFilmView extends SwingDialogView implements ILendFilmView {
 47  
     private static final long serialVersionUID = 2370792054850689428L;
 48  
 
 49  
     private DataContainerCachedComboBoxModel<Film> modelFilms;
 50  
     private DataContainerCachedComboBoxModel<Person> modelBorrowers;
 51  
 
 52  
     @Resource
 53  
     private IBorrowersService borrowersService;
 54  
 
 55  
     @Resource
 56  
     private IFilmsService filmsService;
 57  
 
 58  
     /**
 59  
      * Construct a new <code>JFrameLendFilm</code> and initialize the frame.
 60  
      *
 61  
      * @param parent The parent frame.
 62  
      */
 63  
     public LendFilmView(Frame parent) {
 64  0
         super(parent);
 65  0
     }
 66  
 
 67  
     /**
 68  
      * Build the view.
 69  
      */
 70  
     @PostConstruct
 71  
     private void build() {
 72  0
         setContentPane(buildContentPane());
 73  0
         setTitleKey("lend.view.title");
 74  0
         pack();
 75  
 
 76  0
         setLocationRelativeTo(getOwner());
 77  0
     }
 78  
 
 79  
     /**
 80  
      * Build the content pane of the frame.
 81  
      *
 82  
      * @return The content pane.
 83  
      */
 84  
     private Container buildContentPane() {
 85  0
         PanelBuilder builder = new PanelBuilder();
 86  
 
 87  0
         builder.addI18nLabel("lend.view.film", builder.gbcSet(0, 0));
 88  
 
 89  0
         modelFilms = new DataContainerCachedComboBoxModel<Film>(filmsService);
 90  
 
 91  0
         builder.addComboBox(modelFilms, builder.gbcSet(1, 0, GridBagUtils.HORIZONTAL, 2, 1));
 92  
 
 93  0
         builder.addI18nLabel("lend.view.borrower", builder.gbcSet(0, 1));
 94  
 
 95  0
         modelBorrowers = new DataContainerCachedComboBoxModel<Person>(borrowersService);
 96  
 
 97  0
         builder.addComboBox(modelBorrowers, builder.gbcSet(1, 1));
 98  
 
 99  0
         builder.addButton(Managers.getManager(IBeansManager.class).<Action>getBean("newBorrowerAction"), builder.gbcSet(2, 1));
 100  
 
 101  0
         builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL, 3, 1), 
 102  
                 new AcValidateLendView(), new CloseViewAction("generic.view.actions.cancel", this));
 103  
 
 104  0
         return builder.getPanel();
 105  
     }
 106  
 
 107  
     @Override
 108  
     public Film getSelectedFilm() {
 109  0
         return modelFilms.getSelectedData();
 110  
     }
 111  
 
 112  
     @Override
 113  
     public Person getSelectedBorrower() {
 114  0
         return modelBorrowers.getSelectedData();
 115  
     }
 116  
 
 117  
     @Override
 118  
     protected void validate(Collection<JThequeError> errors) {
 119  0
     }
 120  
 }