Coverage Report - org.jtheque.core.managers.view.impl.actions.module.repository.InstallRepositoryModuleAction
 
Classes in this File Line Coverage Branch Coverage Complexity
InstallRepositoryModuleAction
0 %
0/9
0 %
0/4
2
 
 1  
 package org.jtheque.core.managers.view.impl.actions.module.repository;
 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.IViewManager;
 23  
 import org.jtheque.core.managers.view.able.update.IRepositoryView;
 24  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 25  
 import org.jtheque.core.utils.CoreUtils;
 26  
 
 27  
 import java.awt.event.ActionEvent;
 28  
 
 29  
 /**
 30  
  * Install the selected module.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  
 public final class InstallRepositoryModuleAction extends JThequeAction {
 35  
     /**
 36  
      * Construct a new InstallRepositoryModuleAction.
 37  
      */
 38  
     public InstallRepositoryModuleAction() {
 39  0
         super("repository.actions.install");
 40  0
     }
 41  
 
 42  
     @Override
 43  
     public void actionPerformed(ActionEvent e) {
 44  0
         ModuleDescription description = CoreUtils.<IRepositoryView>getBean("repositoryView").getSelectedModule();
 45  
 
 46  0
         if (description.getCoreVersion().isGreaterThan(Managers.getCore().getCoreCurrentVersion())) {
 47  0
             Managers.getManager(IViewManager.class).displayI18nText("error.module.version.core");
 48  
         } else {
 49  0
             if (Managers.getManager(IModuleManager.class).isInstalled(description.getId())) {
 50  0
                 Managers.getManager(IViewManager.class).displayI18nText("message.repository.module.installed");
 51  
             } else {
 52  0
                 Managers.getManager(IModuleManager.class).install(description.getVersionsFileURL());
 53  
             }
 54  
         }
 55  0
     }
 56  
 }