Coverage Report - org.jtheque.films.view.impl.sort.NoneSorter
 
Classes in this File Line Coverage Branch Coverage Complexity
NoneSorter
0 %
0/8
0 %
0/4
1.333
 
 1  
 package org.jtheque.films.view.impl.sort;
 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.primary.controller.able.IPrincipalController;
 20  
 import org.jtheque.primary.od.able.Data;
 21  
 import org.jtheque.primary.view.impl.models.tree.JThequeTreeModel;
 22  
 import org.jtheque.primary.view.impl.models.tree.TreeElement;
 23  
 import org.jtheque.primary.view.impl.sort.Sorter;
 24  
 
 25  
 /**
 26  
  * A sorter who get directly the informations from the display list.
 27  
  *
 28  
  * @author Baptiste Wicht
 29  
  */
 30  
 public final class NoneSorter implements Sorter {
 31  
     private final IPrincipalController<? extends Data> controller;
 32  
 
 33  
     /**
 34  
      * Construct a new <code>NoneSorter</code> for the specified principal controller.
 35  
      *
 36  
      * @param controller The principal controller.
 37  
      */
 38  0
     public NoneSorter(IPrincipalController<? extends Data> controller) {
 39  0
         this.controller = controller;
 40  0
     }
 41  
 
 42  
     @Override
 43  
     public boolean canSort(String content, String sortType) {
 44  0
         return content.equals(controller.getDataType()) && "None".equals(sortType);
 45  
     }
 46  
 
 47  
     @Override
 48  
     public void sort(JThequeTreeModel model) {
 49  0
         TreeElement root = model.getRoot();
 50  
 
 51  0
         root.addAll(controller.getDisplayList());
 52  
 
 53  0
         model.setRootElement(root);
 54  0
     }
 55  
 }