Coverage Report - org.jtheque.core.managers.view.impl.frame.UpdateView
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateView
0 %
0/28
0 %
0/6
1.375
 
 1  
 package org.jtheque.core.managers.view.impl.frame;
 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.module.beans.ModuleContainer;
 20  
 import org.jtheque.core.managers.update.Updatable;
 21  
 import org.jtheque.core.managers.view.able.components.IModel;
 22  
 import org.jtheque.core.managers.view.able.update.IUpdateView;
 23  
 import org.jtheque.core.managers.view.impl.actions.module.update.AcValidateUpdateView;
 24  
 import org.jtheque.core.managers.view.impl.components.model.VersionsComboBoxModel;
 25  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingBuildedDialogView;
 26  
 import org.jtheque.core.utils.ui.PanelBuilder;
 27  
 import org.jtheque.utils.bean.Version;
 28  
 import org.jtheque.utils.ui.GridBagUtils;
 29  
 
 30  
 /**
 31  
  * An update view.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  
 public final class UpdateView extends SwingBuildedDialogView<IModel> implements IUpdateView {
 36  
     private VersionsComboBoxModel model;
 37  
 
 38  0
     private Mode mode = Mode.KERNEL;
 39  
     private ModuleContainer module;
 40  
     private Updatable updatable;
 41  
 
 42  
     /**
 43  
      * Construct a new UpdateView. 
 44  
      */
 45  
     public UpdateView(){
 46  0
         super();
 47  
 
 48  0
         build();
 49  0
     }
 50  
 
 51  
     @Override
 52  
     protected void initView(){
 53  0
         setTitleKey("update.view.title");
 54  0
         setResizable(false);
 55  0
     }
 56  
 
 57  
     @Override
 58  
     protected void buildView(PanelBuilder builder){
 59  0
         builder.addI18nLabel("update.view.versions", builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL));
 60  
 
 61  0
         model = new VersionsComboBoxModel();
 62  
 
 63  0
         builder.addComboBox(model, builder.gbcSet(0, 1, GridBagUtils.HORIZONTAL));
 64  
 
 65  0
         builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL),
 66  
                 new AcValidateUpdateView(), getCloseAction("update.actions.cancel"));
 67  0
     }
 68  
 
 69  
     @Override
 70  
     public void sendMessage(String message, Object value) {
 71  0
         if ("kernel".equals(message)) {
 72  0
             mode = Mode.KERNEL;
 73  
 
 74  0
             model.loadKernelVersions();
 75  0
         } else if ("module".equals(message)) {
 76  0
             mode = Mode.MODULE;
 77  
 
 78  0
             module = (ModuleContainer) value;
 79  0
             model.loadModuleVersions(module);
 80  0
         } else if ("updatable".equals(message)) {
 81  0
             mode = Mode.UPDATABLE;
 82  
 
 83  0
             updatable = (Updatable) value;
 84  0
             model.loadUpdatableVersions(updatable);
 85  
         }
 86  0
     }
 87  
 
 88  
     @Override
 89  
     public Mode getMode() {
 90  0
         return mode;
 91  
     }
 92  
 
 93  
     @Override
 94  
     public Version getSelectedVersion() {
 95  0
         return model.getSelectedVersion();
 96  
     }
 97  
 
 98  
     @Override
 99  
     public ModuleContainer getModule() {
 100  0
         return module;
 101  
     }
 102  
 
 103  
     @Override
 104  
     public Updatable getUpdatable() {
 105  0
         return updatable;
 106  
     }
 107  
 }