diff options
author | t-espave <unknown> | 2011-07-26 15:31:27 -0700 |
---|---|---|
committer | t-espave <unknown> | 2011-07-26 15:31:27 -0700 |
commit | 2ae20b9061caba69e43a479481b5179c5db80805 (patch) | |
tree | f1182bc81fc35ded32a11f65eacfb25afd88da12 /BCT/PhoneControlsExtractor | |
parent | d19feaa3cbda4dd6cd01d2c28b565ea46ab4b004 (diff) |
tracking new controls
Diffstat (limited to 'BCT/PhoneControlsExtractor')
-rw-r--r-- | BCT/PhoneControlsExtractor/PhoneControlsExtractor.py | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/BCT/PhoneControlsExtractor/PhoneControlsExtractor.py b/BCT/PhoneControlsExtractor/PhoneControlsExtractor.py index d56351da..b16e9bfe 100644 --- a/BCT/PhoneControlsExtractor/PhoneControlsExtractor.py +++ b/BCT/PhoneControlsExtractor/PhoneControlsExtractor.py @@ -4,13 +4,13 @@ import os from xml.dom import minidom
import xml.dom
-CONTROL_NAMES= ["Button", "CheckBox", "RadioButton"]
+CONTROL_NAMES= ["Button", "CheckBox", "RadioButton", "ApplicationBarIconButton"]
# TODO maybe a control is enabled but its parent is not, must take this into account
# TODO a possible solution is to tie the enabled value to that of the parent in the app until it is either overriden
# TODO (by directly manipulating the control's enabled value) or the parent becomes enabled
-CONTAINER_CONTROL_NAMES= ["Canvas", "Grid", "StackPanel"]
+CONTAINER_CONTROL_NAMES= ["Canvas", "Grid", "StackPanel", "ApplicationBar"]
staticControlsMap= {}
mainPageXAML= None
@@ -54,6 +54,25 @@ def getControlNodes(xmlNode): return controlNodes
+def addDummyControlToMap(pageXAML, parentPage):
+ pageControls=[]
+ newControl={}
+ try:
+ pageControls= staticControlsMap[parentPage]
+ except KeyError:
+ pass
+
+ newControl["Type"]= "DummyType"
+ newControl["Name"]= "DummyName"
+ newControl["IsEnabled"]= "false"
+ newControl["Visibility"]= "Collapsed"
+ newControl["Click"] = ""
+ newControl["Checked"] = ""
+ newControl["Unchecked"] = ""
+ newControl["XAML"]= pageXAML
+ pageControls.append(newControl)
+ staticControlsMap[parentPage]= pageControls
+
def addControlToMap(pageXAML, parentPage, controlNode):
pageControls=[]
newControl={}
@@ -91,14 +110,31 @@ def extractPhoneControlsFromPage(pageXAML): pageFile.close()
removeBlankElements(pageFileXML)
controls= getControlNodes(pageFileXML)
- ownerPage = None
- for control in controls:
- parent= control
- while not parent == None and ownerPage == None:
- if parent.localName == "PhoneApplicationPage":
- ownerPage= parent.getAttribute("x:Class")
- parent= parent.parentNode
- addControlToMap(pageXAML, ownerPage, control)
+ ownerPage = getOwnerPage(pageFileXML)
+ if (ownerPage != None):
+ if (len(controls) == 0):
+ # it is either a page with no controls, or controls that are dynamically created, or controls we do not track yet
+ # in any case, just add a dummy control so as not to lose the page
+ addDummyControlToMap(pageXAML, ownerPage)
+ else:
+ for control in controls:
+ parent= control
+ while not parent == None and ownerPage == None:
+ parent= parent.parentNode
+ addControlToMap(pageXAML, ownerPage, control)
+
+def getOwnerPage(xmlNode):
+ ownerPage= None
+ if (xmlNode.nodeType == xml.dom.Node.ELEMENT_NODE and xmlNode.localName == "PhoneApplicationPage"):
+ ownerPage= xmlNode.getAttribute("x:Class")
+ else:
+ for child in xmlNode.childNodes:
+ ownerPage= getOwnerPage(child)
+ if (ownerPage != None):
+ break
+
+ return ownerPage
+
def outputPhoneControls(outputFileName):
outputFile= open(outputFileName, "w")
|