Coverage Report - org.jtheque.core.managers.view.impl.frame.RepositoryView
 
Classes in this File Line Coverage Branch Coverage Complexity
RepositoryView
0 %
0/19
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.frame;
 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.module.IModuleManager;
 21  
 import org.jtheque.core.managers.update.repository.ModuleDescription;
 22  
 import org.jtheque.core.managers.view.able.components.IModel;
 23  
 import org.jtheque.core.managers.view.able.update.IRepositoryView;
 24  
 import org.jtheque.core.managers.view.impl.actions.module.repository.ExpandRepositoryModuleAction;
 25  
 import org.jtheque.core.managers.view.impl.actions.module.repository.InstallRepositoryModuleAction;
 26  
 import org.jtheque.core.managers.view.impl.components.model.ModuleRepositoryListModel;
 27  
 import org.jtheque.core.managers.view.impl.components.panel.ModulePanel;
 28  
 import org.jtheque.core.managers.view.impl.components.renderers.ModuleRepositoryListRenderer;
 29  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingBuildedDialogView;
 30  
 import org.jtheque.core.utils.ui.PanelBuilder;
 31  
 import org.jtheque.utils.ui.GridBagUtils;
 32  
 
 33  
 import javax.swing.JList;
 34  
 import javax.swing.ListSelectionModel;
 35  
 
 36  
 /**
 37  
  * The view to display the repository of the application.
 38  
  *
 39  
  * @author Baptiste Wicht
 40  
  */
 41  
 public final class RepositoryView extends SwingBuildedDialogView<IModel> implements IRepositoryView {
 42  
     private JList list;
 43  
 
 44  
     /**
 45  
      * Construct a new RepositoryView. 
 46  
      */
 47  
     public RepositoryView(){
 48  0
         super();
 49  
 
 50  0
         build();
 51  0
     }
 52  
 
 53  
     @Override
 54  
     protected void initView(){
 55  0
         setTitleKey("repository.view.title", Managers.getManager(IModuleManager.class).getRepository().getApplication());
 56  0
         setResizable(false);
 57  0
     }
 58  
 
 59  
     @Override
 60  
     protected void buildView(PanelBuilder builder){
 61  0
         builder.addLabel(Managers.getManager(IModuleManager.class).getRepository().getTitle().toString(),
 62  
                 builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL));
 63  
 
 64  0
         list = new JList();
 65  0
         list.setModel(new ModuleRepositoryListModel());
 66  0
         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 67  0
         list.setCellRenderer(new ModuleRepositoryListRenderer());
 68  0
         list.setVisibleRowCount(5);
 69  
 
 70  0
         builder.addScrolled(list, builder.gbcSet(0, 1, GridBagUtils.BOTH));
 71  
 
 72  0
         builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL),
 73  
                 new ExpandRepositoryModuleAction(), new InstallRepositoryModuleAction());
 74  0
     }
 75  
 
 76  
     @Override
 77  
     public ModuleDescription getSelectedModule() {
 78  0
         return (ModuleDescription) list.getSelectedValue();
 79  
     }
 80  
 
 81  
     @Override
 82  
     public void expandSelectedModule() {
 83  0
         ModulePanel renderer = (ModulePanel)
 84  
                 list.getCellRenderer().getListCellRendererComponent(
 85  
                         list, list.getSelectedValue(),
 86  
                         list.getSelectedIndex(), true, true);
 87  
 
 88  0
         renderer.expand();
 89  0
     }
 90  
 }