Coverage Report - org.jtheque.core.managers.view.impl.components.panel.AbstractDelegatedView
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractDelegatedView
0 %
0/21
N/A
1
AbstractDelegatedView$1
0 %
0/3
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.components.panel;
 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.view.able.IView;
 21  
 import org.jtheque.core.managers.view.able.IViewManager;
 22  
 import org.jtheque.core.managers.view.edt.SimpleTask;
 23  
 
 24  
 /**
 25  
  * An abstract delegated view. It seems a view who delegates all the view's operations to an other view.
 26  
  *
 27  
  * @author Baptiste Wicht
 28  
  */
 29  0
 public abstract class AbstractDelegatedView<T extends IView> implements IView {
 30  
     private T delegate;
 31  
 
 32  
     /**
 33  
      * Return the implementation of the view.
 34  
      *
 35  
      * @return The implementation of the view.
 36  
      */
 37  
     public final T getImplementationView(){
 38  0
         return delegate;
 39  
     }
 40  
 
 41  
     /**
 42  
      * Set the delegate view.
 43  
      *
 44  
      * @param view The delegate view. 
 45  
      */
 46  
     public final void setDelegate(T view){
 47  0
         delegate = view;
 48  0
     }
 49  
 
 50  
     /**
 51  
      * Build the delegated view in EDT. This method only call the buildDelegatedView() method in the EDT.
 52  
      */
 53  
     public final void buildInEDT() {
 54  0
         Managers.getManager(IViewManager.class).execute(new SimpleTask() {
 55  
             @Override
 56  
             public void run() {
 57  0
                 buildDelegatedView();
 58  0
             }
 59  
         });
 60  0
     }
 61  
 
 62  
     /**
 63  
      * Build the delegated view. This method must only be called from the buildInEDT() method. With that contract respected,
 64  
      * this method is always called in the EDT.
 65  
      */
 66  
     protected abstract void buildDelegatedView();
 67  
 
 68  
     @Override
 69  
     public final void display() {
 70  0
         delegate.display();
 71  0
     }
 72  
 
 73  
     @Override
 74  
     public final Object getImpl() {
 75  0
         return delegate.getImpl();
 76  
     }
 77  
 
 78  
     @Override
 79  
     public final void closeDown() {
 80  0
         delegate.closeDown();
 81  0
     }
 82  
 
 83  
     @Override
 84  
     public final void toFirstPlan() {
 85  0
         delegate.toFirstPlan();
 86  0
     }
 87  
 
 88  
     @Override
 89  
     public final void setEnabled(boolean enabled) {
 90  0
         delegate.setEnabled(enabled);
 91  0
     }
 92  
 
 93  
     @Override
 94  
     public final boolean isEnabled() {
 95  0
         return delegate.isEnabled();
 96  
     }
 97  
 
 98  
     @Override
 99  
     public final void sendMessage(String message, Object value) {
 100  0
         delegate.sendMessage(message, value);
 101  0
     }
 102  
 
 103  
     @Override
 104  
     public final void refresh() {
 105  0
         delegate.refresh();
 106  0
     }
 107  
 
 108  
     @Override
 109  
     public final boolean validateContent() {
 110  0
         return delegate.validateContent();
 111  
     }
 112  
 }