Clover coverage report -
Coverage timestamp: Sun Apr 18 2004 21:32:30 EDT
file stats: LOC: 110   Methods: 5
NCLOC: 42   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TagSelector.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * SimplyHTML, a word processor based on Java, HTML and CSS
 3   
  * Copyright (C) 2002 Ulrich Hilger
 4   
  *
 5   
  * This program is free software; you can redistribute it and/or
 6   
  * modify it under the terms of the GNU General Public License
 7   
  * as published by the Free Software Foundation; either version 2
 8   
  * of the License, or (at your option) any later version.
 9   
  *
 10   
  * This program 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 this program; if not, write to the Free Software
 17   
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 18   
  */
 19   
 
 20   
 import javax.swing.*;
 21   
 import javax.swing.text.html.*;
 22   
 import java.util.*;
 23   
 
 24   
 /**
 25   
  * Component to select a tag
 26   
  *
 27   
  * @author Ulrich Hilger
 28   
  * @author Light Development
 29   
  * @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
 30   
  * @author <a href="mailto:info@lightdev.com">info@lightdev.com</a>
 31   
  * @author published under the terms and conditions of the
 32   
  *      GNU General Public License,
 33   
  *      for details see file gpl.txt in the distribution
 34   
  *      package of this software
 35   
  *
 36   
  * @version stage 11, April 27, 2003
 37   
  */
 38   
 
 39   
 public class TagSelector extends JComboBox {
 40   
 
 41   
   /** table with available tags to select */
 42   
   private Vector tags = new Vector();
 43   
 
 44   
   /** table with tag names corresponding to tags */
 45   
   private Vector tagNames = new Vector();
 46   
 
 47   
   /**
 48   
    * construct a new TagSelector
 49   
    */
 50  78
   public TagSelector() {
 51  78
     super();
 52  78
     initTags();
 53  78
     setModel(new DefaultComboBoxModel(tagNames));
 54   
   }
 55   
 
 56   
   /**
 57   
    * get the name of the tag that is currently selected
 58   
    *
 59   
    * @return the tag name
 60   
    */
 61  1
   public String getSelectedTag() {
 62  1
     return (String) tags.elementAt(getSelectedIndex());
 63   
   }
 64   
 
 65   
   /**
 66   
    * get the list of tags selectable through this component
 67   
    *
 68   
    * @return a Vector of tags available from this component
 69   
    */
 70  1
   public Vector getTags() {
 71  1
     return tags;
 72   
   }
 73   
 
 74   
   /**
 75   
    * set the tag that is to be shown in this component
 76   
    *
 77   
    * @param tag  the name of the tag to show
 78   
    */
 79  29
   public void setSelectedTag(String tag) {
 80  29
     int index = tags.indexOf(tag);
 81  29
     if(index > -1) {
 82  6
       setSelectedIndex(tags.indexOf(tag));
 83   
     }
 84   
     else {
 85  23
       setSelectedIndex(0);
 86   
     }
 87   
   }
 88   
 
 89   
   /**
 90   
    * initialize content types hashtable
 91   
    */
 92  78
   private void initTags() {
 93  78
     tags.addElement(HTML.Tag.P.toString());
 94  78
     tags.addElement(HTML.Tag.H1.toString());
 95  78
     tags.addElement(HTML.Tag.H2.toString());
 96  78
     tags.addElement(HTML.Tag.H3.toString());
 97  78
     tags.addElement(HTML.Tag.H4.toString());
 98  78
     tags.addElement(HTML.Tag.H5.toString());
 99  78
     tags.addElement(HTML.Tag.H6.toString());
 100   
 
 101  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNamePara"));
 102  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead1"));
 103  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead2"));
 104  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead3"));
 105  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead4"));
 106  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead5"));
 107  78
     tagNames.addElement(FrmMain.dynRes.getResourceString(FrmMain.resources, "cTagNameHead6"));
 108   
   }
 109   
 
 110   
 }