コード例 #1
0
def viewRelationshipSet(modelXbrl, tabWin, arcrole, 
                        linkrole=None, linkqname=None, arcqname=None, lang=None, 
                        treeColHdr=None, showLinkroles=True, showRelationships=True, showColumns=True,
                        expandAll=False, hasTableIndex=False):
    arcroleName = groupRelationshipLabel(arcrole)
    relationshipSet = groupRelationshipSet(modelXbrl, arcrole, linkrole, linkqname, arcqname)
    if not relationshipSet:
        modelXbrl.modelManager.addToLog(_("no relationships for {0}").format(arcroleName))
        return False
    modelXbrl.modelManager.showStatus(_("viewing relationships {0}").format(arcroleName))
    view = ViewRelationshipSet(modelXbrl, tabWin, arcrole, linkrole, linkqname, arcqname, lang, 
                               treeColHdr, showLinkroles, showRelationships, showColumns,
                               expandAll, hasTableIndex)
    view.view(firstTime=True, relationshipSet=relationshipSet)
    view.treeView.bind("<<TreeviewSelect>>", view.treeviewSelect, '+')
    view.treeView.bind("<Enter>", view.treeviewEnter, '+')
    view.treeView.bind("<Leave>", view.treeviewLeave, '+')
    
    # pop up menu
    menu = view.contextMenu()
    view.menuAddExpandCollapse()
    view.menuAddClipboard()
    view.menuAddLangs()
    view.menuAddLabelRoles(includeConceptName=True)
    view.menuAddViews()
コード例 #2
0
def viewRelationshipSet(modelXbrl, tabWin, arcrole, 
                        linkrole=None, linkqname=None, arcqname=None, lang=None, 
                        treeColHdr=None, showLinkroles=True, showRelationships=True, showColumns=True,
                        expandAll=False, hasTableIndex=False):
    arcroleName = groupRelationshipLabel(arcrole)
    relationshipSet = groupRelationshipSet(modelXbrl, arcrole, linkrole, linkqname, arcqname)
    if not relationshipSet:
        modelXbrl.modelManager.addToLog(_("no relationships for {0}").format(arcroleName))
        return False
    modelXbrl.modelManager.showStatus(_("viewing relationships {0}").format(arcroleName))
    view = ViewRelationshipSet(modelXbrl, tabWin, arcrole, linkrole, linkqname, arcqname, lang, 
                               treeColHdr, showLinkroles, showRelationships, showColumns,
                               expandAll, hasTableIndex)
    view.view(firstTime=True, relationshipSet=relationshipSet)
    view.treeView.bind("<<TreeviewSelect>>", view.treeviewSelect, '+')
    view.treeView.bind("<Enter>", view.treeviewEnter, '+')
    view.treeView.bind("<Leave>", view.treeviewLeave, '+')
    
    # pop up menu
    menu = view.contextMenu()
    view.menuAddExpandCollapse()
    view.menuAddClipboard()
    view.menuAddLangs()
    view.menuAddLabelRoles(includeConceptName=True)
    view.menuAddViews()
コード例 #3
0
    def view(self, firstTime=False, relationshipSet=None):
        self.blockSelectEvent = 1
        self.blockViewModelObject = 0
        self.tag_has = defaultdict(list) # temporary until Tk 8.6
        # relationship set based on linkrole parameter, to determine applicable linkroles
        if relationshipSet is None:
            relationshipSet = groupRelationshipSet(self.modelXbrl, self.arcrole, self.linkrole, self.linkqname, self.arcqname)
        if not relationshipSet:
            self.modelXbrl.modelManager.addToLog(_("no relationships for {0}").format(groupRelationshipLabel(self.arcrole)))
            return False
        
        if firstTime:
            self.showReferences = False
            # set up treeView widget and tabbed pane
            hdr = self.treeColHdr if self.treeColHdr else _("{0} Relationships").format(groupRelationshipLabel(self.arcrole))
            self.treeView.heading("#0", text=hdr)
            if self.showColumns:
                if self.arcrole == XbrlConst.parentChild: # extra columns
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("preferredLabel", "type", "references")
                    self.treeView.column("preferredLabel", width=64, anchor="w", stretch=False)
                    self.treeView.heading("preferredLabel", text=_("Pref. Label"))
                    self.treeView.column("type", width=100, anchor="w", stretch=False)
                    self.treeView.heading("type", text=_("Type"))
                    self.treeView.column("references", width=200, anchor="w", stretch=False)
                    self.treeView.heading("references", text=_("References"))
                elif self.arcrole == XbrlConst.summationItem: # extra columns
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("weight", "balance")
                    self.treeView.column("weight", width=48, anchor="w", stretch=False)
                    self.treeView.heading("weight", text=_("Weight"))
                    self.treeView.column("balance", width=70, anchor="w", stretch=False)
                    self.treeView.heading("balance", text=_("Balance"))
                elif self.arcrole == "XBRL-dimensions":    # add columns for dimensional information
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("arcrole", "contextElement", "closed", "usable")
                    self.treeView.column("arcrole", width=100, anchor="w", stretch=False)
                    self.treeView.heading("arcrole", text="Arcrole")
                    self.treeView.column("contextElement", width=50, anchor="center", stretch=False)
                    self.treeView.heading("contextElement", text="Context")
                    self.treeView.column("closed", width=40, anchor="center", stretch=False)
                    self.treeView.heading("closed", text="Closed")
                    self.treeView.column("usable", width=40, anchor="center", stretch=False)
                    self.treeView.heading("usable", text="Usable")
                elif self.arcrole == "Table-rendering":    # add columns for dimensional information
                    self.treeView.column("#0", width=160, anchor="w")
                    self.treeView["columns"] = ("axis", "abstract", "merge", "header", "priItem", "dims")
                    self.treeView.column("axis", width=28, anchor="center", stretch=False)
                    self.treeView.heading("axis", text="Axis")
                    self.treeView.column("abstract", width=24, anchor="center", stretch=False)
                    self.treeView.heading("abstract", text="Abs")
                    self.treeView.column("merge", width=26, anchor="center", stretch=False)
                    self.treeView.heading("merge", text="Mrg")
                    self.treeView.column("header", width=160, anchor="w", stretch=False)
                    self.treeView.heading("header", text="Header")
                    self.treeView.column("priItem", width=100, anchor="w", stretch=False)
                    self.treeView.heading("priItem", text="Primary Item")
                    self.treeView.column("dims", width=150, anchor="w", stretch=False)
                    self.treeView.heading("dims", text=_("Dimensions"))
                elif isinstance(self.arcrole, (list,tuple)) or XbrlConst.isResourceArcrole(self.arcrole):
                    self.isResourceArcrole = True
                    self.showReferences = isinstance(self.arcrole, _STR_BASE) and self.arcrole.endswith("-reference")
                    self.treeView.column("#0", width=160, anchor="w")
                    self.treeView["columns"] = ("arcrole", "resource", "resourcerole", "lang")
                    self.treeView.column("arcrole", width=100, anchor="w", stretch=False)
                    self.treeView.heading("arcrole", text="Arcrole")
                    self.treeView.column("resource", width=60, anchor="w", stretch=False)
                    self.treeView.heading("resource", text="Resource")
                    self.treeView.column("resourcerole", width=100, anchor="w", stretch=False)
                    self.treeView.heading("resourcerole", text="Resource Role")
                    self.treeView.column("lang", width=36, anchor="w", stretch=False)
                    self.treeView.heading("lang", text="Lang")
        self.clearTreeView()
        self.id = 1
        
        # sort URIs by definition
        linkroleUris = []
        for linkroleUri in relationshipSet.linkRoleUris:
            modelRoleTypes = self.modelXbrl.roleTypes.get(linkroleUri)
            if modelRoleTypes:
                roledefinition = ((self.hasTableIndex and getattr(modelRoleTypes[0], "_tableIndex", False)) or
                                  modelRoleTypes[0].genLabel(lang=self.lang, strip=True) or 
                                  modelRoleTypes[0].definition or 
                                  linkroleUri)
                roleId = modelRoleTypes[0].objectId(self.id)
            else:
                roledefinition = linkroleUri
                roleId = "node{0}".format(self.id)
            self.id += 1
            linkroleUris.append((roledefinition, linkroleUri, roleId))
        linkroleUris.sort()
        # for each URI in definition order
        tableGroup = ""
        for roledefinition, linkroleUri, roleId in linkroleUris:
            if self.showLinkroles:
                if isinstance(roledefinition, tuple): # tableGroup
                    nextTableGroup, order, roledefinition = roledefinition
                    if tableGroup != nextTableGroup:
                        self.treeView.insert("", "end", nextTableGroup, text=nextTableGroup[1:], tags=("Group",))
                        if not tableGroup: # first tableGroup item, expand it
                            self.setTreeItemOpen(nextTableGroup,open=True)
                        tableGroup = nextTableGroup
                linknode = self.treeView.insert(tableGroup, "end", roleId, text=roledefinition, tags=("ELR",))
            else:
                linknode = ""
            if self.showRelationships:
                linkRelationshipSet = groupRelationshipSet(self.modelXbrl, self.arcrole, linkroleUri, self.linkqname, self.arcqname)
                for rootConcept in linkRelationshipSet.rootConcepts:
                    self.viewConcept(rootConcept, rootConcept, "", self.labelrole, linknode, 1, linkRelationshipSet, set())
                    self.tag_has[linkroleUri].append(linknode)

        if self.expandAllOnFirstDisplay:
            self.expandAll()
コード例 #4
0
    def view(self, firstTime=False, relationshipSet=None):
        self.blockSelectEvent = 1
        self.blockViewModelObject = 0
        self.tag_has = defaultdict(list)  # temporary until Tk 8.6
        # relationship set based on linkrole parameter, to determine applicable linkroles
        if relationshipSet is None:
            relationshipSet = groupRelationshipSet(self.modelXbrl,
                                                   self.arcrole, self.linkrole,
                                                   self.linkqname,
                                                   self.arcqname)
        if not relationshipSet:
            self.modelXbrl.modelManager.addToLog(
                _("no relationships for {0}").format(
                    groupRelationshipLabel(self.arcrole)))
            return False

        if firstTime:
            self.showReferences = False
            # set up treeView widget and tabbed pane
            hdr = self.treeColHdr if self.treeColHdr else _(
                "{0} Relationships").format(
                    groupRelationshipLabel(self.arcrole))
            self.treeView.heading("#0", text=hdr)
            if self.isEbaTableIndex:
                # settings for the filing indicator column
                self.treeView.heading("#1", text='Filed')
                self.treeView.column("#1", width=40, anchor="w", stretch=False)
            if self.showColumns:
                if self.arcrole == XbrlConst.parentChild:  # extra columns
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("preferredLabel", "type",
                                                "references")
                    self.treeView.column("preferredLabel",
                                         width=64,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("preferredLabel",
                                          text=_("Pref. Label"))
                    self.treeView.column("type",
                                         width=100,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("type", text=_("Type"))
                    self.treeView.column("references",
                                         width=200,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("references", text=_("References"))
                elif self.arcrole == XbrlConst.summationItem:  # extra columns
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("weight", "balance")
                    self.treeView.column("weight",
                                         width=48,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("weight", text=_("Weight"))
                    self.treeView.column("balance",
                                         width=70,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("balance", text=_("Balance"))
                elif self.arcrole == "XBRL-dimensions":  # add columns for dimensional information
                    self.treeView.column("#0", width=300, anchor="w")
                    self.treeView["columns"] = ("arcrole", "contextElement",
                                                "closed", "usable")
                    self.treeView.column("arcrole",
                                         width=100,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("arcrole", text="Arcrole")
                    self.treeView.column("contextElement",
                                         width=50,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("contextElement", text="Context")
                    self.treeView.column("closed",
                                         width=40,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("closed", text="Closed")
                    self.treeView.column("usable",
                                         width=40,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("usable", text="Usable")
                elif self.arcrole == "Table-rendering":  # add columns for dimensional information
                    self.treeView.column("#0", width=160, anchor="w")
                    self.treeView["columns"] = ("axis", "abstract", "merge",
                                                "header", "priItem", "dims")
                    self.treeView.column("axis",
                                         width=28,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("axis", text="Axis")
                    self.treeView.column("abstract",
                                         width=24,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("abstract", text="Abs")
                    self.treeView.column("merge",
                                         width=26,
                                         anchor="center",
                                         stretch=False)
                    self.treeView.heading("merge", text="Mrg")
                    self.treeView.column("header",
                                         width=160,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("header", text="Header")
                    self.treeView.column("priItem",
                                         width=100,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("priItem", text="Primary Item")
                    self.treeView.column("dims",
                                         width=150,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("dims", text=_("Dimensions"))
                elif isinstance(self.arcrole,
                                (list, tuple)) or XbrlConst.isResourceArcrole(
                                    self.arcrole):
                    self.isResourceArcrole = True
                    self.showReferences = isinstance(
                        self.arcrole,
                        _STR_BASE) and self.arcrole.endswith("-reference")
                    self.treeView.column("#0", width=160, anchor="w")
                    self.treeView["columns"] = ("arcrole", "resource",
                                                "resourcerole", "lang")
                    self.treeView.column("arcrole",
                                         width=100,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("arcrole", text="Arcrole")
                    self.treeView.column("resource",
                                         width=60,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("resource", text="Resource")
                    self.treeView.column("resourcerole",
                                         width=100,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("resourcerole", text="Resource Role")
                    self.treeView.column("lang",
                                         width=36,
                                         anchor="w",
                                         stretch=False)
                    self.treeView.heading("lang", text="Lang")
        self.clearTreeView()
        self.id = 1

        # sort URIs by definition
        linkroleUris = []
        linkroleUriChildren = {}
        for linkroleUri in relationshipSet.linkRoleUris:
            modelRoleTypes = self.modelXbrl.roleTypes.get(linkroleUri)
            if modelRoleTypes:
                roledefinition = (
                    (self.hasTableIndex
                     and getattr(modelRoleTypes[0], "_tableIndex", False))
                    or modelRoleTypes[0].genLabel(lang=self.lang, strip=True)
                    or modelRoleTypes[0].definition or linkroleUri)
                roleId = modelRoleTypes[0].objectId(self.id)
                if (self.hasTableIndex
                        and getattr(modelRoleTypes[0], "_tableChildren")):
                    linkroleUriChildren[linkroleUri] = [
                        roleType.roleURI
                        for roleType in modelRoleTypes[0]._tableChildren
                    ]
            else:
                roledefinition = linkroleUri
                roleId = "node{0}".format(self.id)
            self.id += 1
            linkroleUris.append((roledefinition, linkroleUri, roleId))
        linkroleUris.sort()

        def insertLinkroleChildren(parentNode, childUris):
            for childUri in childUris:
                for roledefinition, linkroleUri, roleId in linkroleUris:
                    if childUri == linkroleUri and isinstance(
                            roledefinition, tuple):  # tableGroup
                        _nextTableGroup, _order, roledefinition = roledefinition
                        childId = "_{}{}".format(self.id, roleId)
                        self.id += 1
                        childNode = self.treeView.insert(parentNode,
                                                         "end",
                                                         childId,
                                                         text=roledefinition,
                                                         tags=("ELR", ))
                        if childUri in linkroleUriChildren:
                            insertLinkroleChildren(
                                childNode, linkroleUriChildren[childUri])
                        break

        # for each URI in definition order
        tableGroup = ""
        for roledefinition, linkroleUri, roleId in linkroleUris:
            if self.showLinkroles:
                if isinstance(roledefinition, tuple):  # tableGroup
                    nextTableGroup, _order, roledefinition = roledefinition
                    if tableGroup != nextTableGroup:
                        self.treeView.insert("",
                                             "end",
                                             nextTableGroup,
                                             text=nextTableGroup[1:],
                                             tags=("Group", ))
                        if not tableGroup:  # first tableGroup item, expand it
                            self.setTreeItemOpen(nextTableGroup, open=True)
                        tableGroup = nextTableGroup
                linknode = self.treeView.insert(tableGroup,
                                                "end",
                                                roleId,
                                                text=roledefinition,
                                                tags=("ELR", ))
                # add tableChildren as child nodes
                if linkroleUri in linkroleUriChildren:
                    insertLinkroleChildren(linknode,
                                           linkroleUriChildren[linkroleUri])
            else:
                linknode = ""
            if self.showRelationships:
                linkRelationshipSet = groupRelationshipSet(
                    self.modelXbrl, self.arcrole, linkroleUri, self.linkqname,
                    self.arcqname)
                for rootConcept in linkRelationshipSet.rootConcepts:
                    self.viewConcept(rootConcept, rootConcept, "",
                                     self.labelrole, linknode, 1,
                                     linkRelationshipSet, set())
                    self.tag_has[linkroleUri].append(linknode)

        if self.expandAllOnFirstDisplay:
            self.expandAll()
コード例 #5
0
 def view(self, firstTime=False, relationshipSet=None):
     self.blockSelectEvent = 1
     self.blockViewModelObject = 0
     self.tag_has = defaultdict(list) # temporary until Tk 8.6
     # relationship set based on linkrole parameter, to determine applicable linkroles
     if relationshipSet is None:
         relationshipSet = groupRelationshipSet(self.modelXbrl, self.arcrole, self.linkrole, self.linkqname, self.arcqname)
     if not relationshipSet:
         self.modelXbrl.modelManager.addToLog(_("no relationships for {0}").format(groupRelationshipLabel(self.arcrole)))
         return False
     
     if firstTime:
         self.showReferences = False
         # set up treeView widget and tabbed pane
         hdr = self.treeColHdr if self.treeColHdr else _("{0} Relationships").format(groupRelationshipLabel(self.arcrole))
         self.treeView.heading("#0", text=hdr)
         if self.arcrole == XbrlConst.parentChild: # extra columns
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("type", "references")
             self.treeView.column("type", width=100, anchor="w", stretch=False)
             self.treeView.heading("type", text=_("Type"))
             self.treeView.column("references", width=200, anchor="w", stretch=False)
             self.treeView.heading("references", text=_("References"))
         elif self.arcrole == XbrlConst.summationItem: # extra columns
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("weight", "balance")
             self.treeView.column("weight", width=48, anchor="w", stretch=False)
             self.treeView.heading("weight", text=_("Weight"))
             self.treeView.column("balance", width=70, anchor="w", stretch=False)
             self.treeView.heading("balance", text=_("Balance"))
         elif self.arcrole == "XBRL-dimensions":    # add columns for dimensional information
             self.treeView.column("#0", width=300, anchor="w")
             self.treeView["columns"] = ("arcrole", "contextElement", "closed", "usable")
             self.treeView.column("arcrole", width=100, anchor="w", stretch=False)
             self.treeView.heading("arcrole", text="Arcrole")
             self.treeView.column("contextElement", width=50, anchor="center", stretch=False)
             self.treeView.heading("contextElement", text="Context")
             self.treeView.column("closed", width=40, anchor="center", stretch=False)
             self.treeView.heading("closed", text="Closed")
             self.treeView.column("usable", width=40, anchor="center", stretch=False)
             self.treeView.heading("usable", text="Usable")
         elif self.arcrole == "Table-rendering":    # add columns for dimensional information
             self.treeView.column("#0", width=160, anchor="w")
             self.treeView["columns"] = ("axis", "abstract", "header", "priItem", "dims")
             self.treeView.column("axis", width=28, anchor="center", stretch=False)
             self.treeView.heading("axis", text="Axis")
             self.treeView.column("abstract", width=24, anchor="center", stretch=False)
             self.treeView.heading("abstract", text="Abs")
             self.treeView.column("header", width=160, anchor="w", stretch=False)
             self.treeView.heading("header", text="Header")
             self.treeView.column("priItem", width=100, anchor="w", stretch=False)
             self.treeView.heading("priItem", text="Primary Item")
             self.treeView.column("dims", width=150, anchor="w", stretch=False)
             self.treeView.heading("dims", text=_("Dimensions"))
         elif isinstance(self.arcrole, (list,tuple)) or XbrlConst.isResourceArcrole(self.arcrole):
             self.isResourceArcrole = True
             self.showReferences = isinstance(self.arcrole, _STR_BASE) and self.arcrole.endswith("-reference")
             self.treeView.column("#0", width=160, anchor="w")
             self.treeView["columns"] = ("arcrole", "resource", "resourcerole", "lang")
             self.treeView.column("arcrole", width=100, anchor="w", stretch=False)
             self.treeView.heading("arcrole", text="Arcrole")
             self.treeView.column("resource", width=60, anchor="w", stretch=False)
             self.treeView.heading("resource", text="Resource")
             self.treeView.column("resourcerole", width=100, anchor="w", stretch=False)
             self.treeView.heading("resourcerole", text="Resource Role")
             self.treeView.column("lang", width=36, anchor="w", stretch=False)
             self.treeView.heading("lang", text="Lang")
     self.id = 1
     for previousNode in self.treeView.get_children(""): 
         self.treeView.delete(previousNode)
     # sort URIs by definition
     linkroleUris = []
     for linkroleUri in relationshipSet.linkRoleUris:
         modelRoleTypes = self.modelXbrl.roleTypes.get(linkroleUri)
         if modelRoleTypes:
             roledefinition = (modelRoleTypes[0].genLabel(lang=self.lang, strip=True) or modelRoleTypes[0].definition or linkroleUri)
             roleId = modelRoleTypes[0].objectId(self.id)
         else:
             roledefinition = linkroleUri
             roleId = "node{0}".format(self.id)
         self.id += 1
         linkroleUris.append((roledefinition, linkroleUri, roleId))
     linkroleUris.sort()
     # for each URI in definition order
     for roledefinition, linkroleUri, roleId in linkroleUris:
         linknode = self.treeView.insert("", "end", roleId, text=roledefinition, tags=("ELR",))
         linkRelationshipSet = groupRelationshipSet(self.modelXbrl, self.arcrole, linkroleUri, self.linkqname, self.arcqname)
         for rootConcept in linkRelationshipSet.rootConcepts:
             self.viewConcept(rootConcept, rootConcept, "", self.labelrole, linknode, 1, linkRelationshipSet, set())
             self.tag_has[linkroleUri].append(linknode)