Coverage Report - org.jtheque.core.managers.view.impl.components.model.UpdatableListModel
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdatableListModel
0 %
0/10
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.components.model;
 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.update.IUpdateManager;
 21  
 import org.jtheque.core.managers.update.Updatable;
 22  
 import org.jtheque.core.managers.update.UpdatableListener;
 23  
 import org.jtheque.utils.collections.CollectionUtils;
 24  
 
 25  
 import javax.swing.DefaultListModel;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * A List model to display the modules.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  
 public final class UpdatableListModel extends DefaultListModel implements UpdatableListener {
 34  
     private final List<Updatable> updatables;
 35  
 
 36  
     /**
 37  
      * Construct a new ModuleListModel.
 38  
      */
 39  
     public UpdatableListModel() {
 40  0
         super();
 41  
 
 42  0
         updatables = CollectionUtils.copyOf(Managers.getManager(IUpdateManager.class).getUpdatables());
 43  
 
 44  0
         Managers.getManager(IUpdateManager.class).addUpdatableListener(this);
 45  0
     }
 46  
 
 47  
     @Override
 48  
     public Object getElementAt(int index) {
 49  0
         return updatables.get(index);
 50  
     }
 51  
 
 52  
     @Override
 53  
     public Object get(int index) {
 54  0
         return updatables.get(index);
 55  
     }
 56  
 
 57  
     @Override
 58  
     public int getSize() {
 59  0
         return updatables.size();
 60  
     }
 61  
 
 62  
     @Override
 63  
     public void updatableAdded() {
 64  0
         updatables.clear();
 65  0
         updatables.addAll(Managers.getManager(IUpdateManager.class).getUpdatables());
 66  0
     }
 67  
 }