blob: f91bdce81ff54d760dd06d05eaf521e34a3bc38d [file] [log] [blame]
<HTML><HEAD><META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type"/><TITLE>EMMA Coverage Report</TITLE><STYLE TYPE="text/css"> TABLE,TD,TH {border-style:solid; border-color:black;} TD,TH {background:white;margin:0;line-height:100%;padding-left:0.5em;padding-right:0.5em;} TD {border-width:0 1px 0 0;} TH {border-width:1px 1px 1px 0;} TR TD.h {color:red;} TABLE {border-spacing:0; border-collapse:collapse;border-width:0 0 1px 1px;} P,H1,H2,H3,TH {font-family:verdana,arial,sans-serif;font-size:10pt;} TD {font-family:courier,monospace;font-size:10pt;} TABLE.hdft {border-spacing:0;border-collapse:collapse;border-style:none;} TABLE.hdft TH,TABLE.hdft TD {border-style:none;line-height:normal;} TABLE.hdft TH.tl,TABLE.hdft TD.tl {background:#6699CC;color:white;} TABLE.hdft TD.nv {background:#6633DD;color:white;} .nv A:link {color:white;} .nv A:visited {color:white;} .nv A:active {color:yellow;} TABLE.hdft A:link {color:white;} TABLE.hdft A:visited {color:white;} TABLE.hdft A:active {color:yellow;} .in {color:#356085;} TABLE.s TD {padding-left:0.25em;padding-right:0.25em;} TABLE.s TD.l {padding-left:0.25em;padding-right:0.25em;text-align:right;background:#F0F0F0;} TABLE.s TR.z TD {background:#FF9999;} TABLE.s TR.p TD {background:#FFFF88;} TABLE.s TR.c TD {background:#CCFFCC;} A:link {color:#0000EE;text-decoration:none;} A:visited {color:#0000EE;text-decoration:none;} A:hover {color:#0000EE;text-decoration:underline;} TABLE.cn {border-width:0 0 1px 0;} TABLE.s {border-width:1px 0 1px 1px;} TD.h {color:red;border-width:0 1px 0 0;} TD.f {border-width:0 1px 0 1px;} TD.hf {color:red;border-width:0 1px 0 1px;} TH.f {border-width:1px 1px 1px 1px;} TR.cis TD {background:#F0F0F0;} TR.cis TD {border-width:1px 1px 1px 0;} TR.cis TD.h {color:red;border-width:1px 1px 1px 0;} TR.cis TD.f {border-width:1px 1px 1px 1px;} TR.cis TD.hf {color:red;border-width:1px 1px 1px 1px;} TD.b {border-style:none;background:transparent;line-height:50%;} TD.bt {border-width:1px 0 0 0;background:transparent;line-height:50%;} TR.o TD {background:#F0F0F0;}TABLE.it {border-style:none;}TABLE.it TD,TABLE.it TH {border-style:none;}</STYLE></HEAD><BODY><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="tl"><A HREF="http://www.eclemma.org/">EMMA</A> Coverage Report (generated Fri Feb 20 18:44:54 GMT 2009)</TH></TR><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="c2.html">org.eclipse.wst.xsl.ui.internal.style</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">XMLTextAttributeMap.java</SPAN>]</H2><TABLE CELLSPACING="0" WIDTH="100%"><TR><TH>name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD>XMLTextAttributeMap.java</TD><TD>100% (1/1)</TD><TD>100% (7/7)</TD><TD>91%  (160/175)</TD><TD>94%  (46.8/50)</TD></TR></TABLE><H3>COVERAGE BREAKDOWN BY CLASS AND METHOD</H3><TABLE CLASS="cn" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="f">name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD></TR><TR CLASS="cis"><TD CLASS="f">class <A HREF="#0">XMLTextAttributeMap</A></TD><TD>100% (1/1)</TD><TD>100% (7/7)</TD><TD>91%  (160/175)</TD><TD>94%  (46.8/50)</TD></TR><TR><TD CLASS="f"><A HREF="#1">createTextAttribute (RGB, RGB, int): TextAttribute</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>82%  (14/17)</TD><TD>82%  (0.8/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">addXMLTextAttribute (String): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (71/83)</TD><TD>86%  (19/22)</TD></TR><TR><TD CLASS="f"><A HREF="#0">&lt;static initializer&gt;</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (9/9)</TD><TD>100% (3/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">XMLTextAttributeMap (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (60/60)</TD><TD>100% (21/21)</TD></TR><TR><TD CLASS="f"><A HREF="#5">getInstance (): XMLTextAttributeMap</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (2/2)</TD><TD>100% (1/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">getTextAttributeMap (): Map</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (2/2)</TD><TD>100% (1/1)</TD></TR><TR><TD CLASS="f"><A HREF="#7">getXMLPreferenceStore (): IPreferenceStore</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (2/2)</TD><TD>100% (1/1)</TD></TR></TABLE><P></P><TABLE CLASS="s" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="l">1</TD><TD>/*******************************************************************************</TD></TR><TR><TD CLASS="l">2</TD><TD> *Copyright (c) 2008 Standards for Technology in Automotive Retail and others.</TD></TR><TR><TD CLASS="l">3</TD><TD> *All rights reserved. This program and the accompanying materials</TD></TR><TR><TD CLASS="l">4</TD><TD> *are made available under the terms of the Eclipse Public License v1.0</TD></TR><TR><TD CLASS="l">5</TD><TD> *which accompanies this distribution, and is available at</TD></TR><TR><TD CLASS="l">6</TD><TD> *http://www.eclipse.org/legal/epl-v10.html</TD></TR><TR><TD CLASS="l">7</TD><TD> *</TD></TR><TR><TD CLASS="l">8</TD><TD> *Contributors:</TD></TR><TR><TD CLASS="l">9</TD><TD> *    David Carver (STAR) - bug 213775 - initial API and implementation</TD></TR><TR><TD CLASS="l">10</TD><TD> *******************************************************************************/</TD></TR><TR><TD CLASS="l">11</TD><TD>package org.eclipse.wst.xsl.ui.internal.style;</TD></TR><TR><TD CLASS="l">12</TD><TD> </TD></TR><TR><TD CLASS="l">13</TD><TD>import java.util.HashMap;</TD></TR><TR><TD CLASS="l">14</TD><TD>import java.util.Map;</TD></TR><TR><TD CLASS="l">15</TD><TD> </TD></TR><TR><TD CLASS="l">16</TD><TD>import org.eclipse.jface.preference.IPreferenceStore;</TD></TR><TR><TD CLASS="l">17</TD><TD>import org.eclipse.jface.text.TextAttribute;</TD></TR><TR><TD CLASS="l">18</TD><TD>import org.eclipse.swt.SWT;</TD></TR><TR><TD CLASS="l">19</TD><TD>import org.eclipse.swt.graphics.RGB;</TD></TR><TR><TD CLASS="l">20</TD><TD>import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;</TD></TR><TR><TD CLASS="l">21</TD><TD>import org.eclipse.wst.sse.ui.internal.util.EditorUtility;</TD></TR><TR><TD CLASS="l">22</TD><TD>import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;</TD></TR><TR><TD CLASS="l">23</TD><TD>import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;</TD></TR><TR><TD CLASS="l">24</TD><TD> </TD></TR><TR><TD CLASS="l">25</TD><TD>/**</TD></TR><TR><TD CLASS="l">26</TD><TD> * XMlTextAttributeMap handles the mapping of XML Style Constants to TextAttributes.</TD></TR><TR><TD CLASS="l">27</TD><TD> * </TD></TR><TR><TD CLASS="l">28</TD><TD> * @author David Carver</TD></TR><TR><TD CLASS="l"><A NAME="0">29</A></TD><TD> * @since 1.0</TD></TR><TR><TD CLASS="l">30</TD><TD> */</TD></TR><TR CLASS="c"><TD CLASS="l">31</TD><TD>public class XMLTextAttributeMap {</TD></TR><TR><TD CLASS="l">32</TD><TD>        </TD></TR><TR CLASS="c"><TD CLASS="l">33</TD><TD>        private static HashMap&lt;String,TextAttribute&gt; textAttributeMap = new HashMap&lt;String,TextAttribute&gt;();</TD></TR><TR CLASS="c"><TD CLASS="l"><A NAME="7">34</A></TD><TD>        private static XMLTextAttributeMap xmlTextAttributeMap = new XMLTextAttributeMap(); </TD></TR><TR><TD CLASS="l">35</TD><TD>        private static IPreferenceStore xmlPreferenceStore;</TD></TR><TR><TD CLASS="l"><A NAME="4">36</A></TD><TD>        </TD></TR><TR><TD CLASS="l">37</TD><TD>        private static IPreferenceStore getXMLPreferenceStore() {</TD></TR><TR CLASS="c"><TD CLASS="l">38</TD><TD>                return xmlPreferenceStore;</TD></TR><TR><TD CLASS="l">39</TD><TD>        }</TD></TR><TR CLASS="c"><TD CLASS="l">40</TD><TD>        private XMLTextAttributeMap() {</TD></TR><TR CLASS="c"><TD CLASS="l">41</TD><TD>                xmlPreferenceStore = XMLUIPlugin.getDefault().getPreferenceStore();</TD></TR><TR CLASS="c"><TD CLASS="l">42</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.TAG_NAME);</TD></TR><TR CLASS="c"><TD CLASS="l">43</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.TAG_BORDER);</TD></TR><TR CLASS="c"><TD CLASS="l">44</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);</TD></TR><TR CLASS="c"><TD CLASS="l">45</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);</TD></TR><TR CLASS="c"><TD CLASS="l">46</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);</TD></TR><TR CLASS="c"><TD CLASS="l">47</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.COMMENT_BORDER);</TD></TR><TR CLASS="c"><TD CLASS="l">48</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.COMMENT_TEXT);</TD></TR><TR CLASS="c"><TD CLASS="l">49</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.CDATA_BORDER);</TD></TR><TR CLASS="c"><TD CLASS="l">50</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.CDATA_TEXT);</TD></TR><TR CLASS="c"><TD CLASS="l">51</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.DECL_BORDER);</TD></TR><TR CLASS="c"><TD CLASS="l">52</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);</TD></TR><TR CLASS="c"><TD CLASS="l">53</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);</TD></TR><TR CLASS="c"><TD CLASS="l">54</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);</TD></TR><TR CLASS="c"><TD CLASS="l">55</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.DOCTYPE_NAME);</TD></TR><TR CLASS="c"><TD CLASS="l">56</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.PI_CONTENT);</TD></TR><TR CLASS="c"><TD CLASS="l">57</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.PI_BORDER);</TD></TR><TR CLASS="c"><TD CLASS="l">58</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.XML_CONTENT);</TD></TR><TR CLASS="c"><TD CLASS="l">59</TD><TD>                addXMLTextAttribute(IStyleConstantsXML.ENTITY_REFERENCE);</TD></TR><TR CLASS="c"><TD CLASS="l">60</TD><TD>        }</TD></TR><TR><TD CLASS="l">61</TD><TD>        </TD></TR><TR><TD CLASS="l">62</TD><TD>        /**</TD></TR><TR><TD CLASS="l"><A NAME="5">63</A></TD><TD>         * An instance of XMLTextAttributeMap.</TD></TR><TR><TD CLASS="l">64</TD><TD>         * @return</TD></TR><TR><TD CLASS="l">65</TD><TD>         */</TD></TR><TR><TD CLASS="l">66</TD><TD>        public static XMLTextAttributeMap getInstance() {</TD></TR><TR CLASS="c"><TD CLASS="l">67</TD><TD>                  return xmlTextAttributeMap;</TD></TR><TR><TD CLASS="l">68</TD><TD>        }</TD></TR><TR><TD CLASS="l">69</TD><TD>        </TD></TR><TR><TD CLASS="l">70</TD><TD>        /**</TD></TR><TR><TD CLASS="l"><A NAME="6">71</A></TD><TD>         * Returns a Map of Style Constants and the corresponding Text Attribute</TD></TR><TR><TD CLASS="l">72</TD><TD>         * @return</TD></TR><TR><TD CLASS="l">73</TD><TD>         */</TD></TR><TR><TD CLASS="l">74</TD><TD>        public Map&lt;String,TextAttribute&gt; getTextAttributeMap() {</TD></TR><TR CLASS="c"><TD CLASS="l"><A NAME="2">75</A></TD><TD>                return textAttributeMap;</TD></TR><TR><TD CLASS="l">76</TD><TD>        }</TD></TR><TR><TD CLASS="l">77</TD><TD>        </TD></TR><TR><TD CLASS="l">78</TD><TD>        private void addXMLTextAttribute(String colorKey) {</TD></TR><TR CLASS="c"><TD CLASS="l">79</TD><TD>                if (getXMLPreferenceStore() != null) {</TD></TR><TR CLASS="c"><TD CLASS="l">80</TD><TD>                        String prefString = getXMLPreferenceStore().getString(colorKey);</TD></TR><TR CLASS="c"><TD CLASS="l">81</TD><TD>                        String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);</TD></TR><TR CLASS="c"><TD CLASS="l">82</TD><TD>                        if (stylePrefs != null) {</TD></TR><TR CLASS="c"><TD CLASS="l">83</TD><TD>                                RGB foreground = ColorHelper.toRGB(stylePrefs[0]);</TD></TR><TR CLASS="c"><TD CLASS="l">84</TD><TD>                                RGB background = ColorHelper.toRGB(stylePrefs[1]);</TD></TR><TR CLASS="c"><TD CLASS="l">85</TD><TD>                                boolean bold = Boolean.valueOf(stylePrefs[2]).booleanValue();</TD></TR><TR CLASS="c"><TD CLASS="l">86</TD><TD>                                boolean italic = Boolean.valueOf(stylePrefs[3]).booleanValue();</TD></TR><TR CLASS="c"><TD CLASS="l">87</TD><TD>                                boolean strikethrough = Boolean.valueOf(stylePrefs[4]).booleanValue();</TD></TR><TR CLASS="c"><TD CLASS="l">88</TD><TD>                                boolean underline = Boolean.valueOf(stylePrefs[5]).booleanValue();</TD></TR><TR CLASS="c"><TD CLASS="l">89</TD><TD>                                int style = SWT.NORMAL;</TD></TR><TR CLASS="c"><TD CLASS="l">90</TD><TD>                                if (bold) {</TD></TR><TR CLASS="z"><TD CLASS="l">91</TD><TD>                                        style = style | SWT.BOLD;</TD></TR><TR><TD CLASS="l">92</TD><TD>                                }</TD></TR><TR CLASS="c"><TD CLASS="l">93</TD><TD>                                if (italic) {</TD></TR><TR CLASS="c"><TD CLASS="l">94</TD><TD>                                        style = style | SWT.ITALIC;</TD></TR><TR><TD CLASS="l">95</TD><TD>                                }</TD></TR><TR CLASS="c"><TD CLASS="l">96</TD><TD>                                if (strikethrough) {</TD></TR><TR CLASS="z"><TD CLASS="l">97</TD><TD>                                        style = style | TextAttribute.STRIKETHROUGH;</TD></TR><TR><TD CLASS="l">98</TD><TD>                                }</TD></TR><TR CLASS="c"><TD CLASS="l">99</TD><TD>                                if (underline) {</TD></TR><TR CLASS="z"><TD CLASS="l">100</TD><TD>                                        style = style | TextAttribute.UNDERLINE;</TD></TR><TR><TD CLASS="l">101</TD><TD>                                }</TD></TR><TR><TD CLASS="l">102</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">103</TD><TD>                                TextAttribute createTextAttribute = createTextAttribute(foreground, background, style);</TD></TR><TR CLASS="c"><TD CLASS="l">104</TD><TD>                                textAttributeMap.put(colorKey, createTextAttribute);</TD></TR><TR><TD CLASS="l">105</TD><TD>                        }</TD></TR><TR><TD CLASS="l"><A NAME="1">106</A></TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">107</TD><TD>        }</TD></TR><TR><TD CLASS="l">108</TD><TD> </TD></TR><TR><TD CLASS="l">109</TD><TD>        protected TextAttribute createTextAttribute(RGB foreground, RGB background, int style) {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="82% line coverage (14 out of 17 instructions)">110</TD><TD TITLE="82% line coverage (14 out of 17 instructions)">                return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, style);</TD></TR><TR><TD CLASS="l">111</TD><TD>        }</TD></TR><TR><TD CLASS="l">112</TD><TD> </TD></TR><TR><TD CLASS="l">113</TD><TD>}</TD></TR></TABLE><P></P><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="c2.html">org.eclipse.wst.xsl.ui.internal.style</A>]</TD></TR><TR><TD CLASS="tl"><A HREF="http://www.eclemma.org/support.html">EMMA 2.0.5312 EclEmma Fix 1</A> (C) Vladimir Roubtsov</TD></TR></TABLE></BODY></HTML>