Coverage Report - org.jtheque.core.managers.view.impl.actions.module.EnableModuleAction
 
Classes in this File Line Coverage Branch Coverage Complexity
EnableModuleAction
0 %
0/12
0 %
0/4
2
 
 1  
 package org.jtheque.core.managers.view.impl.actions.module;
 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.module.beans.ModuleContainer;
 22  
 import org.jtheque.core.managers.module.beans.ModuleState;
 23  
 import org.jtheque.core.managers.view.able.IViewManager;
 24  
 import org.jtheque.core.managers.view.able.update.IModuleView;
 25  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 26  
 import org.jtheque.core.utils.CoreUtils;
 27  
 import org.jtheque.utils.bean.Version;
 28  
 
 29  
 import java.awt.event.ActionEvent;
 30  
 
 31  
 /**
 32  
  * An action to enable a module.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  
 public final class EnableModuleAction extends JThequeAction {
 37  
     /**
 38  
      * Construct a new EnableModuleAction.
 39  
      */
 40  
     public EnableModuleAction() {
 41  0
         super("modules.actions.activate");
 42  0
     }
 43  
 
 44  
     @Override
 45  
     public void actionPerformed(ActionEvent arg0) {
 46  0
         IModuleView moduleView = CoreUtils.getBean("moduleView");
 47  
 
 48  0
         ModuleContainer module = moduleView.getSelectedModule();
 49  
 
 50  0
         if (module.getState() == ModuleState.DISABLED) {
 51  0
             if (new Version(module.getInfos().core()).isGreaterThan(Managers.getCore().getCoreCurrentVersion())) {
 52  0
                 Managers.getManager(IViewManager.class).displayI18nText("modules.message.versionproblem");
 53  
             } else {
 54  0
                 Managers.getManager(IModuleManager.class).enableModule(module);
 55  0
                 moduleView.refreshList();
 56  
 
 57  0
                 Managers.getManager(IViewManager.class).displayI18nText("message.module.enabled");
 58  
             }
 59  
         } else {
 60  0
             Managers.getManager(IViewManager.class).displayI18nText("error.module.not.disabled");
 61  
         }
 62  0
     }
 63  
 }