buildframework/helium/sf/python/pythoncore/lib/helium/output/widgets.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : widgets.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    19
""" handles components in XML documents"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    21
# pylint: disable=E1101
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import xml.dom.minidom
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
class Widget:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
    """ Class Widget represents a component in an xml document """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
    def __init__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    30
        """get DOM container"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
class Box(Widget):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    """ A widget of type Box """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    def __init__(self, doc, container, divId = "mb", divClass = "mc"):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        Widget.__init__(self)
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    38
        doc_1 = doc.createElementNS("", "div")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    39
        doc_1.setAttributeNS("", "id", divId)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    40
        container.appendChild(doc_1)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    41
        m_c = doc.createElementNS("", "div")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    42
        m_c.setAttributeNS("", "class", divClass)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    43
        doc_1.appendChild(m_c)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        self.__doc = doc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        self.__title = None
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    46
        self.__mc = m_c
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    def setTitle(self, title=""):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    49
        """set the title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        if self.__title == None:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    51
            t_doc = self.__doc.createElementNS("", "h1")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    52
            self.__mc.insertBefore(t_doc, self.__mc.firstChild)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
            self.__title = self.__doc.createTextNode(title)
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    54
            t_doc.appendChild(self.__title)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        self.__title.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    58
        """get DOM container"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        return self.__mc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
    
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    61
class Summary(Box):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    """ A widget representing a summary component """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
    def __init__(self, doc, container):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        Box.__init__(self, doc, container, divId = "s_mb", divClass = "s_mc")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        self.__table = doc.createElementNS("", "table")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        self.__table.setAttributeNS("", "cellspacing", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
        self.__table.setAttributeNS("", "cellpadding", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        self.__table.setAttributeNS("", "border", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        self.__table.setAttributeNS("", "width", "100%")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        self.__table.appendChild(self._Box__doc.createTextNode(""))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
        div = self._Box__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        div.setAttributeNS("", "class", "t_wrapper")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        div.appendChild(self.__table)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
        self.getDOMContainer().appendChild(div)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        self.__table_stat = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
        self.setTitle()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
    def addElement(self, tag, value):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    80
        """add Element"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
        row = self._Box__doc.createElementNS("", "tr")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
        #Tag
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    83
        t_d = self._Box__doc.createElementNS("", "td")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    84
        t_d.setAttributeNS("", "valign", "top")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    85
        t_d.setAttributeNS("", "nowrap", "nowrap")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
        div = self._Box__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        div.setAttributeNS("", "class", "s_tag")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        div.appendChild(self._Box__doc.createTextNode(tag))
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    89
        t_d.appendChild(div)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    90
        row.appendChild(t_d)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
        # Value
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    93
        t_d = self._Box__doc.createElementNS("", "td")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    94
        t_d.setAttributeNS("", "width", "100%")        
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        div = self._Box__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
        div.setAttributeNS("", "class", "s_val")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        div.appendChild(self._Box__doc.createTextNode(value))
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    98
        t_d.appendChild(div)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    99
        row.appendChild(t_d)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        self.__table.appendChild(row)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   103
    def addStatistics(self, type_, value):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   104
        """add Statistics"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
        if self.__table_stat == None:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   106
            head1 = self._Box__doc.createElementNS("", "h1")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   107
            head1.appendChild(self._Box__doc.createTextNode("Global Statistics"))
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   108
            self.getDOMContainer().appendChild(head1)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
                            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
            div = self._Box__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
            div.setAttributeNS("", "class", "t_wrapper")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
            self.getDOMContainer().appendChild(div)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
            self.__table_stat = self._Box__doc.createElementNS("", "table")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
            self.__table_stat.setAttributeNS("", "cellspacing", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
            self.__table_stat.setAttributeNS("", "cellpadding", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
            self.__table_stat.setAttributeNS("", "border", "0")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
            self.__table_stat.setAttributeNS("", "width", "100%")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
            div.appendChild(self.__table_stat)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
            row = self._Box__doc.createElementNS("", "tr")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
            self.__table_stat.appendChild(row)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
            self.__table_stat = row
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   124
        t_d = self._Box__doc.createElementNS("", "td")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
        div = self._Box__doc.createElementNS("", "div")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   126
        div.setAttributeNS("", "class", "gbl_cnt_" + type_)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   127
        div.appendChild(self._Box__doc.createTextNode("%d %ss" % (value, type_)))
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   128
        t_d.appendChild(div)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   129
        self.__table_stat.appendChild(t_d)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
          
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
class Event(Widget):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
    """ A widget representing an event component """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   135
    def __init__(self, doc, container, id_):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
        Widget.__init__(self)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        self.__doc = doc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
        node_head = doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
        node_head.setAttributeNS("", "class", "node_head")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
        container.appendChild(node_head)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
        link = doc.createElementNS("", "a")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   143
        link.setAttributeNS("", "href", "javascript:ToggleNode('Img%d')" % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        node_head.appendChild(link)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
        span = doc.createElementNS("", "span")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   147
        span.setAttributeNS("", "id", "Img%d" % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
        span.setAttributeNS("", "style", "background:url(http://fawww.europe.nokia.com/isis/isis_interface/img/icons/button_open.gif) no-repeat")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
        link.appendChild(span)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
        stitle = doc.createElementNS("", "span")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
        stitle.setAttributeNS("", "class", "node_title")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
        self.__title = doc.createTextNode("")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
        stitle.appendChild(self.__title)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
        span.appendChild(stitle)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
        # shaow all
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        showall = doc.createElementNS("", "a")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   159
        showall.setAttributeNS("", "href", "javascript:ShowChilds('Img%d')"  % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
        span = doc.createElementNS("", "span")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
        span.setAttributeNS("", "class", "node_action")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
        span.appendChild(doc.createTextNode("[Show All]"))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
        showall.appendChild(span)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        #hide all
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        hideall = doc.createElementNS("", "a")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   167
        hideall.setAttributeNS("", "href", "javascript:HideChilds('Img%d')" % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
        span = doc.createElementNS("", "span")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        span.setAttributeNS("", "class", "node_action")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
        span.appendChild(doc.createTextNode("[Hide All]"))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        hideall.appendChild(span)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
        #toggle node
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
        self.__togglenode = doc.createElementNS("", "a")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   175
        self.__togglenode.setAttributeNS("", "href", "javascript:ToggleNode('Img%d')" % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
        self.__togglenode.appendChild(doc.createTextNode(""))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        # append container
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
        node_head.appendChild(showall)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        node_head.appendChild(hideall)
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   180
        node_head.appendChild(self.__togglenode)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
        contentx = doc.createElementNS("", "div")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   183
        contentx.setAttributeNS("", "id", "Content%d" % id_)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
        contentx.setAttributeNS("", "style", "display:none")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
        container.appendChild(contentx)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
        content = doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
        content.setAttributeNS("", 'class', "node_content")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
        content.appendChild(doc.createTextNode(""))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
        contentx.appendChild(content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
        self.__container = content
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
        self.__node_info = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
    def setTitle(self, title = ""):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   194
        """set Title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
        self.__title.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   197
    def addStatistics(self, type_, value):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   198
        """add Statistics"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
        if self.__node_info == None:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
            self.__node_info = self.__doc.createElementNS("", "span")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
            self.__node_info.setAttributeNS("", "class", "node_info")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
            self.__togglenode.appendChild(self.__node_info)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
        span = self.__doc.createElementNS("", "span")
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   204
        span.setAttributeNS("", "class","cnt_%s" % type_)
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   205
        span.appendChild(self.__doc.createTextNode("%d %ss" % (value, type_)))
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
        self.__node_info.appendChild(span)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
          #<span class="node_info">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
          #  <span class="cnt_warning">2 warnings</span>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
          #</span>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   212
        """get DOM Container"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
        return self.__container
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   214
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
class Header(Widget):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
    """ A widget representing a Header section """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
    def __init__(self, doc, container):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
        Widget.__init__(self)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
        self.__doc = doc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
        h_wrapper = self.__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
        h_wrapper.setAttributeNS("", "id", "h_wrapper")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
        h_elmt = self.__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
        h_elmt.setAttributeNS("", "class", "h_elmt")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
        h_wrapper.appendChild(h_elmt)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
        container.appendChild(h_wrapper)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   227
        #title
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   228
        t_elem = self.__doc.createElementNS("", "div")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   229
        self.__title = doc.createTextNode("")
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   230
        t_elem.appendChild(self.__title)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   231
        t_elem.setAttributeNS("", "class", "h_title")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   232
        h_elmt.appendChild(t_elem)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
        #subtitle
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   234
        t_elem = self.__doc.createElementNS("", "div")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
        self.__subtitle = doc.createTextNode("")
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   236
        t_elem.appendChild(self.__subtitle)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   237
        t_elem.setAttributeNS("", "class", "h_subtitle")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   238
        h_elmt.appendChild(t_elem)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   239
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   241
        
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   242
    def setTitle(self, title):
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   243
        """set Title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
        self.__title.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
        
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   246
    def setSubTitle(self, title):
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   247
        """set Sub Title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
        self.__subtitle.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   251
        """get DOM Container"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
        return None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   254
class Footer(Widget):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
    """ A widget representing a footer section """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
    def __init__(self, doc, container):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
        Widget.__init__(self)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
        self.__doc = doc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
        h_wrapper = self.__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
        h_wrapper.setAttributeNS("", "id", "f_wrapper")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
        h_elmt = self.__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
        h_elmt.setAttributeNS("", "class", "f_elmt")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
        h_wrapper.appendChild(h_elmt)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
        container.appendChild(h_wrapper)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
        #title
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   266
        t_elem = self.__doc.createElementNS("", "div")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
        self.__title = doc.createTextNode("")
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   268
        t_elem.appendChild(self.__title)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   269
        t_elem.setAttributeNS("", "class", "f_title")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   270
        h_elmt.appendChild(t_elem)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
        #subtitle
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   272
        t_elem = self.__doc.createElementNS("", "div")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
        self.__subtitle = doc.createTextNode("")
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   274
        t_elem.appendChild(self.__subtitle)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   275
        t_elem.setAttributeNS("", "class", "f_subtitle")
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   276
        h_elmt.appendChild(t_elem)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   277
        
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   278
    def setTitle(self, title):
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   279
        """set Title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
        self.__title.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
        
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   282
    def setSubTitle(self, title):
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   283
        """set Sub Title"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
        self.__subtitle.data = title
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
class Text(Widget):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
    """ A widget representing a text component """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
    def __init__(self, doc, container):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
        Widget.__init__(self)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
        self.__doc = doc
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
        self.__div = self.__doc.createElementNS("", "div")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
        self.__div.setAttributeNS("", "class", "icn_dft")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
        container.appendChild(self.__div)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
    def setIcon(self, name):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   296
        """set Icon"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
        self.__div.setAttributeNS("", "class", name)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   299
    def appendText(self, text):
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   300
        """append Text"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
        def pushContent(arg):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   302
            """push Content"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
            self.getDOMContainer().appendChild(self.__doc.createTextNode(arg))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
            self.getDOMContainer().appendChild(self.__doc.createElementNS("","br"))
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   305
        [pushContent(line) for line in text.strip().split("\n")]
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   308
        """get DOM Container"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
        return self.__div
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
class RawText(Text):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
    """ This class represents a raw text component """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
    def appendText(self, text):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   314
        """append Text"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
        for child in xml.dom.minidom.parseString("<xhtml>" + text.strip() + "</xhtml>").documentElement.childNodes:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
            self.getDOMContainer().appendChild(child.cloneNode(True))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
class BoldText(Text):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
    """ This class represents a bold text component """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
    def __init__(self, doc, container):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
        Text.__init__(self, doc, container)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
        self.__bold = doc.createElementNS("","b")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
        self._Text__div.appendChild(self.__bold)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
    def getDOMContainer(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   326
        """get DOM COntainer"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
        return self.__bold