Coverage Report - org.jtheque.films.view.impl.panels.JPanelInfosPerso
 
Classes in this File Line Coverage Branch Coverage Complexity
JPanelInfosPerso
0 %
0/27
N/A
1
 
 1  
 package org.jtheque.films.view.impl.panels;
 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.error.JThequeError;
 20  
 import org.jtheque.core.utils.ui.PanelBuilder;
 21  
 import org.jtheque.core.utils.ui.constraints.ConstraintManager;
 22  
 import org.jtheque.films.persistence.od.able.Film;
 23  
 import org.jtheque.films.utils.Constants.Properties;
 24  
 import org.jtheque.films.view.able.IInfosPersoView;
 25  
 import org.jtheque.films.view.impl.fb.IFilmFormBean;
 26  
 import org.jtheque.primary.od.able.Notable;
 27  
 import org.jtheque.primary.view.impl.listeners.ObjectChangedEvent;
 28  
 import org.jtheque.primary.view.impl.models.NotesComboBoxModel;
 29  
 import org.jtheque.primary.view.impl.renderers.NoteComboRenderer;
 30  
 import org.jtheque.utils.ui.GridBagUtils;
 31  
 
 32  
 import javax.swing.JComboBox;
 33  
 import javax.swing.JComponent;
 34  
 import javax.swing.JPanel;
 35  
 import javax.swing.JTextArea;
 36  
 import javax.swing.ListCellRenderer;
 37  
 import java.util.Collection;
 38  
 
 39  
 /**
 40  
  * Panel to add personal informations on a film.
 41  
  *
 42  
  * @author Baptiste Wicht
 43  
  */
 44  
 public final class JPanelInfosPerso extends JPanel implements IInfosPersoView {
 45  
     private final NotesComboBoxModel modelNote;
 46  
     private final JComboBox comboNote;
 47  
     private final JTextArea areaComment;
 48  
 
 49  
     /**
 50  
      * Construct a new JPanelInfosPerso. 
 51  
      */
 52  
     public JPanelInfosPerso(){
 53  0
         super();
 54  
 
 55  0
         PanelBuilder builder = new PanelBuilder(this);
 56  
 
 57  0
         builder.addI18nLabel(Properties.Film.NOTE, builder.gbcSet(0, 0));
 58  
 
 59  0
         ListCellRenderer noteRenderer = new NoteComboRenderer();
 60  
 
 61  0
         modelNote = new NotesComboBoxModel();
 62  
 
 63  0
         comboNote = builder.addComboBox(modelNote, builder.gbcSet(1, 0));
 64  0
         comboNote.setEnabled(false);
 65  0
         comboNote.setRenderer(noteRenderer);
 66  
 
 67  0
         builder.addI18nLabel(Properties.Film.COMMENT, builder.gbcSet(0, 1));
 68  
 
 69  0
         areaComment = new JTextArea();
 70  0
         areaComment.setEnabled(false);
 71  
 
 72  0
         builder.addScrolled(areaComment, builder.gbcSet(0, 2, GridBagUtils.BOTH, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 1.0));
 73  0
     }
 74  
 
 75  
     @Override
 76  
     public void objectChanged(ObjectChangedEvent event) {
 77  0
         comboNote.setSelectedItem(((Notable) event.getObject()).getNote());
 78  0
         areaComment.setText(((Film) event.getObject()).getComment());
 79  0
     }
 80  
 
 81  
     /**
 82  
      * Fill the form bean.
 83  
      *
 84  
      * @param fb The form bean to fill.
 85  
      */
 86  
     @Override
 87  
     public void fillFilm(IFilmFormBean fb) {
 88  0
         fb.setComment(areaComment.getText());
 89  0
         fb.setNote(modelNote.getSelectedNote());
 90  0
     }
 91  
 
 92  
     @Override
 93  
     public void setEnabled(boolean enabled) {
 94  0
         areaComment.setEnabled(enabled);
 95  0
         comboNote.setEnabled(enabled);
 96  
 
 97  0
         super.setEnabled(enabled);
 98  0
     }
 99  
 
 100  
     /**
 101  
      * Validate the view.
 102  
      *
 103  
      * @param errors The errors list to fill.
 104  
      */
 105  
     @Override
 106  
     public void validate(Collection<JThequeError> errors) {
 107  0
         ConstraintManager.validate(Properties.Film.COMMENT, areaComment.getText(), errors);
 108  0
         ConstraintManager.validate(Properties.Film.NOTE, modelNote.getSelectedNote(), errors);
 109  0
     }
 110  
 
 111  
     @Override
 112  
     public JComponent getImpl() {
 113  0
         return this;
 114  
     }
 115  
 }