Coverage Report - org.jtheque.core.managers.view.impl.actions.about.PrintLicenseAction
 
Classes in this File Line Coverage Branch Coverage Complexity
PrintLicenseAction
0 %
0/6
N/A
1
PrintLicenseAction$1
0 %
0/4
N/A
1
PrintLicenseAction$PrintRunnable
0 %
0/4
N/A
1
PrintLicenseAction$StopWaitTask
0 %
0/3
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.actions.about;
 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.view.able.ILicenceView;
 22  
 import org.jtheque.core.managers.view.able.IViewManager;
 23  
 import org.jtheque.core.managers.view.edt.SimpleTask;
 24  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 25  
 import org.jtheque.utils.print.PrintUtils;
 26  
 
 27  
 import javax.annotation.Resource;
 28  
 import java.awt.event.ActionEvent;
 29  
 
 30  
 /**
 31  
  * An action to print the licence of the application.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  0
 public final class PrintLicenseAction extends JThequeAction {
 36  
     @Resource
 37  
     private ILicenceView licenceView;
 38  
 
 39  
     /**
 40  
      * Construct a new AcPrintLicense.
 41  
      */
 42  
     public PrintLicenseAction() {
 43  0
         super("licence.actions.print");
 44  
 
 45  0
         Managers.getManager(IBeansManager.class).inject(this);
 46  0
     }
 47  
 
 48  
     @Override
 49  
     public void actionPerformed(ActionEvent arg0) {
 50  0
         Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 51  
             @Override
 52  
             public void run() {
 53  0
                 licenceView.startWait();
 54  
 
 55  0
                 new Thread(new PrintRunnable()).start();
 56  0
             }
 57  
         });
 58  0
     }
 59  
 
 60  
     /**
 61  
      * A runnable to print the license.
 62  
      *
 63  
      * @author Baptiste Wicht
 64  
      */
 65  0
     private final class PrintRunnable implements Runnable {
 66  
         @Override
 67  
         public void run() {
 68  0
             PrintUtils.printLineFiles(getClass().getClassLoader().
 69  
                     getResourceAsStream("org/jtheque/core/resources/others/licence.txt"));
 70  
 
 71  0
             Managers.getManager(IViewManager.class).execute(new StopWaitTask());
 72  0
         }
 73  
     }
 74  
 
 75  
     /**
 76  
      * A task to stop the wait progress of the view.
 77  
      *
 78  
      * @author Baptiste Wicht
 79  
      */
 80  0
     private final class StopWaitTask extends SimpleTask {
 81  
         @Override
 82  
         public void run() {
 83  0
             licenceView.stopWait();
 84  0
         }
 85  
     }
 86  
 }