Coverage Report - org.jtheque.core.managers.view.impl.actions.module.update.AcValidateUpdateView
 
Classes in this File Line Coverage Branch Coverage Complexity
AcValidateUpdateView
0 %
0/6
N/A
1.4
AcValidateUpdateView$1
0 %
0/4
N/A
1.4
AcValidateUpdateView$StopWaitTask
0 %
0/3
N/A
1.4
AcValidateUpdateView$UpdateRunnable
0 %
0/8
0 %
0/4
1.4
 
 1  
 package org.jtheque.core.managers.view.impl.actions.module.update;
 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.beans.IBeansManager;
 21  
 import org.jtheque.core.managers.update.IUpdateManager;
 22  
 import org.jtheque.core.managers.view.able.IViewManager;
 23  
 import org.jtheque.core.managers.view.able.update.IUpdateView;
 24  
 import org.jtheque.core.managers.view.able.update.IUpdateView.Mode;
 25  
 import org.jtheque.core.managers.view.edt.SimpleTask;
 26  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 27  
 
 28  
 import javax.annotation.Resource;
 29  
 import java.awt.event.ActionEvent;
 30  
 
 31  
 /**
 32  
  * An action to validate the update view.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  0
 public final class AcValidateUpdateView extends JThequeAction {
 37  
     @Resource
 38  
     private IUpdateView updateView;
 39  
 
 40  
     /**
 41  
      * Construct a new AcValidateUpdateView.
 42  
      */
 43  
     public AcValidateUpdateView() {
 44  0
         super("update.actions.update");
 45  
 
 46  0
         Managers.getManager(IBeansManager.class).inject(this);
 47  0
     }
 48  
 
 49  
     @Override
 50  
     public void actionPerformed(ActionEvent e) {
 51  0
         Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 52  
             @Override
 53  
             public void run() {
 54  0
                 updateView.startWait();
 55  
 
 56  0
                 new Thread(new UpdateRunnable()).start();
 57  0
             }
 58  
         });
 59  0
     }
 60  
 
 61  
     /**
 62  
      * A runnable to update the module or the kernel.
 63  
      *
 64  
      * @author Baptiste Wicht
 65  
      */
 66  0
     private final class UpdateRunnable implements Runnable {
 67  
         @Override
 68  
         public void run() {
 69  0
             if (updateView.getMode() == Mode.KERNEL) {
 70  0
                 Managers.getManager(IUpdateManager.class).update(updateView.getSelectedVersion());
 71  0
             } else if (updateView.getMode() == Mode.MODULE) {
 72  0
                 Managers.getManager(IUpdateManager.class).update(updateView.getModule(), updateView.getSelectedVersion());
 73  
             } else {
 74  0
                 Managers.getManager(IUpdateManager.class).update(updateView.getUpdatable(), updateView.getSelectedVersion());
 75  
             }
 76  
 
 77  0
             Managers.getManager(IViewManager.class).execute(new StopWaitTask());
 78  0
         }
 79  
     }
 80  
 
 81  
     /**
 82  
      * A task to stop the wait progress of the view.
 83  
      *
 84  
      * @author Baptiste Wicht
 85  
      */
 86  0
     private final class StopWaitTask extends SimpleTask {
 87  
         @Override
 88  
         public void run() {
 89  0
             updateView.stopWait();
 90  0
         }
 91  
     }
 92  
 }