Coverage Report - org.jtheque.core.managers.view.impl.frame.ConfigView
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigView
0 %
0/19
0 %
0/2
1.143
 
 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.error.JThequeError;
 20  
 import org.jtheque.core.managers.view.able.IConfigView;
 21  
 import org.jtheque.core.managers.view.able.components.IModel;
 22  
 import org.jtheque.core.managers.view.impl.actions.config.ApplyChangesAction;
 23  
 import org.jtheque.core.managers.view.impl.actions.config.ApplyChangesAndCloseAction;
 24  
 import org.jtheque.core.managers.view.impl.actions.config.CancelChangesAction;
 25  
 import org.jtheque.core.managers.view.impl.components.LayerTabbedPane;
 26  
 import org.jtheque.core.managers.view.impl.components.config.ConfigTabComponent;
 27  
 import org.jtheque.core.managers.view.impl.frame.abstraction.SwingBuildedDialogView;
 28  
 import org.jtheque.core.managers.view.listeners.ConfigTabEvent;
 29  
 import org.jtheque.core.managers.view.listeners.ConfigTabListener;
 30  
 import org.jtheque.core.utils.ui.PanelBuilder;
 31  
 import org.jtheque.utils.ui.GridBagUtils;
 32  
 
 33  
 import java.util.Collection;
 34  
 
 35  
 /**
 36  
  * A view for the configuration.
 37  
  *
 38  
  * @author Baptiste Wicht
 39  
  */
 40  
 public final class ConfigView extends SwingBuildedDialogView<IModel> implements ConfigTabListener, IConfigView {
 41  
     private LayerTabbedPane tab;
 42  
 
 43  
     /**
 44  
      * Construct the ConfigView. 
 45  
      */
 46  
     public ConfigView(){
 47  0
         super();
 48  
 
 49  0
         build();
 50  0
     }
 51  
 
 52  
     @Override
 53  
     protected void initView(){
 54  0
         setTitleKey("config.view.title");
 55  0
     }
 56  
 
 57  
     @Override
 58  
     protected void buildView(PanelBuilder builder){
 59  0
         tab = new LayerTabbedPane();
 60  
 
 61  0
         for (ConfigTabComponent component : getManager().getConfigTabComponents()) {
 62  0
             tab.addLayeredTab(component.getTitle(), component.getComponent());
 63  
         }
 64  
 
 65  0
         getManager().addConfigTabListener(this);
 66  
 
 67  0
         builder.add(tab, builder.gbcSet(0, 0, GridBagUtils.BOTH));
 68  
 
 69  0
         builder.addButtonBar(builder.gbcSet(0, 1, GridBagUtils.HORIZONTAL),
 70  
                 new ApplyChangesAndCloseAction(), new ApplyChangesAction(), new CancelChangesAction());
 71  0
     }
 72  
 
 73  
     @Override
 74  
     public ConfigTabComponent getSelectedPanelConfig() {
 75  0
         return (ConfigTabComponent) tab.getSelectedComponent();
 76  
     }
 77  
 
 78  
     @Override
 79  
     public void tabAdded(ConfigTabEvent event) {
 80  0
         tab.addLayeredTab(event.getComponent().getTitle(), event.getComponent().getComponent());
 81  0
     }
 82  
 
 83  
     @Override
 84  
     public void tabRemoved(ConfigTabEvent event) {
 85  0
         tab.removeTabAt(tab.indexOfTab(event.getComponent().getTitle()));
 86  0
     }
 87  
 
 88  
     @Override
 89  
     protected void validate(Collection<JThequeError> errors){
 90  0
         getSelectedPanelConfig().validate(errors);
 91  0
     }
 92  
 }