~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev.jython/Lib/xml/dom/html/HTMLTableRowElement.py

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
########################################################################
 
2
#
 
3
# File Name:            HTMLTableRowElement.py
 
4
#
 
5
# Documentation:        http://docs.4suite.com/4DOM/HTMLTableRowElement.py.html
 
6
#
 
7
"""
 
8
WWW: http://4suite.com/4DOM         e-mail: support@4suite.com
 
9
 
 
10
Copyright (c) 2000 Fourthought Inc, USA.   All Rights Reserved.
 
11
See  http://4suite.com/COPYRIGHT  for license and copyright information
 
12
"""
 
13
 
 
14
import string
 
15
from xml.dom import implementation
 
16
from xml.dom import IndexSizeErr
 
17
from xml.dom.html.HTMLElement import HTMLElement
 
18
 
 
19
class HTMLTableRowElement(HTMLElement):
 
20
 
 
21
    def __init__(self, ownerDocument, nodeName='TR'):
 
22
        HTMLElement.__init__(self, ownerDocument, nodeName)
 
23
 
 
24
    ### Attribute Methods ###
 
25
 
 
26
    def _get_align(self):
 
27
        return string.capitalize(self.getAttribute('ALIGN'))
 
28
 
 
29
    def _set_align(self,align):
 
30
        self.setAttribute('ALIGN', align)
 
31
 
 
32
    def _get_bgColor(self):
 
33
        return self.getAttribute('BGCOLOR')
 
34
 
 
35
    def _set_bgColor(self, color):
 
36
        self.setAttribute('BGCOLOR', color)
 
37
 
 
38
    def _get_cells(self):
 
39
        cells = []
 
40
        for child in self.childNodes:
 
41
            if child.tagName in ['TD','TH']:
 
42
                cells.append(child)
 
43
        return implementation._4dom_createHTMLCollection(cells)
 
44
 
 
45
    def _get_ch(self):
 
46
        return self.getAttribute('CHAR')
 
47
 
 
48
    def _set_ch(self, ch):
 
49
        self.setAttribute('CHAR', ch)
 
50
 
 
51
    def _get_chOff(self):
 
52
        return self.getAttribute('CHAROFF')
 
53
 
 
54
    def _set_chOff(self, offset):
 
55
        self.setAttribute('CHAROFF', offset)
 
56
 
 
57
    def _get_rowIndex(self):
 
58
        #Get our index in the table
 
59
        section = self.parentNode
 
60
        if section == None:
 
61
            return -1
 
62
        table = section.parentNode
 
63
        if table == None:
 
64
            return -1
 
65
        rows = table._get_rows()
 
66
        return rows.index(self)
 
67
 
 
68
    def _get_sectionRowIndex(self):
 
69
        section = self.parentNode
 
70
        if section == None:
 
71
            return -1
 
72
        rows = section._get_rows()
 
73
        return rows.index(self)
 
74
 
 
75
    def _get_vAlign(self):
 
76
        return string.capitalize(self.getAttribute('VALIGN'))
 
77
 
 
78
    def _set_vAlign(self, valign):
 
79
        self.setAttribute('VALIGN', valign)
 
80
 
 
81
    ### Methods ###
 
82
 
 
83
    def insertCell(self, index):
 
84
        cells = self._get_cells()
 
85
        if index < 0 or index > len(cells):
 
86
            raise IndexSizeErr()
 
87
        cell = self.ownerDocument.createElement('TD')
 
88
        length = cells.length
 
89
        if index == len(cells):
 
90
            ref = None
 
91
        elif index < len(cells):
 
92
            ref = cells[index]
 
93
        return self.insertBefore(cell, ref)
 
94
 
 
95
    def deleteCell(self,index):
 
96
        cells = self._get_cells()
 
97
        if index < 0 or index >= len(cells):
 
98
            raise IndexSizeErr()
 
99
        self.removeChild(cells[index])
 
100
 
 
101
    ### Attribute Access Mappings ###
 
102
 
 
103
    _readComputedAttrs = HTMLElement._readComputedAttrs.copy()
 
104
    _readComputedAttrs.update ({
 
105
         'rowIndex'      : _get_rowIndex,
 
106
         'sectionRowIndex' : _get_sectionRowIndex,
 
107
         'cells'         : _get_cells,
 
108
         'align'         : _get_align,
 
109
         'bgColor'       : _get_bgColor,
 
110
         'ch'            : _get_ch,
 
111
         'chOff'         : _get_chOff,
 
112
         'vAlign'        : _get_vAlign,
 
113
      })
 
114
 
 
115
    _writeComputedAttrs = HTMLElement._writeComputedAttrs.copy()
 
116
    _writeComputedAttrs.update ({
 
117
         'align'         : _set_align,
 
118
         'bgColor'       : _set_bgColor,
 
119
         'ch'            : _set_ch,
 
120
         'chOff'         : _set_chOff,
 
121
         'vAlign'        : _set_vAlign,
 
122
      })
 
123
 
 
124
    # Create the read-only list of attributes
 
125
    _readOnlyAttrs = filter(lambda k,m=_writeComputedAttrs: not m.has_key(k),
 
126
                     HTMLElement._readOnlyAttrs + _readComputedAttrs.keys())