Coverage Report - org.jtheque.core.managers.view.impl.components.renderers.ModuleRepositoryListRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
ModuleRepositoryListRenderer
0 %
0/7
0 %
0/2
1.5
 
 1  
 package org.jtheque.core.managers.view.impl.components.renderers;
 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.view.impl.components.panel.ModulePanel;
 20  
 
 21  
 import javax.swing.JList;
 22  
 import javax.swing.ListCellRenderer;
 23  
 import java.awt.Component;
 24  
 import java.util.HashMap;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * A renderer to display a module in a list.
 29  
  *
 30  
  * @author Baptiste Wicht
 31  
  */
 32  
 public final class ModuleRepositoryListRenderer implements ListCellRenderer {
 33  
     private final Map<Integer, ModulePanel> panels;
 34  
 
 35  
     /**
 36  
      * Construct a new ModuleListRenderer.
 37  
      */
 38  
     public ModuleRepositoryListRenderer() {
 39  0
         super();
 40  
 
 41  0
         panels = new HashMap<Integer, ModulePanel>(10);
 42  0
     }
 43  
 
 44  
     @Override
 45  
     public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
 46  0
         if (panels.get(index) == null) {
 47  0
             panels.put(index, new ModulePanel(value, isSelected));
 48  
         } else {
 49  0
             panels.get(index).setSelected(isSelected);
 50  
         }
 51  
 
 52  0
         return panels.get(index);
 53  
     }
 54  
 
 55  
 }