Coverage Report - org.jtheque.core.managers.update.AbstractUpdatable
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractUpdatable
0 %
0/20
0 %
0/2
1.111
 
 1  
 package org.jtheque.core.managers.update;
 2  
 
 3  
 import org.jdesktop.swingx.event.WeakEventListenerList;
 4  
 import org.jtheque.utils.bean.Version;
 5  
 
 6  
 /*
 7  
  * This file is part of JTheque.
 8  
  *
 9  
  * JTheque is free software: you can redistribute it and/or modify
 10  
  * it under the terms of the GNU General Public License as published by
 11  
  * the Free Software Foundation, either version 3 of the License.
 12  
  *
 13  
  * JTheque is distributed in the hope that it will be useful,
 14  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16  
  * GNU General Public License for more details.
 17  
  *
 18  
  * You should have received a copy of the GNU General Public License
 19  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 20  
  */
 21  
 
 22  
 /**
 23  
  * An abstract updatable.
 24  
  *
 25  
  * @author Baptiste Wicht
 26  
  */
 27  
 public abstract class AbstractUpdatable implements Updatable {
 28  
     private final String key;
 29  
     private final String name;
 30  
     private Version version;
 31  
 
 32  
     private final WeakEventListenerList listenerList;
 33  
 
 34  
     /**
 35  
      * Construct a new AbstractUpdatable.
 36  
      *
 37  
      * @param name The name of the updatable.
 38  
      * @param key  The internationalization key.
 39  
      */
 40  
     protected AbstractUpdatable(String name, String key) {
 41  0
         super();
 42  
 
 43  0
         this.key = key;
 44  0
         this.name = name;
 45  
 
 46  0
         listenerList = new WeakEventListenerList();
 47  0
     }
 48  
 
 49  
     @Override
 50  
     public final void addUpdateListener(UpdateListener listener) {
 51  0
         listenerList.add(UpdateListener.class, listener);
 52  0
     }
 53  
 
 54  
     @Override
 55  
     public final void removeUpdateListener(UpdateListener listener) {
 56  0
         listenerList.remove(UpdateListener.class, listener);
 57  0
     }
 58  
 
 59  
     @Override
 60  
     public final void setUpdated() {
 61  0
         fireUpdated();
 62  0
     }
 63  
 
 64  
     /**
 65  
      * Fire an updated event.
 66  
      */
 67  
     private void fireUpdated() {
 68  0
         UpdateListener[] listeners = listenerList.getListeners(UpdateListener.class);
 69  
 
 70  0
         for (UpdateListener l : listeners) {
 71  0
             l.updated();
 72  
         }
 73  0
     }
 74  
 
 75  
     @Override
 76  
     public final void setVersion(Version version) {
 77  0
         this.version = version;
 78  0
     }
 79  
 
 80  
     @Override
 81  
     public final Version getVersion() {
 82  0
         return version;
 83  
     }
 84  
 
 85  
     @Override
 86  
     public final String getKey() {
 87  0
         return key;
 88  
     }
 89  
 
 90  
     @Override
 91  
     public final String getName() {
 92  0
         return name;
 93  
     }
 94  
 }