Coverage Report - org.jtheque.films.view.impl.frames.ExportView
 
Classes in this File Line Coverage Branch Coverage Complexity
ExportView
0 %
0/25
0 %
0/2
1.143
 
 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.error.JThequeError;
 20  
 import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel;
 21  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView;
 22  
 import org.jtheque.core.utils.ui.Borders;
 23  
 import org.jtheque.core.utils.ui.PanelBuilder;
 24  
 import org.jtheque.core.utils.ui.ValidationUtils;
 25  
 import org.jtheque.films.persistence.od.able.Film;
 26  
 import org.jtheque.films.services.impl.utils.search.Searcher;
 27  
 import org.jtheque.films.view.able.IExportView;
 28  
 import org.jtheque.films.view.impl.actions.CloseViewAction;
 29  
 import org.jtheque.films.view.impl.actions.file.AcValidateExportView;
 30  
 import org.jtheque.films.view.impl.panels.search.JPanelFilmSearch;
 31  
 import org.jtheque.utils.io.SimpleFilter;
 32  
 import org.jtheque.utils.ui.GridBagUtils;
 33  
 
 34  
 import java.awt.Color;
 35  
 import java.awt.Container;
 36  
 import java.awt.Frame;
 37  
 import java.util.Collection;
 38  
 
 39  
 /**
 40  
  * The frame used to define the options of an export.
 41  
  *
 42  
  * @author Baptiste Wicht
 43  
  */
 44  
 public final class ExportView extends SwingDialogView implements IExportView {
 45  
     private static final long serialVersionUID = -1591189533123010866L;
 46  
 
 47  
     private FileChooserPanel chooser;
 48  
     private JPanelFilmSearch searchPanel;
 49  
 
 50  
     /**
 51  
      * Construct a new <code>JFrameExport</code>.
 52  
      *
 53  
      * @param parent The parent frame.
 54  
      */
 55  
     public ExportView(Frame parent) {
 56  0
         super(parent);
 57  
         
 58  0
         build();
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Build the view.
 63  
      */
 64  
     private void build() {
 65  0
         setTitleKey("export.view.title");
 66  0
         setContentPane(buildContentPane());
 67  
 
 68  0
         pack();
 69  0
         setLocationRelativeTo(getOwner());
 70  0
     }
 71  
 
 72  
     /**
 73  
      * Return the content pane initialized.
 74  
      *
 75  
      * @return The content pane.
 76  
      */
 77  
     private Container buildContentPane() {
 78  0
         PanelBuilder builder = new PanelBuilder();
 79  
 
 80  0
         chooser = new FileChooserPanel();
 81  0
         chooser.setTextKey("export.view.filePath");
 82  0
         chooser.setBackground(Color.white);
 83  0
         builder.add(chooser, builder.gbcSet(0, 0));
 84  
 
 85  0
         searchPanel = new JPanelFilmSearch();
 86  0
         searchPanel.setBorder(Borders.createTitledBorder("export.view.search"));
 87  0
         builder.add(searchPanel, builder.gbcSet(0, 1, GridBagUtils.BOTH));
 88  
 
 89  0
         builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL), 
 90  
                 new AcValidateExportView(), new CloseViewAction("generic.view.actions.cancel", this));
 91  
 
 92  0
         return builder.getPanel();
 93  
     }
 94  
 
 95  
     @Override
 96  
     public Searcher<Film> getSearcher() {
 97  0
         return searchPanel.getSearcher();
 98  
     }
 99  
 
 100  
     @Override
 101  
     public String getFilePath() {
 102  0
         return chooser.getFilePath();
 103  
     }
 104  
 
 105  
     @Override
 106  
     public void sendMessage(String message, Object value) {
 107  0
         if ("filter".equals(message)) {
 108  0
             chooser.setFileFilter((SimpleFilter) value);
 109  
         }
 110  0
     }
 111  
 
 112  
     @Override
 113  
     protected void validate(Collection<JThequeError> errors) {
 114  0
         ValidationUtils.rejectIfEmpty(getFilePath(), "export.view.filePath", errors);
 115  0
     }
 116  
 }