Coverage Report - org.jtheque.core.managers.view.impl.actions.module.AbstractUpdateAction
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractUpdateAction
0 %
0/12
0 %
0/2
1.4
 
 1  
 package org.jtheque.core.managers.view.impl.actions.module;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.beans.IBeansManager;
 5  
 import org.jtheque.core.managers.error.IErrorManager;
 6  
 import org.jtheque.core.managers.log.ILoggingManager;
 7  
 import org.jtheque.core.managers.view.able.IViewManager;
 8  
 import org.jtheque.core.managers.view.able.update.IUpdateView;
 9  
 import org.jtheque.core.managers.view.impl.actions.JThequeAction;
 10  
 
 11  
 import javax.annotation.Resource;
 12  
 import java.awt.HeadlessException;
 13  
 import java.awt.event.ActionEvent;
 14  
 
 15  
 /*
 16  
  * This file is part of JTheque.
 17  
  *
 18  
  * JTheque is free software: you can redistribute it and/or modify
 19  
  * it under the terms of the GNU General Public License as published by
 20  
  * the Free Software Foundation, either version 3 of the License.
 21  
  *
 22  
  * JTheque is distributed in the hope that it will be useful,
 23  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 24  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 25  
  * GNU General Public License for more details.
 26  
  *
 27  
  * You should have received a copy of the GNU General Public License
 28  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 29  
  */
 30  
 
 31  
 /**
 32  
  * An abstract update action.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  
 public abstract class AbstractUpdateAction extends JThequeAction {
 37  
     @Resource
 38  
     private IUpdateView updateView;
 39  
 
 40  
     /**
 41  
      * Construct a new AbstractUpdateAction.
 42  
      *
 43  
      * @param key The internationalization key.
 44  
      */
 45  
     AbstractUpdateAction(String key) {
 46  0
         super(key);
 47  
 
 48  0
         Managers.getManager(IBeansManager.class).inject(this);
 49  0
     }
 50  
 
 51  
     @Override
 52  
     public final void actionPerformed(ActionEvent e) {
 53  
         try {
 54  0
             if (isUpToDate()) {
 55  0
                 Managers.getManager(IViewManager.class).displayI18nText("message.update.no.version");
 56  
             } else {
 57  0
                 updateView.sendMessage(getMessage(), getSelectedObject());
 58  0
                 updateView.display();
 59  
             }
 60  0
         } catch (HeadlessException e2) {
 61  0
             Managers.getManager(ILoggingManager.class).getLogger(getClass()).error(e2);
 62  0
             Managers.getManager(IErrorManager.class).addInternationalizedError("error.update.internet");
 63  0
         }
 64  0
     }
 65  
 
 66  
     /**
 67  
      * Indicate if the selected object is up to date.
 68  
      *
 69  
      * @return true if the selected object is up to date.
 70  
      */
 71  
     abstract boolean isUpToDate();
 72  
 
 73  
     /**
 74  
      * Return the message to send.
 75  
      *
 76  
      * @return The message to send.
 77  
      */
 78  
     abstract String getMessage();
 79  
 
 80  
     /**
 81  
      * Return the selected object.
 82  
      *
 83  
      * @return The selected object.
 84  
      */
 85  
     abstract Object getSelectedObject();
 86  
 }