Coverage Report - org.jtheque.films.view.impl.frames.CoverView
 
Classes in this File Line Coverage Branch Coverage Complexity
CoverView
0 %
0/27
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.jdesktop.swingx.JXImagePanel;
 20  
 import org.jtheque.core.managers.error.JThequeError;
 21  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView;
 22  
 import org.jtheque.core.utils.ui.PanelBuilder;
 23  
 import org.jtheque.films.persistence.od.able.Film;
 24  
 import org.jtheque.films.services.able.ICoverService;
 25  
 import org.jtheque.films.services.able.IFilmsService;
 26  
 import org.jtheque.films.services.impl.utils.cover.Format;
 27  
 import org.jtheque.films.view.able.ICoverView;
 28  
 import org.jtheque.films.view.impl.actions.CloseViewAction;
 29  
 import org.jtheque.films.view.impl.actions.cover.AcExportCover;
 30  
 import org.jtheque.films.view.impl.actions.cover.AcPrintCover;
 31  
 import org.jtheque.films.view.impl.actions.cover.AcUpdateCover;
 32  
 import org.jtheque.films.view.impl.models.combo.CoverFormatComboBoxModel;
 33  
 import org.jtheque.primary.view.impl.models.DataContainerCachedComboBoxModel;
 34  
 import org.jtheque.utils.ui.GridBagUtils;
 35  
 
 36  
 import javax.annotation.PostConstruct;
 37  
 import javax.annotation.Resource;
 38  
 import java.awt.Color;
 39  
 import java.awt.Container;
 40  
 import java.awt.Frame;
 41  
 import java.awt.Image;
 42  
 import java.util.Collection;
 43  
 
 44  
 /**
 45  
  * A cover view implementation.
 46  
  *
 47  
  * @author Baptiste Wicht
 48  
  */
 49  
 public final class CoverView extends SwingDialogView implements ICoverView {
 50  
     @Resource
 51  
     private IFilmsService filmsService;
 52  
 
 53  
     @Resource
 54  
     private ICoverService coverService;
 55  
 
 56  
     private DataContainerCachedComboBoxModel<Film> modelFilms;
 57  
     private CoverFormatComboBoxModel modelFormats;
 58  
     private JXImagePanel viewer;
 59  
 
 60  
     /**
 61  
      * Construct a new CoverView.
 62  
      *
 63  
      * @param frame        The parent frame.
 64  
      */
 65  
     public CoverView(Frame frame) {
 66  0
         super(frame);
 67  0
     }
 68  
 
 69  
     /**
 70  
      * Build the view.
 71  
      */
 72  
     @PostConstruct
 73  
     private void build() {
 74  0
         setTitleKey("cover.view.title");
 75  0
         setContentPane(buildContentPane());
 76  0
         pack();
 77  
 
 78  0
         setLocationRelativeTo(getOwner());
 79  0
     }
 80  
 
 81  
     /**
 82  
      * Build the content pane.
 83  
      *
 84  
      * @return The builded content pane.
 85  
      */
 86  
     private Container buildContentPane() {
 87  0
         PanelBuilder builder = new PanelBuilder();
 88  
 
 89  0
         builder.addI18nLabel("cover.view.film", builder.gbcSet(0, 0));
 90  
 
 91  0
         modelFilms = new DataContainerCachedComboBoxModel<Film>(filmsService);
 92  0
         modelFilms.selectFirst();
 93  
 
 94  0
         builder.addComboBox(modelFilms, builder.gbcSet(1, 0));
 95  
 
 96  0
         builder.addI18nLabel("cover.view.format", builder.gbcSet(0, 1));
 97  
 
 98  0
         modelFormats = new CoverFormatComboBoxModel();
 99  0
         modelFormats.selectFirst();
 100  
 
 101  0
         builder.addComboBox(modelFormats, builder.gbcSet(1, 1));
 102  
 
 103  0
         viewer = new JXImagePanel();
 104  0
         viewer.setBackground(Color.white);
 105  0
         viewer.setImage(coverService.getReportImage(modelFilms.getSelectedData(), modelFormats.getSelectedItem()));
 106  
 
 107  0
         builder.add(viewer, builder.gbcSet(0, 2, GridBagUtils.BOTH, 2, 1));
 108  
 
 109  0
         builder.addButtonBar(builder.gbcSet(0, 3, GridBagUtils.HORIZONTAL, 2, 1),
 110  
                 new AcUpdateCover(), new AcPrintCover(), new AcExportCover(), new CloseViewAction("generic.view.actions.cancel", this));
 111  
 
 112  0
         return builder.getPanel();
 113  
     }
 114  
 
 115  
     @Override
 116  
     public void display(Image image) {
 117  0
         viewer.setImage(image);
 118  0
     }
 119  
 
 120  
     @Override
 121  
     public Film getSelectedFilm() {
 122  0
         return modelFilms.getSelectedData();
 123  
     }
 124  
 
 125  
     @Override
 126  
     public Format getSelectedFormat() {
 127  0
         return modelFormats.getSelectedItem();
 128  
     }
 129  
 
 130  
     @Override
 131  
     protected void validate(Collection<JThequeError> errors) {
 132  0
     }
 133  
 }