Coverage Report - org.jtheque.films.view.impl.actions.auto.add.AcValidateAutoAddView
 
Classes in this File Line Coverage Branch Coverage Complexity
AcValidateAutoAddView
0 %
0/8
0 %
0/2
1.167
AcValidateAutoAddView$1
0 %
0/4
N/A
1.167
AcValidateAutoAddView$AutoAddRunnable
0 %
0/7
N/A
1.167
AcValidateAutoAddView$AutoAddRunnable$1
0 %
0/4
N/A
1.167
 
 1  
 package org.jtheque.films.view.impl.actions.auto.add;
 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.Managers;
 20  
 import org.jtheque.core.managers.beans.IBeansManager;
 21  
 import org.jtheque.core.managers.view.able.IViewManager;
 22  
 import org.jtheque.core.managers.view.edt.SimpleTask;
 23  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 24  
 import org.jtheque.films.controllers.able.IAutoAddController;
 25  
 import org.jtheque.films.view.able.IAutoAddView;
 26  
 
 27  
 import javax.annotation.Resource;
 28  
 import java.awt.event.ActionEvent;
 29  
 
 30  
 /**
 31  
  * Action to validate the auto add view.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  0
 public final class AcValidateAutoAddView extends JThequeAction {
 36  
     @Resource
 37  
     private IAutoAddController autoAddController;
 38  
 
 39  
     /**
 40  
      * Construct a new AcValidateAutoAddView.
 41  
      */
 42  
     public AcValidateAutoAddView() {
 43  0
         super("generic.view.actions.ok");
 44  
         
 45  0
         Managers.getManager(IBeansManager.class).inject(this);
 46  0
     }
 47  
 
 48  
     @Override
 49  
     public void actionPerformed(ActionEvent event) {
 50  0
         final IAutoAddView view = autoAddController.getView();
 51  
 
 52  0
         if (view.validateContent(IAutoAddView.PHASE_2)) {
 53  0
             Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 54  
                 @Override
 55  
                 public void run() {
 56  0
                     view.startWait();
 57  
 
 58  0
                     new Thread(new AutoAddRunnable(autoAddController)).start();
 59  0
                 }
 60  
             });
 61  
         }
 62  0
     }
 63  
 
 64  
     /**
 65  
      * A runnable to launch the auto add process.
 66  
      *
 67  
      * @author Baptiste Wicht
 68  
      */
 69  0
     private static final class AutoAddRunnable implements Runnable {
 70  
         private final IAutoAddController controller;
 71  
 
 72  
         /**
 73  
          * Create a new AutoAddRunnable.
 74  
          *
 75  
          * @param controller The controller to manage.
 76  
          */
 77  
         AutoAddRunnable(IAutoAddController controller) {
 78  0
             super();
 79  
 
 80  0
             this.controller = controller;
 81  0
         }
 82  
 
 83  
         @Override
 84  
         public void run() {
 85  0
             controller.auto(controller.getView().getSelectedFilm());
 86  
 
 87  0
             Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 88  
                 @Override
 89  
                 public void run() {
 90  0
                     controller.getView().stopWait();
 91  0
                     controller.getView().closeDown();
 92  0
                 }
 93  
             });
 94  0
         }
 95  
     }
 96  
 }