Coverage Report - org.xmlhammer.gui.overview.CheckBoxNode
 
Classes in this File Line Coverage Branch Coverage Complexity
CheckBoxNode
85% 
100% 
0
 
 1  
 /*
 2  
  * $Id: CheckBoxNode.java,v 1.3 2006/09/07 13:37:36 edankert Exp $
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License 
 5  
  * Version 1.1 (the "License"); you may not use this file except in 
 6  
  * compliance with the License. You may obtain a copy of the License at 
 7  
  * http://www.mozilla.org/MPL/ 
 8  
  *
 9  
  * Software distributed under the License is distributed on an "AS IS" basis, 
 10  
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  
  * for the specific language governing rights and limitations under the License.
 12  
  *
 13  
  * The Original Code is XML Hammer code. (org.xmlhammer.*)
 14  
  *
 15  
  * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
 16  
  * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
 17  
  * All Rights Reserved.
 18  
  *
 19  
  * Contributor(s): Edwin Dankert <edankert@gmail.com>
 20  
  */
 21  
 
 22  
 
 23  
 package org.xmlhammer.gui.overview;
 24  
 
 25  
 import java.awt.event.ItemEvent;
 26  
 import java.awt.event.ItemListener;
 27  
 import java.util.ArrayList;
 28  
 
 29  
 import javax.swing.Icon;
 30  
 import javax.swing.ImageIcon;
 31  
 import javax.swing.JCheckBox;
 32  
 
 33  
 import org.bounce.image.ImageLoader;
 34  
 
 35  
 
 36  
 public class CheckBoxNode implements OverviewNode, ItemListener {
 37  22
         private static final ImageIcon UNSELECTED_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/elcl16/disabled_co.gif");
 38  22
         private static final ImageIcon SELECTED_ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/elcl16/enabled_co.gif");
 39  
 
 40  3036
         private ArrayList<OverviewNode> empty = new ArrayList<OverviewNode>();
 41  3036
         private JCheckBox check     = null;
 42  3036
         private OverviewNode parent = null;
 43  3036
     private String error        = null;
 44  
 
 45  3036
     public CheckBoxNode( OverviewNode parent, JCheckBox check) {
 46  3036
         this.parent = parent;
 47  3036
         this.check = check;
 48  
         
 49  3036
         check.addItemListener( this);
 50  3036
     }
 51  
     public String getNodeName() {
 52  3366
         return check.getText();
 53  
     }
 54  
 
 55  
     public ArrayList<OverviewNode> getChildNodes() {
 56  115944
         return empty;
 57  
     }
 58  
 
 59  
     public OverviewNode getParentNode() {
 60  8888
         return parent;
 61  
     }
 62  
 
 63  
     public Icon getNodeIcon() {
 64  3366
             if ( check.isSelected()) { 
 65  836
                     return SELECTED_ICON;
 66  
             }
 67  
 
 68  2530
             return UNSELECTED_ICON;
 69  
     }
 70  
 
 71  
     public void itemStateChanged( ItemEvent e) {
 72  836
             OverviewNode node = parent;
 73  
             
 74  836
             while ( node != null && !(node.getParentNode() instanceof OverviewTreeModel)) {
 75  0
                     node = node.getParentNode();
 76  0
             }
 77  
             
 78  836
                 if ( node != null) {
 79  836
                     ((OverviewTreeModel)node.getParentNode()).nodeChanged( this);
 80  
             }
 81  836
     }
 82  
     
 83  
     public void setError(String error) {
 84  0
         this.error = error;
 85  0
     }
 86  
     
 87  
     public String getError() {
 88  96474
         return error;
 89  
     }
 90  
 }