Coverage Report - org.jtheque.films.view.impl.frames.VideoFileView
 
Classes in this File Line Coverage Branch Coverage Complexity
VideoFileView
0 %
0/20
N/A
1
 
 1  
 package org.jtheque.films.view.impl.frames;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.beans.IBeansManager;
 5  
 import org.jtheque.core.managers.error.JThequeError;
 6  
 import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel;
 7  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView;
 8  
 import org.jtheque.core.utils.ui.PanelBuilder;
 9  
 import org.jtheque.films.persistence.od.able.Film;
 10  
 import org.jtheque.films.services.able.IFilmsService;
 11  
 import org.jtheque.films.view.able.IVideoFileView;
 12  
 import org.jtheque.films.view.impl.actions.CloseViewAction;
 13  
 import org.jtheque.films.view.impl.actions.video.file.AcValidateVideoFileView;
 14  
 import org.jtheque.primary.view.impl.models.DataContainerCachedComboBoxModel;
 15  
 import org.jtheque.utils.ui.GridBagUtils;
 16  
 import org.jtheque.utils.ui.SwingUtils;
 17  
 
 18  
 import javax.swing.Action;
 19  
 import javax.swing.JComponent;
 20  
 import java.awt.Container;
 21  
 import java.awt.Frame;
 22  
 import java.util.Collection;
 23  
 
 24  
 /*
 25  
  * This file is part of JTheque.
 26  
  *
 27  
  * JTheque is free software: you can redistribute it and/or modify
 28  
  * it under the terms of the GNU General Public License as published by
 29  
  * the Free Software Foundation, either version 3 of the License.
 30  
  *
 31  
  * JTheque is distributed in the hope that it will be useful,
 32  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 33  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 34  
  * GNU General Public License for more details.
 35  
  *
 36  
  * You should have received a copy of the GNU General Public License
 37  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 38  
  */
 39  
 
 40  
 /**
 41  
  * @author Baptiste Wicht
 42  
  */
 43  
 public final class VideoFileView extends SwingDialogView implements IVideoFileView {
 44  
     private DataContainerCachedComboBoxModel<Film> model;
 45  
     private FileChooserPanel fieldFile;
 46  
 
 47  
     /**
 48  
      * Construct a new VideoFileView modal to his parent view.
 49  
      *
 50  
      * @param parent         The parent frame.
 51  
      */
 52  
     public VideoFileView(Frame parent) {
 53  0
         super(parent);
 54  
 
 55  0
         setContentPane(buildContentPane());
 56  0
         pack();
 57  
 
 58  0
         setLocationRelativeTo(getOwner());
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Build the content pane.
 63  
      *
 64  
      * @return The builded content pane.
 65  
      */
 66  
     private Container buildContentPane() {
 67  0
         PanelBuilder builder = new PanelBuilder();
 68  
 
 69  0
         Action validateAction = new AcValidateVideoFileView();
 70  
         
 71  0
         fieldFile = new FileChooserPanel();
 72  0
         fieldFile.setTextKey("video.file.view.file");
 73  0
         SwingUtils.addFieldValidateAction(fieldFile, validateAction);
 74  
 
 75  0
         builder.add(fieldFile, builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL, 2, 1));
 76  
 
 77  0
         builder.addI18nLabel("video.file.view.film", builder.gbcSet(0, 1));
 78  
 
 79  0
         model = new DataContainerCachedComboBoxModel<Film>(Managers.getManager(IBeansManager.class).<IFilmsService>getBean("filmsService"));
 80  
 
 81  0
         JComponent combo = builder.addComboBox(model, builder.gbcSet(1, 1));
 82  0
         SwingUtils.addFieldValidateAction(combo, validateAction);
 83  
 
 84  0
         builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL, 2, 1), 
 85  
                 validateAction, new CloseViewAction("generic.view.actions.cancel", this));
 86  
 
 87  0
         return builder.getPanel();
 88  
     }
 89  
 
 90  
     @Override
 91  
     protected void validate(Collection<JThequeError> errors) {
 92  0
     }
 93  
 
 94  
     @Override
 95  
     public String getFilePath() {
 96  0
         return fieldFile.getFilePath();
 97  
     }
 98  
 
 99  
     @Override
 100  
     public Film getFilm() {
 101  0
         return model.getSelectedData();
 102  
     }
 103  
 }