Coverage Report - org.jtheque.films.controllers.impl.undo.delete.DeletedKindEdit
 
Classes in this File Line Coverage Branch Coverage Complexity
DeletedKindEdit
0 %
0/11
N/A
1
 
 1  
 package org.jtheque.films.controllers.impl.undo.delete;
 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.language.ILanguageManager;
 22  
 import org.jtheque.primary.od.KindImpl;
 23  
 import org.jtheque.primary.services.able.IKindsService;
 24  
 
 25  
 import javax.annotation.Resource;
 26  
 import javax.swing.undo.AbstractUndoableEdit;
 27  
 import javax.swing.undo.CannotRedoException;
 28  
 import javax.swing.undo.CannotUndoException;
 29  
 
 30  
 /**
 31  
  * An edit for a deletion of kind.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  
 public final class DeletedKindEdit extends AbstractUndoableEdit {
 36  
     private static final long serialVersionUID = -3037357344759861059L;
 37  
 
 38  
     private final KindImpl kind;
 39  
 
 40  
     @Resource
 41  
     private IKindsService kindsService;
 42  
 
 43  
     /**
 44  
      * Construct a new DeletedKindEdit.
 45  
      *
 46  
      * @param kind The deleted kind.
 47  
      */
 48  
     public DeletedKindEdit(KindImpl kind) {
 49  0
         super();
 50  
 
 51  0
         Managers.getManager(IBeansManager.class).inject(this);
 52  
 
 53  0
         this.kind = kind;
 54  0
     }
 55  
 
 56  
     @Override
 57  
     public void undo() throws CannotUndoException {
 58  0
         super.undo();
 59  
 
 60  0
         kindsService.create(kind);
 61  0
     }
 62  
 
 63  
     @Override
 64  
     public void redo() throws CannotRedoException {
 65  0
         super.redo();
 66  
 
 67  0
         kindsService.delete(kind);
 68  0
     }
 69  
 
 70  
     @Override
 71  
     public String getPresentationName() {
 72  0
         return Managers.getManager(ILanguageManager.class).getMessage("undo.edits.delete");
 73  
     }
 74  
 }