Coverage Report - org.jtheque.films.view.impl.actions.film.AcAddActorToList
 
Classes in this File Line Coverage Branch Coverage Complexity
AcAddActorToList
0 %
0/13
0 %
0/2
1.5
 
 1  
 package org.jtheque.films.view.impl.actions.film;
 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.impl.actions.JThequeSimpleAction;
 22  
 import org.jtheque.films.view.able.IInfosActorsView;
 23  
 import org.jtheque.utils.collections.ArrayUtils;
 24  
 
 25  
 import javax.swing.DefaultListModel;
 26  
 import java.awt.event.ActionEvent;
 27  
 import java.util.Arrays;
 28  
 
 29  
 /**
 30  
  * Action to add an actor to the list.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  
 public final class AcAddActorToList extends JThequeSimpleAction {
 35  
     /**
 36  
      * Construct a new AcAddActorToList.
 37  
      */
 38  
     public AcAddActorToList() {
 39  0
         super();
 40  
 
 41  0
         setText(" >> ");
 42  0
     }
 43  
 
 44  
     @Override
 45  
     public void actionPerformed(ActionEvent e) {
 46  0
         IInfosActorsView actorsView = Managers.getManager(IBeansManager.class).getBean("filmActorsView");
 47  
         
 48  0
         DefaultListModel modelActors = actorsView.getActorsModel();
 49  0
         DefaultListModel modelActorsForFilm = actorsView.getActorsForFilmModel();
 50  
         
 51  0
         int[] selectedActors = actorsView.getSelectedActorsIndexes();
 52  
 
 53  0
         Arrays.sort(selectedActors);
 54  
 
 55  0
         ArrayUtils.reverse(selectedActors);
 56  
 
 57  0
         for (int index : selectedActors) {
 58  0
             Object actor = modelActors.remove(index);
 59  0
             modelActorsForFilm.addElement(actor);
 60  
         }
 61  0
     }
 62  
 }