Coverage Report - org.jtheque.core.managers.AbstractManager
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractManager
16 %
2/12
N/A
1
 
 1  
 package org.jtheque.core.managers;
 2  
 
 3  
 import org.jdesktop.swingx.event.WeakEventListenerList;
 4  
 import org.jtheque.core.managers.error.IErrorManager;
 5  
 import org.jtheque.core.managers.language.ILanguageManager;
 6  
 import org.jtheque.core.managers.log.IJThequeLogger;
 7  
 import org.jtheque.core.managers.log.ILoggingManager;
 8  
 import org.jtheque.core.managers.state.IStateManager;
 9  
 
 10  
 /*
 11  
  * This file is part of JTheque.
 12  
  *
 13  
  * JTheque is free software: you can redistribute it and/or modify
 14  
  * it under the terms of the GNU General Public License as published by
 15  
  * the Free Software Foundation, either version 3 of the License.
 16  
  *
 17  
  * JTheque is distributed in the hope that it will be useful,
 18  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 19  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 20  
  * GNU General Public License for more details.
 21  
  *
 22  
  * You should have received a copy of the GNU General Public License
 23  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 24  
  */
 25  
 
 26  
 /**
 27  
  * An abstract manager.
 28  
  *
 29  
  * @author Baptiste Wicht
 30  
  */
 31  8
 public abstract class AbstractManager implements IManager {
 32  2
     private static final WeakEventListenerList LISTENERS = new WeakEventListenerList();
 33  
 
 34  
     /**
 35  
      * Return the listeners of the manager. The listener's list is static so shared to all the managers. 
 36  
      *
 37  
      * @return The listeners of the manager.
 38  
      */
 39  
     protected static WeakEventListenerList getListeners(){
 40  0
         return LISTENERS;
 41  
     }
 42  
 
 43  
     /**
 44  
      * Return the logger of the manager.
 45  
      *
 46  
      * @return The logger of the manager.
 47  
      */
 48  
     protected final IJThequeLogger getLogger() {
 49  0
         return getManager(ILoggingManager.class).getLogger(getClass());
 50  
     }
 51  
 
 52  
     /**
 53  
      * Return the error manager.
 54  
      *
 55  
      * @return The error manager.
 56  
      */
 57  
     protected static IErrorManager getErrorManager() {
 58  0
         return getManager(IErrorManager.class);
 59  
     }
 60  
 
 61  
     /**
 62  
      * Return the state manager.
 63  
      *
 64  
      * @return The state manager.
 65  
      */
 66  
     protected static IStateManager getStates() {
 67  0
         return getManager(IStateManager.class);
 68  
     }
 69  
 
 70  
     /**
 71  
      * Return the internationalized message.
 72  
      *
 73  
      * @param key The internationalization key.
 74  
      * @return The internationalized message.
 75  
      */
 76  
     protected static String getMessage(String key) {
 77  0
         return getManager(ILanguageManager.class).getMessage(key);
 78  
     }
 79  
 
 80  
     /**
 81  
      * Return the internationalized message.
 82  
      *
 83  
      * @param key      The internationalization key.
 84  
      * @param replaces The objects to use for the replaces.
 85  
      * @return The internationalized message.
 86  
      */
 87  
     protected static String getMessage(String key, Object... replaces) {
 88  0
         return getManager(ILanguageManager.class).getMessage(key, replaces);
 89  
     }
 90  
 
 91  
     /**
 92  
      * Return the manager with the specific class.
 93  
      *
 94  
      * @param managerClass The class of the manager.
 95  
      * @param <T>          The type of manager.
 96  
      * @return The manager.
 97  
      */
 98  
     protected static <T> T getManager(Class<T> managerClass) {
 99  0
         return Managers.getManager(managerClass);
 100  
     }
 101  
 
 102  
     @Override
 103  
     public void preInit(){
 104  
         //Nothing by default
 105  0
     }
 106  
 
 107  
     @Override
 108  
     public void init() throws ManagerException{
 109  
         //Nothing by default
 110  0
     }
 111  
 
 112  
     @Override
 113  
     public void close(){
 114  
         //Nothing by default
 115  0
     }
 116  
 }