Coverage Report - org.jtheque.core.managers.view.impl.actions.module.DisableModuleAction
 
Classes in this File Line Coverage Branch Coverage Complexity
DisableModuleAction
0 %
0/10
0 %
0/2
1.5
 
 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  
 
 28  
 import java.awt.event.ActionEvent;
 29  
 
 30  
 /**
 31  
  * An action to disable a module.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  
 public final class DisableModuleAction extends JThequeAction {
 36  
     /**
 37  
      * Construct a new DisableModuleAction.
 38  
      */
 39  
     public DisableModuleAction() {
 40  0
         super("modules.actions.desactivate");
 41  0
     }
 42  
 
 43  
     @Override
 44  
     public void actionPerformed(ActionEvent arg0) {
 45  0
         IModuleView moduleView = CoreUtils.getBean("moduleView");
 46  
 
 47  0
         ModuleContainer module = moduleView.getSelectedModule();
 48  
 
 49  0
         if (module.getState() == ModuleState.DISABLED) {
 50  0
             Managers.getManager(IViewManager.class).displayI18nText("error.module.not.enabled");
 51  
         } else {
 52  0
             Managers.getManager(IModuleManager.class).disableModule(module);
 53  0
             moduleView.refreshList();
 54  
 
 55  0
             Managers.getManager(IViewManager.class).displayI18nText("message.module.disabled");
 56  
         }
 57  0
     }
 58  
 }