Coverage Report - org.jtheque.films.view.impl.frames.VideoView
 
Classes in this File Line Coverage Branch Coverage Complexity
VideoView
0 %
0/20
N/A
1
 
 1  
 package org.jtheque.films.view.impl.frames;
 2  
 
 3  
 import org.jtheque.core.managers.error.JThequeError;
 4  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView;
 5  
 import org.jtheque.core.utils.ui.PanelBuilder;
 6  
 import org.jtheque.films.services.impl.utils.VideoFile;
 7  
 import org.jtheque.films.view.able.IVideoView;
 8  
 import org.jtheque.films.view.impl.actions.CloseViewAction;
 9  
 import org.jtheque.films.view.impl.actions.video.AcNewVideoFile;
 10  
 import org.jtheque.films.view.impl.actions.video.AcOpenVideoFile;
 11  
 import org.jtheque.films.view.impl.actions.video.AcRefreshVideoView;
 12  
 import org.jtheque.films.view.impl.models.list.VideoListModel;
 13  
 import org.jtheque.films.view.impl.renderers.VideoListRenderer;
 14  
 import org.jtheque.utils.ui.GridBagUtils;
 15  
 
 16  
 import javax.swing.JList;
 17  
 import javax.swing.ListSelectionModel;
 18  
 import java.awt.Container;
 19  
 import java.awt.Frame;
 20  
 import java.util.Collection;
 21  
 
 22  
 /*
 23  
  * This file is part of JTheque.
 24  
  *
 25  
  * JTheque is free software: you can redistribute it and/or modify
 26  
  * it under the terms of the GNU General Public License as published by
 27  
  * the Free Software Foundation, either version 3 of the License.
 28  
  *
 29  
  * JTheque is distributed in the hope that it will be useful,
 30  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 31  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 32  
  * GNU General Public License for more details.
 33  
  *
 34  
  * You should have received a copy of the GNU General Public License
 35  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 36  
  */
 37  
 
 38  
 /**
 39  
  * A video view implementation.
 40  
  *
 41  
  * @author Baptiste Wicht
 42  
  */
 43  
 public final class VideoView extends SwingDialogView implements IVideoView {
 44  
     private JList list;
 45  
 
 46  
     private final VideoListModel model;
 47  
 
 48  
     /**
 49  
      * Construct a new VideoView.
 50  
      *
 51  
      * @param parent The parent frame.
 52  
      */
 53  
     public VideoView(Frame parent) {
 54  0
         super(parent);
 55  
         
 56  0
         model = new VideoListModel();
 57  
 
 58  0
         setTitleKey("video.view.title");
 59  0
         setContentPane(buildContentPane());
 60  0
         pack();
 61  
 
 62  0
         setLocationRelativeTo(getOwner());
 63  0
     }
 64  
     
 65  
     /**
 66  
      * Build the content pane.
 67  
      *
 68  
      * @return The builded content pane.
 69  
      */
 70  
     private Container buildContentPane() {
 71  0
         PanelBuilder builder = new PanelBuilder();
 72  
 
 73  0
         list = new JList();
 74  0
         list.setModel(model);
 75  0
         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 76  0
         list.setCellRenderer(new VideoListRenderer());
 77  0
         list.setVisibleRowCount(4);
 78  
 
 79  0
         builder.addScrolled(list, builder.gbcSet(0, 0, GridBagUtils.BOTH, GridBagUtils.ABOVE_BASELINE_LEADING, 0, -1, 1.0, 1.0));
 80  
 
 81  0
         builder.addButtonBar(builder.gbcSet(0, 1, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 0.0),
 82  
                 new AcRefreshVideoView(), new AcOpenVideoFile(), new AcNewVideoFile(), new CloseViewAction("generic.view.actions.cancel", this));
 83  
 
 84  0
         return builder.getPanel();
 85  
     }
 86  
 
 87  
     @Override
 88  
     protected void validate(Collection<JThequeError> errors) {
 89  0
     }
 90  
 
 91  
     @Override
 92  
     public VideoFile getSelectedFile() {
 93  0
         return (VideoFile) list.getSelectedValue();
 94  
     }
 95  
 
 96  
     @Override
 97  
     public void refreshList() {
 98  0
         model.refresh();
 99  0
     }
 100  
 }