Exemplo n.º 1
0
Arquivo: list.py Projeto: Xeon2003/vi
    def setFields(self, fields):
        if not self._structure:
            self._tableHeaderIsValid = False
            return

        boneInfoList = []
        tmpDict = {key: bone for key, bone in self._structure}

        fields = [x for x in fields if x in tmpDict.keys()]
        self.columns = fields

        for boneName in fields:
            boneInfo = tmpDict[boneName]
            delegateFactory = viewDelegateSelector.select(
                self.module, boneName, tmpDict)(self.module, boneName, tmpDict)
            self.table.setCellRender(boneName, delegateFactory)
            boneInfoList.append(boneInfo)

        if conf["showBoneNames"]:
            self.table.setHeader(fields)
        else:
            self.table.setHeader([x.get("descr", "") for x in boneInfoList])

        self.table.setShownFields(fields)
        rendersDict = {}

        for boneName in fields:
            boneInfo = tmpDict[boneName]
            delegateFactory = viewDelegateSelector.select(
                self.module, boneName, tmpDict)(self.module, boneName, tmpDict)
            rendersDict[boneName] = delegateFactory
            boneInfoList.append(boneInfo)

        self.table.setCellRenders(rendersDict)
        self._tableHeaderIsValid = True
Exemplo n.º 2
0
	def __init__(self, modul, structure, item, *args, **kwargs):
		super( InternalPreview, self ).__init__( *args, **kwargs )

		self["class"].append("internalpreview")

		tmpDict = {key: bone for key, bone in structure}

		for key, bone in structure:
			if "params" in bone.keys() and bone[ "params" ] \
					and "previewBone" in bone[ "params" ].keys() \
						and bone[ "params" ][ "previewBone" ] == False:
				continue

			self.ali= html5.Li()
			self.ali["class"]=[ modul,"type_"+bone["type"],"bone_"+key]
			self.adl= html5.Dl()

			self.adt=html5.Dt()
			self.adt.appendChild(html5.TextNode(key if conf["showBoneNames"] else bone.get("descr", key)))

			self.aadd=html5.Dd()
			delegateFactory = viewDelegateSelector.select( modul, key, tmpDict )( modul, key, tmpDict )
			self.aadd.appendChild(delegateFactory.render( item, key ))

			self.adl.appendChild(self.adt)
			self.adl.appendChild(self.aadd)
			self.ali.appendChild(self.adl)

			self.appendChild(self.ali)
Exemplo n.º 3
0
	def buildDescription(self):
		"""
			Creates the visual representation of our entry
		"""
		# Find any bones in the structure having "frontend_default_visible" set.
		hasDescr = False

		for boneName, boneInfo in self.structure:
			if "params" in boneInfo.keys() and isinstance(boneInfo["params"], dict):
				params = boneInfo["params"]
				if "frontend_default_visible" in params and params["frontend_default_visible"]:
					structure = {k: v for k, v in self.structure}
					wdg = viewDelegateSelector.select(self.module, boneName, structure)

					if wdg is not None:
						self.appendChild(wdg(self.module, boneName, structure).render(self.data, boneName))
						hasDescr = True

		# In case there is no bone configured for visualization, use a format-string
		if not hasDescr:
			format = "$(name)" #default fallback

			if self.module in conf["modules"].keys():
				moduleInfo = conf["modules"][self.module]
				if "format" in moduleInfo.keys():
					format = moduleInfo["format"]

			self.appendChild(html5.utils.unescape(
				utils.formatString(format, self.data, self.structure,
				    language=conf["currentlanguage"])))
Exemplo n.º 4
0
	def buildDescription(self):
		"""
			Creates the visual representation of our entry
		"""
		hasDescr = False
		for boneName, boneInfo in self.structure:
			if "params" in boneInfo.keys() and isinstance(boneInfo["params"], dict):
				params = boneInfo["params"]
				if "frontend_default_visible" in params.keys() and params["frontend_default_visible"]:

					structure = {k: v for k, v in self.structure}
					wdg = viewDelegateSelector.select(self.module, boneName, structure)

					if wdg is not None:
						self.appendChild(wdg(self.module, boneName, structure).render(self.data, boneName))
						hasDescr = True
		if not hasDescr:
			self.appendChild(html5.TextNode(self.data["name"]))