Coverage Report - org.jtheque.primary.controller.impl.LanguageController
 
Classes in this File Line Coverage Branch Coverage Complexity
LanguageController
0 %
0/18
0 %
0/2
1.25
 
 1  
 package org.jtheque.primary.controller.impl;
 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.undo.IUndoRedoManager;
 21  
 import org.jtheque.core.managers.view.able.controller.AbstractController;
 22  
 import org.jtheque.primary.controller.able.ILanguageController;
 23  
 import org.jtheque.primary.controller.impl.undo.CreatedLanguageEdit;
 24  
 import org.jtheque.primary.od.able.Language;
 25  
 import org.jtheque.primary.services.able.ILanguagesService;
 26  
 import org.jtheque.primary.view.able.ILanguageView;
 27  
 import org.jtheque.primary.view.able.ViewMode;
 28  
 
 29  
 import javax.annotation.Resource;
 30  
 
 31  
 /**
 32  
  * A Language Controller.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  0
 public final class LanguageController extends AbstractController implements ILanguageController {
 37  0
     private ViewMode state = ViewMode.NEW;
 38  
     private Language currentLanguage;
 39  
 
 40  
     @Resource
 41  
     private ILanguagesService languagesService;
 42  
 
 43  
     @Resource
 44  
     private ILanguageView languageView;
 45  
 
 46  
     @Override
 47  
     public void newLanguage() {
 48  0
         state = ViewMode.NEW;
 49  
 
 50  0
         languageView.reload();
 51  0
         currentLanguage = languagesService.getEmptyLanguage();
 52  0
     }
 53  
 
 54  
     @Override
 55  
     public void editLanguage(Language language) {
 56  0
         state = ViewMode.EDIT;
 57  
 
 58  0
         languageView.reload(language);
 59  0
         currentLanguage = language;
 60  
 
 61  0
         displayView();
 62  0
     }
 63  
 
 64  
     @Override
 65  
     public void save(String name) {
 66  0
         currentLanguage.setName(name);
 67  
 
 68  0
         if (state == ViewMode.NEW) {
 69  0
             languagesService.create(currentLanguage);
 70  
 
 71  0
             Managers.getManager(IUndoRedoManager.class).addEdit(new CreatedLanguageEdit(currentLanguage));
 72  
         } else {
 73  0
             languagesService.save(currentLanguage);
 74  
         }
 75  0
     }
 76  
 
 77  
     @Override
 78  
     public ILanguageView getView() {
 79  0
         return languageView;
 80  
     }
 81  
 }