Coverage Report - org.jtheque.core.managers.view.MainController
 
Classes in this File Line Coverage Branch Coverage Complexity
MainController
0 %
0/11
0 %
0/4
2
 
 1  
 package org.jtheque.core.managers.view;
 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.language.ILanguageManager;
 21  
 import org.jtheque.core.managers.view.able.IViewManager;
 22  
 
 23  
 import javax.swing.JTabbedPane;
 24  
 import javax.swing.event.ChangeEvent;
 25  
 import javax.swing.event.ChangeListener;
 26  
 import java.awt.event.WindowAdapter;
 27  
 import java.awt.event.WindowEvent;
 28  
 
 29  
 /**
 30  
  * A controller for the main view.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 public final class MainController extends WindowAdapter implements ChangeListener {
 35  
     @Override
 36  
     public void stateChanged(ChangeEvent event) {
 37  0
         JTabbedPane tabbedPane = (JTabbedPane) event.getSource();
 38  
 
 39  0
         int index = tabbedPane.getSelectedIndex();
 40  
 
 41  0
         if (index == -1) {
 42  0
             Managers.getCore().getLifeCycleManager().setCurrentFunction("");
 43  
         } else {
 44  0
             Managers.getCore().getLifeCycleManager().setCurrentFunction(tabbedPane.getTitleAt(index));
 45  
         }
 46  0
     }
 47  
 
 48  
     @Override
 49  
     public void windowClosing(WindowEvent e) {
 50  0
         boolean yes = Managers.getManager(IViewManager.class).askUserForConfirmation(
 51  
                 Managers.getManager(ILanguageManager.class).getMessage("dialogs.confirm.exit",
 52  
                         Managers.getCore().getApplication().getName()),
 53  
                 Managers.getManager(ILanguageManager.class).getMessage("dialogs.confirm.exit.title",
 54  
                         Managers.getCore().getApplication().getName()));
 55  
 
 56  0
         if (yes) {
 57  0
             Managers.getCore().getLifeCycleManager().exit();
 58  
         }
 59  0
     }
 60  
 }