本文整理汇总了Python中pyjamas.DOM.compare方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.compare方法的具体用法?Python DOM.compare怎么用?Python DOM.compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.compare方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getEventTargetCell
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def getEventTargetCell(self, event):
td = DOM.eventGetTarget(event)
while td is not None:
if DOM.getAttribute(td, "tagName").lower() == "td":
tr = DOM.getParent(td)
body = DOM.getParent(tr)
if DOM.compare(body, self.bodyElem):
return td
if DOM.compare(td, self.bodyElem):
return None
td = DOM.getParent(td)
return None
示例2: getSelectedTextElements
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def getSelectedTextElements(self, startNode=None, endNode=None):
"""
Returns all text nodes between (and including) two arbitrary text nodes.
Caller must ensure startNode comes before endNode.
@param startNode start node to traverse
@param endNode end node to finish traversal
@return A list of all text nodes between these two text nodes
"""
if startNode is None and endNode is None:
startNode = self.m_startPoint.getTextNode()
endNode = self.m_endPoint.getTextNode()
res = []
# print "getSelectedTextElements", startNode, endNode
current = startNode
while (current is not None) and (not DOM.compare(current, endNode)):
res.append(current)
current = RangeUtil.getAdjacentTextElement(current, None, True, False)
if current is None:
# With the old way this could have been backwards, but should not
# happen now, so this is an error
res = None
else:
res.append(current)
return res
示例3: getDividerIndex
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def getDividerIndex(self, elem):
while (elem is not None) and not DOM.compare(elem, self.getElement()):
expando = self._getIndex(elem)
if expando is not None:
return int(expando)
elem = DOM.getParent(elem)
return -1
示例4: setCurrentTargetElement
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def setCurrentTargetElement(self, element):
if self._currentTargetElement is not None:
if not DOM.compare(self._currentTargetElement, element):
# leave_event = self.makeDragEvent(self.mouseEvent, 'dragleave',
# self.currentTargetElement)
self.fireDNDEvent('dragleave', self.currentTargetElement,
self.currentDropWidget)
# self.currentDropWidget.onDragLeave(leave_event)
# self.finalize(leave_event)
self._currentTargetElement = element
示例5: equals
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def equals(self, obj):
res = False
try:
comp = obj
res = (comp == self) or \
(DOM.compare(comp.getNode(), self.getNode()) and \
(comp.getOffset() == self.getOffset()))
except ex:
pass
return res
示例6: compareTo
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def compareTo(self, arg0):
Candidate other = (Candidate) arg0
Element myElement = getDropTarget().getElement()
Element otherElement = other.getDropTarget().getElement()
if DOM.compare(myElement, otherElement):
return 0
elif DOM.isOrHasChild(myElement, otherElement):
return -1
elif DOM.isOrHasChild(otherElement, myElement):
return 1
else:
return 0
示例7: findItemByChain
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def findItemByChain(self, chain, idx, root):
if idx == len(chain):
return root
hCurElem = chain[idx]
for i in range(root.getChildCount()):
child = root.getChild(i)
if DOM.compare(child.getElement(), hCurElem):
retItem = self.findItemByChain(chain, idx + 1, root.getChild(i))
if retItem is None:
return child
return retItem
return self.findItemByChain(chain, idx + 1, root)
示例8: elementClicked
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def elementClicked(self, root, hElem):
chain = []
self.collectElementChain(chain, self.getElement(), hElem)
item = self.findItemByChain(chain, 0, root)
if item is not None:
if DOM.compare(item.getImageElement(), hElem):
item.setState(not item.getState(), True)
return True
elif DOM.isOrHasChild(item.getElement(), hElem):
self.onSelection(item, True)
return True
return False
示例9: getAdjacentTextElement
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def getAdjacentTextElement(current, topMostNode, forward=None, traversingUp=False):
if forward is None:
forward = topMostNode
topMostNode = None
res = None
#print "getAdjacentTextElement", current, topMostNode, forward, traversingUp
# If traversingUp, then the children have already been processed
if not traversingUp:
if DOM.getChildCount(current) > 0:
if forward:
node = DOM.getFirstChild(current)
else:
node = DOM.getLastChild(current)
if DOM.getNodeType(node) == DOM.TEXT_NODE:
res = node
else:
# Depth first traversal, the recursive call deals with
# siblings
res = getAdjacentTextElement(node, topMostNode,
forward, False)
if res is None:
if forward:
node = current.nextSibling
else:
node = current.previousSibling
# Traverse siblings
if node is not None:
if DOM.getNodeType(node) == DOM.TEXT_NODE:
res = node
else:
#print node, DOM.getNodeType(node), node.innerHTML
# Depth first traversal, the recursive call deals with
# siblings
res = getAdjacentTextElement(node, topMostNode,
forward, False)
# Go up and over if still not found
if (res is None) and (not DOM.compare(current, topMostNode)):
node = current.parentNode
# Stop at document (technically could stop at "html" tag)
if (node is not None) and \
(DOM.getNodeType(node) != DOM.DOCUMENT_NODE):
res = getAdjacentTextElement(node, topMostNode,
forward, True)
return res
示例10: doDrag
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def doDrag(self, event, x, y):
self.dragBusy = True
#self.dragDataStore.dropEffect = 'none'
drag_event = self.fireDNDEvent('drag', None, self.dragWidget)
# drag event was not canceled
if not isCanceled(drag_event):
target = None
widget = None
# Find the most specific element under the cursor and the widget
# with the drop listener for it.
for widget in self.dropTargets:
target = getElementUnderMouse(widget, x, y)
if target is not None:
break
if target:
drop_widget = widget
drop_element = target
if (not self.currentTargetElement or
not DOM.compare(drop_element, self.currentTargetElement)):
# enter_event = self.makeDragEvent(event,'dragenter',
# drop_element)
enter_event = self.fireDNDEvent('dragenter', drop_element,
drop_widget)
# drop_widget.onDragEnter(enter_event)
# self.finalize(enter_event)
if isCanceled(enter_event):
self.currentTargetElement = drop_element
self.currentDropWidget = drop_widget
if self.currentTargetElement is not None:
# disable dropping if over event is not canceled
# over_event = self.makeDragEvent(event, 'dragover',
# drop_element)
over_event = self.fireDNDEvent('dragover', drop_element,
self.currentDropWidget)
# self.currentDropWidget.onDragOver(over_event)
# self.finalize(over_event)
if isCanceled(over_event):
self.updateDragOperation(over_event)
else:
self.currentDragOperation = 'none'
self.draggingImage.updateCursor(self.currentDragOperation)
else:
self.currentTargetElement = None
else:
self.currentDragOperation = 'none'
self.dragBusy = False
示例11: collectElementChain
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def collectElementChain(self, chain, hRoot, hElem):
if (hElem is None) or DOM.compare(hElem, hRoot):
return
self.collectElementChain(chain, hRoot, DOM.getParent(hElem))
chain.append(hElem)
示例12: appendAndMaybeAdopt
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import compare [as 别名]
def appendAndMaybeAdopt(self, parent, child, beingAdded):
if beingAdded is not None:
if DOM.compare(child, beingAdded.getElement()):
CellPanel.add(self, beingAdded, parent)
return
DOM.appendChild(parent, child)