Exemple #1
0
    def createCsCode(self, outputPath):
        dmDomain, dmClass = separateClassName(self.dataModel)

        osDomainPath = self.domain.replace(".", "/")
        osDomainPath = os.path.join(outputPath, osDomainPath)
        try:
            os.makedirs(osDomainPath)
        except Exception as x:
            print x.message

        #        print self.__getXamlCsCode()

        tData = self.xamlTemplate.substitute(
            dmdomain=dmDomain, dataModel=dmClass, content=self.layout.getCsCode(),

            domain=self.domain, title=self.title, name=self.name)

        filePath = os.path.join(osDomainPath, str(self) + ".xaml")
        #        filePath = os.path.join(outputPath, filePath)

        extraFilePath = os.path.join(osDomainPath, str(self) + ".xaml.cs")
        with open(filePath, 'w') as f:
            f.write(tData)

        with open(extraFilePath, 'w') as f:
            f.write(self.__getXamlCsCode())
Exemple #2
0
        def fillMainAttributes():
            mainPage.fillAttributes(objectModel.attrib)

            #            rindex = mainPage.dataModel.rfind(".")
            #            dataModelPackage = mainPage.dataModel[:rindex]
            #            dataModelClass = mainPage.dataModel[rindex + 1:]
            dataModelPackage, dataModelClass = separateClassName(mainPage.dataModel)
            #            dataModelClass = mainPage.dataModel[rindex + 1:]
            if not domains.has_key(dataModelPackage):
                raise Exception("Data model package %s not found!" % dataModelPackage)
                #            if not domains[dataModelPackage].hasClass(dataModelClass):
                #                raise Exception, "Data model Class %s not found!" % dataModelClass
            if not domains.searchItemName(dataModelPackage, dataModelClass):
                raise Exception, "Class %s in package %s has not found!" % (dataModelClass, dataModelClass)
Exemple #3
0
        def fillFreeWidgets():
            if not mainPage.layout:
                raise Exception, "Layout path in the page not defined"

            layoutPackage, layoutName = separateClassName(mainPage.layout)
            if not domains.has_key(layoutPackage):
                raise Exception, "Package %s not defined in layout packages" % layoutPackage
            l = domains.searchItemName(layoutPackage, layoutName)
            if not l:
                raise Exception, "Layout %s not defined in layout packages" % layoutName
            locations = UniqueMap()

            for w in objectModel.getchildren():
                if w.tag == "comment" or (type(w) is not StringElement and type(w) is not ObjectifiedElement):
                    continue
                name = removeNSFromValue(w.tag)

                #                widget = selectWidget(name)

                if name == "layout":
                    raise  Exception, "Layout in free widget!"
                else:
                    widget = createWidgetFromXMLObject(w)
                    #                    widget.fillAttributes(w.attrib)
                    #                    mainPage.addWidget(widget)
                    locations[widget.location] = widget
                    mainPage.widgetNames.append(widget.name)

            for row in l.rows:
                for cell in row.cells:
                    widget = locations.pop(cell.name)
                    if widget:
                        cell.addWidget(widget)

            if len(locations) > 0:
                raise Exception, "There is some unknown location in layout %s of package %s" % (
                    layoutName, layoutPackage)
            mainPage.layout = l