<s> '''<STR_LIT>''' <EOL> import os , threading , time , logging <EOL> from tkinter import Menu , BooleanVar , font as tkFont <EOL> from arelle import ( ViewWinTkTable , ModelDocument , ModelDtsObject , ModelInstanceObject , XbrlConst , <EOL> ModelXbrl , Locale , FunctionXfi , <EOL> ValidateXbrlDimensions ) <EOL> from arelle . ModelValue import qname , QName <EOL> from arelle . RenderingResolver import resolveAxesStructure , RENDER_UNITS_PER_CHAR <EOL> from arelle . ModelFormulaObject import Aspect , aspectModels , aspectModelAspect <EOL> from arelle . ModelInstanceObject import ModelDimensionValue <EOL> from arelle . ModelRenderingObject import ( ModelClosedDefinitionNode , ModelEuAxisCoord , <EOL> ModelFilterDefinitionNode , <EOL> OPEN_ASPECT_ENTRY_SURROGATE ) <EOL> from arelle . FormulaEvaluator import init as formulaEvaluatorInit , aspectMatches <EOL> from arelle . PrototypeInstanceObject import FactPrototype <EOL> from arelle . UITkTable import XbrlTable <EOL> from arelle . DialogNewFactItem import getNewFactItemOptions <EOL> from collections import defaultdict <EOL> from arelle . ValidateXbrl import ValidateXbrl <EOL> from arelle . XbrlConst import eurofilingModelNamespace , eurofilingModelPrefix <EOL> from arelle . ValidateXbrlDimensions import isFactDimensionallyValid <EOL> from arelle . XmlValidate import UNVALIDATED , validate as xmlValidate <EOL> try : <EOL> from tkinter import ttk <EOL> _Combobox = ttk . Combobox <EOL> except ImportError : <EOL> from ttk import Combobox <EOL> _Combobox = Combobox <EOL> emptyList = [ ] <EOL> ENTRY_WIDTH_IN_CHARS = <NUM_LIT:12> <EOL> ENTRY_WIDTH_SCREEN_UNITS = <NUM_LIT:100> <EOL> PADDING = <NUM_LIT:20> <EOL> qnPercentItemType = qname ( "<STR_LIT>" ) <EOL> qnPureItemType = qname ( "<STR_LIT>" ) <EOL> integerItemTypes = { "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" } <EOL> TABLE_AXIS_ROLES = ( XbrlConst . euTableAxis , XbrlConst . tableBreakdown , XbrlConst . tableBreakdownMMDD , XbrlConst . tableBreakdown201305 , XbrlConst . tableBreakdown201301 , XbrlConst . tableAxis2011 ) <EOL> '''<STR_LIT>''' <EOL> def getTableAxisArcroles ( ) : <EOL> return TABLE_AXIS_ROLES <EOL> def viewRenderedGrid ( modelXbrl , tabWin , lang = None ) : <EOL> modelXbrl . modelManager . showStatus ( _ ( "<STR_LIT>" ) ) <EOL> view = ViewRenderedGrid ( modelXbrl , tabWin , lang ) <EOL> view . blockMenuEvents = <NUM_LIT:1> <EOL> menu = view . contextMenu ( ) <EOL> optionsMenu = Menu ( view . viewFrame , tearoff = <NUM_LIT:0> ) <EOL> optionsMenu . add_command ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , command = lambda : getNewFactItemOptions ( modelXbrl . modelManager . cntlr , view . newFactItemOptions ) ) <EOL> optionsMenu . add_command ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , command = view . setOpenBreakdownEntryRows ) <EOL> view . ignoreDimValidity . trace ( "<STR_LIT:w>" , view . viewReloadDueToMenuAction ) <EOL> optionsMenu . add_checkbutton ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , variable = view . ignoreDimValidity , onvalue = True , offvalue = False ) <EOL> view . xAxisChildrenFirst . trace ( "<STR_LIT:w>" , view . viewReloadDueToMenuAction ) <EOL> optionsMenu . add_checkbutton ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , variable = view . xAxisChildrenFirst , onvalue = True , offvalue = False ) <EOL> view . yAxisChildrenFirst . trace ( "<STR_LIT:w>" , view . viewReloadDueToMenuAction ) <EOL> optionsMenu . add_checkbutton ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , variable = view . yAxisChildrenFirst , onvalue = True , offvalue = False ) <EOL> menu . add_cascade ( label = _ ( "<STR_LIT>" ) , menu = optionsMenu , underline = <NUM_LIT:0> ) <EOL> view . tablesMenu = Menu ( view . viewFrame , tearoff = <NUM_LIT:0> ) <EOL> menu . add_cascade ( label = _ ( "<STR_LIT>" ) , menu = view . tablesMenu , underline = <NUM_LIT:0> ) <EOL> view . tablesMenuLength = <NUM_LIT:0> <EOL> view . menuAddLangs ( ) <EOL> saveMenu = Menu ( view . viewFrame , tearoff = <NUM_LIT:0> ) <EOL> saveMenu . add_command ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , command = lambda : view . modelXbrl . modelManager . cntlr . fileSave ( view = view , fileType = "<STR_LIT:html>" ) ) <EOL> saveMenu . add_command ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , command = lambda : view . modelXbrl . modelManager . cntlr . fileSave ( view = view , fileType = "<STR_LIT>" ) ) <EOL> saveMenu . add_command ( label = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> , command = view . saveInstance ) <EOL> menu . add_cascade ( label = _ ( "<STR_LIT>" ) , menu = saveMenu , underline = <NUM_LIT:0> ) <EOL> view . view ( ) <EOL> view . blockSelectEvent = <NUM_LIT:1> <EOL> view . blockViewModelObject = <NUM_LIT:0> <EOL> view . viewFrame . bind ( "<STR_LIT>" , view . cellEnter , '<STR_LIT:+>' ) <EOL> view . viewFrame . bind ( "<STR_LIT>" , view . cellLeave , '<STR_LIT:+>' ) <EOL> view . viewFrame . bind ( "<STR_LIT>" , view . onQuitView , '<STR_LIT:+>' ) <EOL> view . viewFrame . bind ( "<STR_LIT>" , view . onClick , '<STR_LIT:+>' ) <EOL> view . viewFrame . bind ( "<STR_LIT>" , view . onConfigure , '<STR_LIT:+>' ) <EOL> view . blockMenuEvents = <NUM_LIT:0> <EOL> return view <EOL> class ViewRenderedGrid ( ViewWinTkTable . ViewTkTable ) : <EOL> def __init__ ( self , modelXbrl , tabWin , lang ) : <EOL> super ( ViewRenderedGrid , self ) . __init__ ( modelXbrl , tabWin , _ ( "<STR_LIT>" ) , <EOL> False , lang , self . onQuitView ) <EOL> self . newFactItemOptions = ModelInstanceObject . NewFactItemOptions ( xbrlInstance = modelXbrl ) <EOL> self . factPrototypes = [ ] <EOL> self . aspectEntryObjectIdsNode = { } <EOL> self . aspectEntryObjectIdsCell = { } <EOL> self . factPrototypeAspectEntryObjectIds = defaultdict ( set ) <EOL> self . zOrdinateChoices = None <EOL> self . options = self . modelXbrl . modelManager . cntlr . config . setdefault ( "<STR_LIT>" , { } ) <EOL> self . openBreakdownLines = self . options . setdefault ( "<STR_LIT>" , <NUM_LIT:5> ) <EOL> self . ignoreDimValidity = BooleanVar ( value = self . options . setdefault ( "<STR_LIT>" , True ) ) <EOL> self . xAxisChildrenFirst = BooleanVar ( value = self . options . setdefault ( "<STR_LIT>" , True ) ) <EOL> self . yAxisChildrenFirst = BooleanVar ( value = self . options . setdefault ( "<STR_LIT>" , False ) ) <EOL> formulaEvaluatorInit ( ) <EOL> def close ( self ) : <EOL> super ( ViewRenderedGrid , self ) . close ( ) <EOL> if self . modelXbrl : <EOL> for fp in self . factPrototypes : <EOL> fp . clear ( ) <EOL> self . factPrototypes = None <EOL> self . aspectEntryObjectIdsNode . clear ( ) <EOL> self . aspectEntryObjectIdsCell . clear ( ) <EOL> self . rendrCntx = None <EOL> def loadTablesMenu ( self ) : <EOL> tblMenuEntries = { } <EOL> tblRelSet = self . modelXbrl . relationshipSet ( "<STR_LIT>" ) <EOL> self . tablesToELR = { } <EOL> for tblLinkroleUri in tblRelSet . linkRoleUris : <EOL> for tableAxisArcrole in getTableAxisArcroles ( ) : <EOL> tblAxisRelSet = self . modelXbrl . relationshipSet ( tableAxisArcrole , tblLinkroleUri ) <EOL> if tblAxisRelSet and len ( tblAxisRelSet . modelRelationships ) > <NUM_LIT:0> : <EOL> modelRoleTypes = self . modelXbrl . roleTypes . get ( tblLinkroleUri ) <EOL> if modelRoleTypes is not None and len ( modelRoleTypes ) > <NUM_LIT:0> : <EOL> roledefinition = modelRoleTypes [ <NUM_LIT:0> ] . definition <EOL> if roledefinition is None or roledefinition == "<STR_LIT>" : <EOL> roledefinition = os . path . basename ( tblLinkroleUri ) <EOL> for table in tblAxisRelSet . rootConcepts : <EOL> tblMenuEntries [ roledefinition ] = tblLinkroleUri <EOL> self . tablesToELR [ table . objectId ( ) ] = tblLinkroleUri <EOL> break <EOL> self . tablesMenu . delete ( <NUM_LIT:0> , self . tablesMenuLength ) <EOL> self . tablesMenuLength = <NUM_LIT:0> <EOL> self . tblELR = None <EOL> for tblMenuEntry in sorted ( tblMenuEntries . items ( ) ) : <EOL> tbl , elr = tblMenuEntry <EOL> self . tablesMenu . add_command ( label = tbl , command = lambda e = elr : self . view ( viewTblELR = e ) ) <EOL> self . tablesMenuLength += <NUM_LIT:1> <EOL> if self . tblELR is None : <EOL> self . tblELR = elr <EOL> def viewReloadDueToMenuAction ( self , * args ) : <EOL> if not self . blockMenuEvents : <EOL> self . options [ "<STR_LIT>" ] = self . ignoreDimValidity . get ( ) <EOL> self . options [ "<STR_LIT>" ] = self . xAxisChildrenFirst . get ( ) <EOL> self . options [ "<STR_LIT>" ] = self . yAxisChildrenFirst . get ( ) <EOL> self . view ( ) <EOL> def setOpenBreakdownEntryRows ( self , * args ) : <EOL> import tkinter . simpledialog <EOL> newValue = tkinter . simpledialog . askinteger ( _ ( "<STR_LIT>" ) , <EOL> _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) . format ( self . options [ "<STR_LIT>" ] ) , <EOL> parent = self . tabWin ) <EOL> if newValue is not None : <EOL> self . options [ "<STR_LIT>" ] = self . openBreakdownLines = newValue <EOL> self . viewReloadDueToMenuAction ( ) <EOL> def view ( self , viewTblELR = None , newInstance = None , profile = False ) : <EOL> '''<STR_LIT>''' <EOL> startedAt = time . time ( ) <EOL> self . blockMenuEvents += <NUM_LIT:1> <EOL> if newInstance is not None : <EOL> self . modelXbrl = newInstance <EOL> clearZchoices = False <EOL> if viewTblELR : <EOL> self . tblELR = viewTblELR <EOL> clearZchoices = True <EOL> else : <EOL> clearZchoices = self . zOrdinateChoices is None <EOL> if clearZchoices : <EOL> self . loadTablesMenu ( ) <EOL> viewTblELR = self . tblELR <EOL> if not self . tblELR : <EOL> return <EOL> if clearZchoices : <EOL> self . zOrdinateChoices = { } <EOL> self . viewFrame . clearGrid ( ) <EOL> tblAxisRelSet , xTopStructuralNode , yTopStructuralNode , zTopStructuralNode = resolveAxesStructure ( self , viewTblELR ) <EOL> colAdjustment = <NUM_LIT:1> if zTopStructuralNode is not None else <NUM_LIT:0> <EOL> self . table . resizeTable ( self . dataFirstRow + self . dataRows - <NUM_LIT:1> , self . dataFirstCol + self . dataCols + colAdjustment - <NUM_LIT:1> , titleRows = self . dataFirstRow - <NUM_LIT:1> , titleColumns = self . dataFirstCol - <NUM_LIT:1> ) <EOL> self . hasTableFilters = bool ( self . modelTable . filterRelationships ) <EOL> if tblAxisRelSet : <EOL> fontWidth = tkFont . Font ( font = '<STR_LIT>' ) . configure ( ) [ '<STR_LIT:size>' ] <EOL> fontWidth = fontWidth * <NUM_LIT:3> // <NUM_LIT:2> <EOL> dataColsAllowanceWidth = ( fontWidth * ENTRY_WIDTH_IN_CHARS + PADDING ) * self . dataCols + PADDING <EOL> frameWidth = self . viewFrame . winfo_width ( ) <EOL> if dataColsAllowanceWidth + self . rowHdrWrapLength > frameWidth : <EOL> if dataColsAllowanceWidth > frameWidth / <NUM_LIT:2> : <EOL> rowHdrAllowanceWidth = frameWidth / <NUM_LIT:2> <EOL> else : <EOL> rowHdrAllowanceWidth = frameWidth - dataColsAllowanceWidth <EOL> if self . rowHdrWrapLength > rowHdrAllowanceWidth : <EOL> widthRatio = rowHdrAllowanceWidth / self . rowHdrWrapLength <EOL> self . rowHdrWrapLength = rowHdrAllowanceWidth <EOL> fixedWidth = sum ( w for w in self . rowHdrColWidth if w <= RENDER_UNITS_PER_CHAR ) <EOL> adjustableWidth = sum ( w for w in self . rowHdrColWidth if w > RENDER_UNITS_PER_CHAR ) <EOL> if adjustableWidth > <NUM_LIT:0> : <EOL> widthRatio = ( rowHdrAllowanceWidth - fixedWidth ) / adjustableWidth <EOL> for i in range ( len ( self . rowHdrColWidth ) ) : <EOL> w = self . rowHdrColWidth [ i ] <EOL> if w > RENDER_UNITS_PER_CHAR : <EOL> self . rowHdrColWidth [ i ] = int ( w * widthRatio ) <EOL> self . aspectEntryObjectIdsNode . clear ( ) <EOL> self . aspectEntryObjectIdsCell . clear ( ) <EOL> self . factPrototypeAspectEntryObjectIds . clear ( ) <EOL> self . table . initHeaderCellValue ( ( self . modelTable . genLabel ( lang = self . lang , strip = True ) or <EOL> self . roledefinition ) , <EOL> <NUM_LIT:0> , <NUM_LIT:0> , ( self . dataFirstCol - <NUM_LIT:2> ) , <EOL> ( self . dataFirstRow - <NUM_LIT:2> ) , <EOL> XbrlTable . TG_TOP_LEFT_JUSTIFIED ) <EOL> self . zAspectStructuralNodes = defaultdict ( set ) <EOL> self . zAxis ( <NUM_LIT:1> , zTopStructuralNode , clearZchoices ) <EOL> xStructuralNodes = [ ] <EOL> colsFoundPlus1 , _ , _ , _ = self . xAxis ( self . dataFirstCol , self . colHdrTopRow , self . colHdrTopRow + self . colHdrRows - <NUM_LIT:1> , <EOL> xTopStructuralNode , xStructuralNodes , self . xAxisChildrenFirst . get ( ) , True , True ) <EOL> _ , rowsFoundPlus1 = self . yAxis ( <NUM_LIT:1> , self . dataFirstRow , <EOL> yTopStructuralNode , self . yAxisChildrenFirst . get ( ) , True , True ) <EOL> self . table . resizeTable ( rowsFoundPlus1 - <NUM_LIT:1> , <EOL> colsFoundPlus1 + colAdjustment - <NUM_LIT:1> , <EOL> clearData = False ) <EOL> for fp in self . factPrototypes : <EOL> if fp is not None : <EOL> fp . clear ( ) <EOL> self . factPrototypes = [ ] <EOL> self . bodyCells ( self . dataFirstRow , yTopStructuralNode , xStructuralNodes , self . zAspectStructuralNodes , self . yAxisChildrenFirst . get ( ) ) <EOL> self . table . clearModificationStatus ( ) <EOL> self . table . disableUnusedCells ( ) <EOL> self . table . resizeTableCells ( ) <EOL> self . modelXbrl . profileStat ( "<STR_LIT>" + os . path . basename ( viewTblELR ) , time . time ( ) - startedAt ) <EOL> self . blockMenuEvents -= <NUM_LIT:1> <EOL> def zAxis ( self , row , zStructuralNode , clearZchoices ) : <EOL> if zStructuralNode is not None : <EOL> label = zStructuralNode . header ( lang = self . lang ) <EOL> xValue = self . dataFirstCol - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initHeaderCellValue ( label , <EOL> xValue , yValue , <EOL> <NUM_LIT:0> , <NUM_LIT:0> , <EOL> XbrlTable . TG_LEFT_JUSTIFIED , <EOL> objectId = zStructuralNode . objectId ( ) ) <EOL> if zStructuralNode . choiceStructuralNodes is not None : <EOL> valueHeaders = [ '<STR_LIT>' . ljust ( zChoiceStructuralNode . indent * <NUM_LIT:4> ) + <EOL> ( zChoiceStructuralNode . header ( lang = self . lang ) or '<STR_LIT>' ) <EOL> for zChoiceStructuralNode in zStructuralNode . choiceStructuralNodes ] <EOL> zAxisIsOpenExplicitDimension = False <EOL> zAxisTypedDimension = None <EOL> i = zStructuralNode . choiceNodeIndex <EOL> comboBoxValue = None if i >= <NUM_LIT:0> else zStructuralNode . aspects . get ( '<STR_LIT>' ) <EOL> chosenStructuralNode = zStructuralNode . choiceStructuralNodes [ i ] <EOL> aspect = None <EOL> for aspect in chosenStructuralNode . aspectsCovered ( ) : <EOL> if aspect != Aspect . DIMENSIONS : <EOL> break <EOL> zAxisAspectEntryMode = False <EOL> if isinstance ( chosenStructuralNode . definitionNode , ModelFilterDefinitionNode ) : <EOL> if isinstance ( aspect , QName ) : <EOL> dimConcept = self . modelXbrl . qnameConcepts [ aspect ] <EOL> if dimConcept . isExplicitDimension : <EOL> if len ( valueHeaders ) != <NUM_LIT:1> or valueHeaders [ <NUM_LIT:0> ] : <EOL> valueHeaders . append ( "<STR_LIT>" ) <EOL> else : <EOL> valueHeaders . extend ( <EOL> self . explicitDimensionFilterMembers ( zStructuralNode , chosenStructuralNode ) ) <EOL> zAxisAspectEntryMode = True <EOL> zAxisIsOpenExplicitDimension = True <EOL> elif dimConcept . isTypedDimension : <EOL> if ( zStructuralNode . choiceStructuralNodes [ <NUM_LIT:0> ] . contextItemBinding is None and <EOL> not valueHeaders [ <NUM_LIT:0> ] ) : <EOL> '''<STR_LIT>''' <EOL> if i >= <NUM_LIT:0> : <EOL> chosenStructuralNode = zStructuralNode . choiceStructuralNodes [ i ] <EOL> else : <EOL> chosenStructuralNode = zStructuralNode <EOL> if not comboBoxValue and not valueHeaders : <EOL> comboBoxValue = "<STR_LIT>" <EOL> i = - <NUM_LIT:1> <EOL> valueHeaders . append ( "<STR_LIT>" ) <EOL> zAxisTypedDimension = dimConcept <EOL> combobox = self . table . initHeaderCombobox ( self . dataFirstCol , <EOL> row - <NUM_LIT:1> , <EOL> colspan = <NUM_LIT:0> , <EOL> values = valueHeaders , <EOL> value = comboBoxValue , <EOL> selectindex = zStructuralNode . choiceNodeIndex if i >= <NUM_LIT:0> else None , <EOL> comboboxselected = self . onZComboBoxSelected ) <EOL> combobox . zStructuralNode = zStructuralNode <EOL> combobox . zAxisIsOpenExplicitDimension = zAxisIsOpenExplicitDimension <EOL> combobox . zAxisTypedDimension = zAxisTypedDimension <EOL> combobox . zAxisAspectEntryMode = zAxisAspectEntryMode <EOL> combobox . zAxisAspect = aspect <EOL> combobox . zChoiceOrdIndex = row - <NUM_LIT:1> <EOL> combobox . objectId = zStructuralNode . objectId ( ) <EOL> self . setZStructuralNodeAspects ( chosenStructuralNode ) <EOL> else : <EOL> self . setZStructuralNodeAspects ( zStructuralNode ) <EOL> for zStructuralNode in zStructuralNode . childStructuralNodes : <EOL> self . zAxis ( row + <NUM_LIT:1> , zStructuralNode , clearZchoices ) <EOL> def setZStructuralNodeAspects ( self , zStructuralNode , add = True ) : <EOL> for aspect in aspectModels [ self . aspectModel ] : <EOL> if ( aspect in zStructuralNode . aspects or <EOL> zStructuralNode . hasAspect ( aspect , inherit = True ) ) : <EOL> if aspect == Aspect . DIMENSIONS : <EOL> for dim in ( zStructuralNode . aspectValue ( Aspect . DIMENSIONS , inherit = True ) or emptyList ) : <EOL> if add : <EOL> self . zAspectStructuralNodes [ dim ] . add ( zStructuralNode ) <EOL> else : <EOL> self . zAspectStructuralNodes [ dim ] . discard ( zStructuralNode ) <EOL> else : <EOL> if add : <EOL> self . zAspectStructuralNodes [ aspect ] . add ( zStructuralNode ) <EOL> else : <EOL> self . zAspectStructuralNodes [ aspect ] . discard ( zStructuralNode ) <EOL> def onZComboBoxSelected ( self , event ) : <EOL> combobox = event . widget <EOL> structuralNode = combobox . zStructuralNode <EOL> if combobox . zAxisAspectEntryMode : <EOL> aspectValue = structuralNode . aspectEntryHeaderValues . get ( combobox . get ( ) ) <EOL> if aspectValue is not None : <EOL> self . zOrdinateChoices [ structuralNode . definitionNode ] = structuralNode . aspects = { combobox . zAxisAspect : aspectValue , '<STR_LIT>' : combobox . get ( ) } <EOL> self . view ( ) <EOL> elif combobox . zAxisIsOpenExplicitDimension and combobox . get ( ) == "<STR_LIT>" : <EOL> self . comboboxLoadExplicitDimension ( combobox , <EOL> structuralNode , <EOL> structuralNode . choiceStructuralNodes [ structuralNode . choiceNodeIndex ] ) <EOL> structuralNode . choiceNodeIndex = - <NUM_LIT:1> <EOL> combobox . zAxisAspectEntryMode = True <EOL> elif combobox . zAxisTypedDimension is not None and combobox . get ( ) == "<STR_LIT>" : <EOL> import tkinter . simpledialog <EOL> result = tkinter . simpledialog . askstring ( _ ( "<STR_LIT>" ) , <EOL> combobox . zAxisTypedDimension . label ( ) , <EOL> parent = self . tabWin ) <EOL> if result : <EOL> structuralNode . choiceNodeIndex = - <NUM_LIT:1> <EOL> aspectValue = FunctionXfi . create_element ( self . rendrCntx , <EOL> None , <EOL> ( combobox . zAxisTypedDimension . typedDomainElement . qname , ( ) , result ) ) <EOL> self . zOrdinateChoices [ structuralNode . definitionNode ] = structuralNode . aspects = { combobox . zAxisAspect : aspectValue , <EOL> Aspect . DIMENSIONS : { combobox . zAxisTypedDimension . qname } , <EOL> '<STR_LIT>' : result } <EOL> if not hasattr ( structuralNode , "<STR_LIT>" ) : structuralNode . aspectEntryHeaderValues = { } <EOL> structuralNode . aspectEntryHeaderValues [ result ] = aspectValue <EOL> valueHeaders = list ( combobox [ "<STR_LIT>" ] ) <EOL> if result not in valueHeaders : valueHeaders . insert ( <NUM_LIT:0> , result ) <EOL> combobox [ "<STR_LIT>" ] = valueHeaders <EOL> combobox . zAxisAspectEntryMode = True <EOL> self . view ( ) <EOL> else : <EOL> self . setZStructuralNodeAspects ( structuralNode . choiceStructuralNodes [ structuralNode . choiceNodeIndex ] , add = False ) <EOL> i = combobox . valueIndex <EOL> self . zOrdinateChoices [ combobox . zStructuralNode . definitionNode ] = structuralNode . choiceNodeIndex = i <EOL> self . setZStructuralNodeAspects ( structuralNode . choiceStructuralNodes [ i ] ) <EOL> self . view ( ) <EOL> def xAxis ( self , leftCol , topRow , rowBelow , xParentStructuralNode , xStructuralNodes , childrenFirst , renderNow , atTop ) : <EOL> if xParentStructuralNode is not None : <EOL> parentRow = rowBelow <EOL> noDescendants = True <EOL> rightCol = leftCol <EOL> widthToSpanParent = <NUM_LIT:0> <EOL> for xStructuralNode in xParentStructuralNode . childStructuralNodes : <EOL> if not xStructuralNode . isRollUp : <EOL> noDescendants = False <EOL> isLabeled = xStructuralNode . isLabeled <EOL> isAbstract = ( xStructuralNode . isAbstract or <EOL> ( xStructuralNode . childStructuralNodes and <EOL> not isinstance ( xStructuralNode . definitionNode , ( ModelClosedDefinitionNode , ModelEuAxisCoord ) ) ) ) <EOL> isNonAbstract = not isAbstract <EOL> rightCol , row , width , leafNode = self . xAxis ( leftCol , topRow + isLabeled , rowBelow , xStructuralNode , xStructuralNodes , <EOL> childrenFirst , childrenFirst , False ) <EOL> if row - <NUM_LIT:1> < parentRow : <EOL> parentRow = row - <NUM_LIT:1> <EOL> if isNonAbstract and isLabeled : <EOL> width += ENTRY_WIDTH_SCREEN_UNITS <EOL> widthToSpanParent += width <EOL> if childrenFirst : <EOL> thisCol = rightCol <EOL> else : <EOL> thisCol = leftCol <EOL> if renderNow and isLabeled : <EOL> columnspan = ( rightCol - leftCol + ( <NUM_LIT:1> if isNonAbstract else <NUM_LIT:0> ) ) <EOL> label = xStructuralNode . header ( lang = self . lang , <EOL> returnGenLabel = isinstance ( xStructuralNode . definitionNode , ( ModelClosedDefinitionNode , ModelEuAxisCoord ) ) ) <EOL> if label != OPEN_ASPECT_ENTRY_SURROGATE : <EOL> xValue = leftCol - <NUM_LIT:1> <EOL> yValue = topRow - <NUM_LIT:1> <EOL> headerLabel = label if label else "<STR_LIT:U+0020>" <EOL> self . table . initHeaderCellValue ( headerLabel , <EOL> xValue , yValue , <EOL> columnspan - <NUM_LIT:1> , <EOL> ( ( row - topRow ) if leafNode else <NUM_LIT:0> ) , <EOL> XbrlTable . TG_CENTERED , <EOL> objectId = xStructuralNode . objectId ( ) , <EOL> isRollUp = columnspan > <NUM_LIT:1> and isNonAbstract and len ( xStructuralNode . childStructuralNodes ) < columnspan ) <EOL> else : <EOL> self . aspectEntryObjectIdsNode [ xStructuralNode . aspectEntryObjectId ] = xStructuralNode <EOL> self . aspectEntryObjectIdsCell [ xStructuralNode . aspectEntryObjectId ] = self . table . initHeaderCombobox ( leftCol - <NUM_LIT:1> , <EOL> topRow - <NUM_LIT:1> , <EOL> values = self . aspectEntryValues ( xStructuralNode ) , <EOL> objectId = xStructuralNode . aspectEntryObjectId , <EOL> comboboxselected = self . onAspectComboboxSelection ) <EOL> if isNonAbstract : <EOL> xValue = thisCol - <NUM_LIT:1> <EOL> for i , role in enumerate ( self . colHdrNonStdRoles ) : <EOL> j = ( self . dataFirstRow <EOL> - len ( self . colHdrNonStdRoles ) + i ) - <NUM_LIT:1> <EOL> self . table . initHeaderCellValue ( xStructuralNode . header ( role = role , lang = self . lang ) , <EOL> xValue , <EOL> j , <EOL> <NUM_LIT:0> , <EOL> <NUM_LIT:0> , <EOL> XbrlTable . TG_CENTERED , <EOL> objectId = xStructuralNode . objectId ( ) ) <EOL> xStructuralNodes . append ( xStructuralNode ) <EOL> if isNonAbstract : <EOL> rightCol += <NUM_LIT:1> <EOL> if renderNow and not childrenFirst : <EOL> self . xAxis ( leftCol + ( <NUM_LIT:1> if isNonAbstract else <NUM_LIT:0> ) , topRow + isLabeled , rowBelow , xStructuralNode , xStructuralNodes , childrenFirst , True , False ) <EOL> leftCol = rightCol <EOL> return ( rightCol , parentRow , widthToSpanParent , noDescendants ) <EOL> def yAxis ( self , leftCol , row , yParentStructuralNode , childrenFirst , renderNow , atLeft ) : <EOL> if yParentStructuralNode is not None : <EOL> nestedBottomRow = row <EOL> for yStructuralNode in yParentStructuralNode . childStructuralNodes : <EOL> if not yStructuralNode . isRollUp : <EOL> isAbstract = ( yStructuralNode . isAbstract or <EOL> ( yStructuralNode . childStructuralNodes and <EOL> not isinstance ( yStructuralNode . definitionNode , ( ModelClosedDefinitionNode , ModelEuAxisCoord ) ) ) ) <EOL> isNonAbstract = not isAbstract <EOL> isLabeled = yStructuralNode . isLabeled <EOL> nestRow , nextRow = self . yAxis ( leftCol + isLabeled , row , yStructuralNode , <EOL> childrenFirst , childrenFirst , False ) <EOL> topRow = row <EOL> if childrenFirst and isNonAbstract : <EOL> row = nextRow <EOL> if renderNow and isLabeled : <EOL> columnspan = self . rowHdrCols - leftCol + <NUM_LIT:1> if isNonAbstract or nextRow == row else <NUM_LIT:1> <EOL> depth = yStructuralNode . depth <EOL> wraplength = ( self . rowHdrColWidth [ depth ] if isAbstract else <EOL> self . rowHdrWrapLength - sum ( self . rowHdrColWidth [ <NUM_LIT:0> : depth ] ) ) <EOL> if wraplength < <NUM_LIT:0> : <EOL> wraplength = self . rowHdrColWidth [ depth ] <EOL> label = yStructuralNode . header ( lang = self . lang , <EOL> returnGenLabel = isinstance ( yStructuralNode . definitionNode , ( ModelClosedDefinitionNode , ModelEuAxisCoord ) ) , <EOL> recurseParent = not isinstance ( yStructuralNode . definitionNode , ModelFilterDefinitionNode ) ) <EOL> if label != OPEN_ASPECT_ENTRY_SURROGATE : <EOL> xValue = leftCol - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initHeaderCellValue ( label if label is not None else "<STR_LIT:U+0020>" , <EOL> xValue , yValue , <EOL> columnspan - <NUM_LIT:1> , <EOL> ( nestRow - row if isAbstract else <NUM_LIT:1> ) - <NUM_LIT:1> , <EOL> ( XbrlTable . TG_LEFT_JUSTIFIED <EOL> if isNonAbstract or nestRow == row <EOL> else XbrlTable . TG_CENTERED ) , <EOL> objectId = yStructuralNode . objectId ( ) , <EOL> isRollUp = columnspan > <NUM_LIT:1> and isNonAbstract and ( len ( yStructuralNode . childStructuralNodes ) > <NUM_LIT:1> or ( len ( yStructuralNode . childStructuralNodes ) == <NUM_LIT:1> and not ( yStructuralNode . childStructuralNodes [ <NUM_LIT:0> ] . isAbstract ) ) ) ) <EOL> else : <EOL> self . aspectEntryObjectIdsNode [ yStructuralNode . aspectEntryObjectId ] = yStructuralNode <EOL> self . aspectEntryObjectIdsCell [ yStructuralNode . aspectEntryObjectId ] = self . table . initHeaderCombobox ( leftCol - <NUM_LIT:1> , <EOL> row - <NUM_LIT:1> , <EOL> values = self . aspectEntryValues ( yStructuralNode ) , <EOL> objectId = yStructuralNode . aspectEntryObjectId , <EOL> comboboxselected = self . onAspectComboboxSelection ) <EOL> if isNonAbstract : <EOL> for i , role in enumerate ( self . rowHdrNonStdRoles ) : <EOL> isCode = "<STR_LIT:code>" in role <EOL> docCol = self . dataFirstCol - len ( self . rowHdrNonStdRoles ) + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initHeaderCellValue ( yStructuralNode . header ( role = role , lang = self . lang ) , <EOL> docCol , yValue , <EOL> <NUM_LIT:0> , <NUM_LIT:0> , <EOL> XbrlTable . TG_CENTERED if isCode else XbrlTable . TG_RIGHT_JUSTIFIED , <EOL> objectId = yStructuralNode . objectId ( ) ) <EOL> if isNonAbstract : <EOL> row += <NUM_LIT:1> <EOL> elif childrenFirst : <EOL> row = nextRow <EOL> if nestRow > nestedBottomRow : <EOL> nestedBottomRow = nestRow + ( isNonAbstract and not childrenFirst ) <EOL> if row > nestedBottomRow : <EOL> nestedBottomRow = row <EOL> if not childrenFirst : <EOL> dummy , row = self . yAxis ( leftCol + isLabeled , row , yStructuralNode , childrenFirst , renderNow , False ) <EOL> return ( nestedBottomRow , row ) <EOL> def getbackgroundColor ( self , factPrototype ) : <EOL> bgColor = XbrlTable . TG_BG_DEFAULT <EOL> concept = factPrototype . concept <EOL> if concept == None : <EOL> return bgColor <EOL> isNumeric = concept . isNumeric <EOL> isInteger = concept . baseXbrliType in integerItemTypes <EOL> isPercent = concept . typeQname in ( qnPercentItemType , qnPureItemType ) <EOL> isString = concept . baseXbrliType in ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> isDate = concept . baseXbrliType in ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> if isNumeric : <EOL> if concept . isShares or isInteger : <EOL> bgColor = XbrlTable . TG_BG_ORANGE <EOL> elif isPercent : <EOL> bgColor = XbrlTable . TG_BG_YELLOW <EOL> elif isDate : <EOL> bgColor = XbrlTable . TG_BG_GREEN <EOL> elif isString : <EOL> bgColor = XbrlTable . TG_BG_VIOLET <EOL> return bgColor ; <EOL> def bodyCells ( self , row , yParentStructuralNode , xStructuralNodes , zAspectStructuralNodes , yChildrenFirst ) : <EOL> if yParentStructuralNode is not None : <EOL> dimDefaults = self . modelXbrl . qnameDimensionDefaults <EOL> for yStructuralNode in yParentStructuralNode . childStructuralNodes : <EOL> if yChildrenFirst : <EOL> row = self . bodyCells ( row , yStructuralNode , xStructuralNodes , zAspectStructuralNodes , yChildrenFirst ) <EOL> if not ( yStructuralNode . isAbstract or <EOL> ( yStructuralNode . childStructuralNodes and <EOL> not isinstance ( yStructuralNode . definitionNode , ( ModelClosedDefinitionNode , ModelEuAxisCoord ) ) ) ) and yStructuralNode . isLabeled : <EOL> isYEntryPrototype = yStructuralNode . isEntryPrototype ( default = False ) <EOL> yAspectStructuralNodes = defaultdict ( set ) <EOL> for aspect in aspectModels [ self . aspectModel ] : <EOL> if yStructuralNode . hasAspect ( aspect ) : <EOL> if aspect == Aspect . DIMENSIONS : <EOL> for dim in ( yStructuralNode . aspectValue ( Aspect . DIMENSIONS ) or emptyList ) : <EOL> yAspectStructuralNodes [ dim ] . add ( yStructuralNode ) <EOL> else : <EOL> yAspectStructuralNodes [ aspect ] . add ( yStructuralNode ) <EOL> yTagSelectors = yStructuralNode . tagSelectors <EOL> ignoreDimValidity = self . ignoreDimValidity . get ( ) <EOL> for i , xStructuralNode in enumerate ( xStructuralNodes ) : <EOL> isEntryPrototype = isYEntryPrototype or xStructuralNode . isEntryPrototype ( default = False ) <EOL> xAspectStructuralNodes = defaultdict ( set ) <EOL> for aspect in aspectModels [ self . aspectModel ] : <EOL> if xStructuralNode . hasAspect ( aspect ) : <EOL> if aspect == Aspect . DIMENSIONS : <EOL> for dim in ( xStructuralNode . aspectValue ( Aspect . DIMENSIONS ) or emptyList ) : <EOL> xAspectStructuralNodes [ dim ] . add ( xStructuralNode ) <EOL> else : <EOL> xAspectStructuralNodes [ aspect ] . add ( xStructuralNode ) <EOL> cellTagSelectors = yTagSelectors | xStructuralNode . tagSelectors <EOL> cellAspectValues = { } <EOL> matchableAspects = set ( ) <EOL> for aspect in _DICT_SET ( xAspectStructuralNodes . keys ( ) ) | _DICT_SET ( yAspectStructuralNodes . keys ( ) ) | _DICT_SET ( zAspectStructuralNodes . keys ( ) ) : <EOL> aspectValue = xStructuralNode . inheritedAspectValue ( yStructuralNode , <EOL> self , aspect , cellTagSelectors , <EOL> xAspectStructuralNodes , yAspectStructuralNodes , zAspectStructuralNodes ) <EOL> if ( isinstance ( aspect , _INT ) or <EOL> dimDefaults . get ( aspect ) != aspectValue or <EOL> aspectValue is not None ) : <EOL> cellAspectValues [ aspect ] = aspectValue <EOL> matchableAspects . add ( aspectModelAspect . get ( aspect , aspect ) ) <EOL> cellDefaultedDims = _DICT_SET ( dimDefaults ) - _DICT_SET ( cellAspectValues . keys ( ) ) <EOL> priItemQname = cellAspectValues . get ( Aspect . CONCEPT ) <EOL> concept = self . modelXbrl . qnameConcepts . get ( priItemQname ) <EOL> conceptNotAbstract = concept is None or not concept . isAbstract <EOL> value = None <EOL> objectId = None <EOL> justify = None <EOL> fp = FactPrototype ( self , cellAspectValues ) <EOL> if conceptNotAbstract : <EOL> facts = self . modelXbrl . factsByQname [ priItemQname ] if priItemQname else self . modelXbrl . factsInInstance <EOL> if self . hasTableFilters : <EOL> facts = self . modelTable . filterFacts ( self . rendrCntx , facts ) <EOL> for aspect in matchableAspects : <EOL> if isinstance ( aspect , QName ) : <EOL> aspectValue = cellAspectValues . get ( aspect , None ) <EOL> if isinstance ( aspectValue , ModelDimensionValue ) : <EOL> if aspectValue . isExplicit : <EOL> dimMemQname = aspectValue . memberQname <EOL> else : <EOL> dimMemQname = None <EOL> elif isinstance ( aspectValue , QName ) : <EOL> dimMemQname = aspectValue <EOL> elif aspectValue is None : <EOL> dimMemQname = ModelXbrl . DEFAULT <EOL> else : <EOL> dimMemQname = None <EOL> facts = facts & self . modelXbrl . factsByDimMemQname ( aspect , dimMemQname ) <EOL> if len ( facts ) == <NUM_LIT:0> : <EOL> break ; <EOL> for fact in facts : <EOL> if ( all ( aspectMatches ( self . rendrCntx , fact , fp , aspect ) <EOL> for aspect in matchableAspects ) and <EOL> all ( fact . context . dimMemberQname ( dim , includeDefaults = True ) in ( dimDefaults [ dim ] , None ) <EOL> for dim in cellDefaultedDims ) and <EOL> len ( fp . context . qnameDims ) == len ( fact . context . qnameDims ) ) : <EOL> if yStructuralNode . hasValueExpression ( xStructuralNode ) : <EOL> value = yStructuralNode . evalValueExpression ( fact , xStructuralNode ) <EOL> else : <EOL> value = fact . effectiveValue <EOL> objectId = fact . objectId ( ) <EOL> justify = XbrlTable . TG_RIGHT_JUSTIFIED if fact . isNumeric else XbrlTable . TG_LEFT_JUSTIFIED <EOL> break <EOL> if ( conceptNotAbstract and <EOL> ( value is not None or ignoreDimValidity or isFactDimensionallyValid ( self , fp ) or <EOL> isEntryPrototype ) ) : <EOL> if objectId is None : <EOL> objectId = "<STR_LIT>" . format ( len ( self . factPrototypes ) ) <EOL> self . factPrototypes . append ( fp ) <EOL> for aspect , aspectValue in cellAspectValues . items ( ) : <EOL> if isinstance ( aspectValue , str ) and aspectValue . startswith ( OPEN_ASPECT_ENTRY_SURROGATE ) : <EOL> self . factPrototypeAspectEntryObjectIds [ objectId ] . add ( aspectValue ) <EOL> modelConcept = fp . concept <EOL> if ( justify is None ) and modelConcept is not None : <EOL> justify = XbrlTable . TG_RIGHT_JUSTIFIED if modelConcept . isNumeric else XbrlTable . TG_LEFT_JUSTIFIED <EOL> if modelConcept is not None and modelConcept . isEnumeration : <EOL> myValidationObject = ValidateXbrl ( self . modelXbrl ) <EOL> myValidationObject . modelXbrl = self . modelXbrl <EOL> enumerationSet = ValidateXbrlDimensions . usableEnumerationMembers ( myValidationObject , modelConcept ) <EOL> enumerationDict = dict ( ) <EOL> for enumerationItem in enumerationSet : <EOL> enumerationDict [ enumerationItem . label ( linkrole = modelConcept . enumLinkrole ) ] = enumerationItem . qname <EOL> enumerationValues = sorted ( list ( enumerationDict . keys ( ) ) ) <EOL> enumerationQNameStrings = [ "<STR_LIT>" ] + list ( str ( enumerationDict [ enumerationItem ] ) for enumerationItem in enumerationValues ) <EOL> enumerationValues = [ "<STR_LIT>" ] + enumerationValues <EOL> try : <EOL> selectedIdx = enumerationQNameStrings . index ( value ) <EOL> effectiveValue = enumerationValues [ selectedIdx ] <EOL> except ValueError : <EOL> effectiveValue = enumerationValues [ <NUM_LIT:0> ] <EOL> selectedIdx = <NUM_LIT:0> <EOL> xValue = self . dataFirstCol + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initCellCombobox ( effectiveValue , <EOL> enumerationValues , <EOL> xValue , <EOL> yValue , <EOL> objectId = objectId , <EOL> selectindex = selectedIdx , <EOL> codes = enumerationDict ) <EOL> elif modelConcept is not None and modelConcept . type . qname == XbrlConst . qnXbrliQNameItemType : <EOL> if eurofilingModelPrefix in concept . nsmap and concept . nsmap . get ( eurofilingModelPrefix ) == eurofilingModelNamespace : <EOL> hierarchy = concept . get ( "<STR_LIT:{>" + eurofilingModelNamespace + "<STR_LIT:}>" + "<STR_LIT>" , None ) <EOL> domainQNameAsString = concept . get ( "<STR_LIT:{>" + eurofilingModelNamespace + "<STR_LIT:}>" + "<STR_LIT>" , None ) <EOL> if hierarchy is not None and domainQNameAsString is not None : <EOL> newAspectValues = [ "<STR_LIT>" ] <EOL> newAspectQNames = dict ( ) <EOL> newAspectQNames [ "<STR_LIT>" ] = None <EOL> domPrefix , _ , domLocalName = domainQNameAsString . strip ( ) . rpartition ( "<STR_LIT::>" ) <EOL> domNamespace = concept . nsmap . get ( domPrefix ) <EOL> relationships = concept_relationships ( self . rendrCntx , <EOL> None , <EOL> ( QName ( domPrefix , domNamespace , domLocalName ) , <EOL> hierarchy , <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' ) , <EOL> False ) <EOL> for rel in relationships : <EOL> if ( rel . arcrole in ( XbrlConst . dimensionDomain , XbrlConst . domainMember ) <EOL> and rel . isUsable ) : <EOL> header = rel . toModelObject . label ( lang = self . lang ) <EOL> newAspectValues . append ( header ) <EOL> currentQName = rel . toModelObject . qname <EOL> if str ( currentQName ) == value : <EOL> value = header <EOL> newAspectQNames [ header ] = currentQName <EOL> else : <EOL> newAspectValues = None <EOL> else : <EOL> newAspectValues = None <EOL> if newAspectValues is None : <EOL> xValue = self . dataFirstCol + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initCellValue ( value , <EOL> xValue , <EOL> yValue , <EOL> justification = justify , <EOL> objectId = objectId , <EOL> backgroundColourTag = self . getbackgroundColor ( fp ) ) <EOL> else : <EOL> qNameValues = newAspectValues <EOL> try : <EOL> selectedIdx = qNameValues . index ( value ) <EOL> effectiveValue = value <EOL> except ValueError : <EOL> effectiveValue = qNameValues [ <NUM_LIT:0> ] <EOL> selectedIdx = <NUM_LIT:0> <EOL> xValue = self . dataFirstCol + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initCellCombobox ( effectiveValue , <EOL> qNameValues , <EOL> xValue , <EOL> yValue , <EOL> objectId = objectId , <EOL> selectindex = selectedIdx , <EOL> codes = newAspectQNames ) <EOL> elif modelConcept is not None and modelConcept . type . qname == XbrlConst . qnXbrliBooleanItemType : <EOL> booleanValues = [ "<STR_LIT>" , <EOL> XbrlConst . booleanValueTrue , <EOL> XbrlConst . booleanValueFalse ] <EOL> try : <EOL> selectedIdx = booleanValues . index ( value ) <EOL> effectiveValue = value <EOL> except ValueError : <EOL> effectiveValue = booleanValues [ <NUM_LIT:0> ] <EOL> selectedIdx = <NUM_LIT:0> <EOL> xValue = self . dataFirstCol + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initCellCombobox ( effectiveValue , <EOL> booleanValues , <EOL> xValue , <EOL> yValue , <EOL> objectId = objectId , <EOL> selectindex = selectedIdx ) <EOL> else : <EOL> xValue = self . dataFirstCol + i - <NUM_LIT:1> <EOL> yValue = row - <NUM_LIT:1> <EOL> self . table . initCellValue ( value , <EOL> xValue , <EOL> yValue , <EOL> justification = justify , <EOL> objectId = objectId , <EOL> backgroundColourTag = self . getbackgroundColor ( fp ) ) <EOL> else : <EOL> fp . clear ( ) <EOL> row += <NUM_LIT:1> <EOL> if not yChildrenFirst : <EOL> row = self . bodyCells ( row , yStructuralNode , xStructuralNodes , zAspectStructuralNodes , yChildrenFirst ) <EOL> return row <EOL> def onClick ( self , event ) : <EOL> try : <EOL> objId = event . widget . objectId <EOL> if objId and objId [ <NUM_LIT:0> ] == "<STR_LIT:f>" : <EOL> viewableObject = self . factPrototypes [ int ( objId [ <NUM_LIT:1> : ] ) ] <EOL> else : <EOL> viewableObject = objId <EOL> self . modelXbrl . viewModelObject ( viewableObject ) <EOL> except AttributeError : <EOL> pass <EOL> self . modelXbrl . modelManager . cntlr . currentView = self <EOL> def cellEnter ( self , * args ) : <EOL> self . blockSelectEvent = <NUM_LIT:0> <EOL> self . modelXbrl . modelManager . cntlr . currentView = self <EOL> def cellLeave ( self , * args ) : <EOL> self . blockSelectEvent = <NUM_LIT:1> <EOL> def cellSelect ( self , * args ) : <EOL> if self . blockSelectEvent == <NUM_LIT:0> and self . blockViewModelObject == <NUM_LIT:0> : <EOL> self . blockViewModelObject += <NUM_LIT:1> <EOL> self . blockViewModelObject -= <NUM_LIT:1> <EOL> def viewModelObject ( self , modelObject ) : <EOL> if self . blockViewModelObject == <NUM_LIT:0> : <EOL> self . blockViewModelObject += <NUM_LIT:1> <EOL> try : <EOL> if isinstance ( modelObject , ModelDtsObject . ModelRelationship ) : <EOL> objectId = modelObject . toModelObject . objectId ( ) <EOL> else : <EOL> objectId = modelObject . objectId ( ) <EOL> if objectId in self . tablesToELR : <EOL> self . view ( viewTblELR = self . tablesToELR [ objectId ] ) <EOL> try : <EOL> self . modelXbrl . modelManager . cntlr . currentView = self . modelXbrl . guiViews . tableView <EOL> self . modelXbrl . guiViews . tableView . tabWin . select ( str ( self . modelXbrl . guiViews . tableView . viewFrame ) ) <EOL> except : <EOL> pass <EOL> except ( KeyError , AttributeError ) : <EOL> pass <EOL> self . blockViewModelObject -= <NUM_LIT:1> <EOL> def onConfigure ( self , event , * args ) : <EOL> if not self . blockMenuEvents : <EOL> lastFrameWidth = getattr ( self , "<STR_LIT>" , <NUM_LIT:0> ) <EOL> lastFrameHeight = getattr ( self , "<STR_LIT>" , <NUM_LIT:0> ) <EOL> frameWidth = self . tabWin . winfo_width ( ) <EOL> frameHeight = self . tabWin . winfo_height ( ) <EOL> if lastFrameWidth != frameWidth or lastFrameHeight != frameHeight : <EOL> self . updateInstanceFromFactPrototypes ( ) <EOL> self . lastFrameWidth = frameWidth <EOL> self . lastFrameHeight = frameHeight <EOL> self . setHeightAndWidth ( ) <EOL> if lastFrameWidth : <EOL> """<STR_LIT>""" <EOL> def deferredReload ( ) : <EOL> self . deferredReloadCount -= <NUM_LIT:1> <EOL> if self . deferredReloadCount <= <NUM_LIT:0> : <EOL> self . viewReloadDueToMenuAction ( ) <EOL> self . deferredReloadCount = getattr ( self , "<STR_LIT>" , <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> self . viewFrame . after ( <NUM_LIT> , deferredReload ) <EOL> def onQuitView ( self , event , * args ) : <EOL> self . updateInstanceFromFactPrototypes ( ) <EOL> self . updateProperties ( ) <EOL> def hasChangesToSave ( self ) : <EOL> return len ( self . table . modifiedCells ) <EOL> def updateProperties ( self ) : <EOL> if self . modelXbrl is not None : <EOL> modelXbrl = self . modelXbrl <EOL> if modelXbrl . modelDocument . type == ModelDocument . Type . INSTANCE : <EOL> tbl = self . table <EOL> coordinates = tbl . getCurrentCellCoordinates ( ) <EOL> if coordinates is not None : <EOL> objId = tbl . getObjectId ( coordinates ) <EOL> if objId is not None and len ( objId ) > <NUM_LIT:0> : <EOL> if objId and objId [ <NUM_LIT:0> ] == "<STR_LIT:f>" : <EOL> viewableObject = self . factPrototypes [ int ( objId [ <NUM_LIT:1> : ] ) ] <EOL> elif objId [ <NUM_LIT:0> ] != "<STR_LIT:a>" : <EOL> viewableObject = self . modelXbrl . modelObject ( objId ) <EOL> else : <EOL> return <EOL> modelXbrl . viewModelObject ( viewableObject ) <EOL> def updateInstanceFromFactPrototypes ( self ) : <EOL> if self . modelXbrl is not None and self . modelXbrl . modelDocument . type == ModelDocument . Type . INSTANCE : <EOL> instance = self . modelXbrl <EOL> cntlr = instance . modelManager . cntlr <EOL> newCntx = ModelXbrl . AUTO_LOCATE_ELEMENT <EOL> newUnit = ModelXbrl . AUTO_LOCATE_ELEMENT <EOL> tbl = self . table <EOL> aspectEntryChanges = { } <EOL> aspectEntryChangeIds = _DICT_SET ( aspectEntryChanges . keys ( ) ) <EOL> for modifiedCell in tbl . getCoordinatesOfModifiedCells ( ) : <EOL> objId = tbl . getObjectId ( modifiedCell ) <EOL> if objId is not None and len ( objId ) > <NUM_LIT:0> : <EOL> if tbl . isHeaderCell ( modifiedCell ) : <EOL> if objId [ <NUM_LIT:0> ] == OPEN_ASPECT_ENTRY_SURROGATE : <EOL> aspectEntryChanges [ objId ] = tbl . getTableValue ( modifiedCell ) <EOL> else : <EOL> cellIndex = str ( modifiedCell ) <EOL> comboboxCells = tbl . window_names ( cellIndex ) <EOL> if comboboxCells is not None and len ( comboboxCells ) > <NUM_LIT:0> : <EOL> comboName = tbl . window_cget ( cellIndex , '<STR_LIT>' ) <EOL> combobox = cntlr . parent . nametowidget ( comboName ) <EOL> else : <EOL> combobox = None <EOL> if isinstance ( combobox , _Combobox ) : <EOL> codeDict = combobox . codes <EOL> if len ( codeDict ) > <NUM_LIT:0> : <EOL> bodyCellValue = tbl . getTableValue ( modifiedCell ) <EOL> value = codeDict . get ( bodyCellValue , None ) <EOL> if value is None : <EOL> value = bodyCellValue <EOL> else : <EOL> value = tbl . getTableValue ( modifiedCell ) <EOL> else : <EOL> value = tbl . getTableValue ( modifiedCell ) <EOL> objId = tbl . getObjectId ( modifiedCell ) <EOL> if objId is not None and len ( objId ) > <NUM_LIT:0> : <EOL> if objId [ <NUM_LIT:0> ] == "<STR_LIT:f>" : <EOL> factPrototypeIndex = int ( objId [ <NUM_LIT:1> : ] ) <EOL> factPrototype = self . factPrototypes [ factPrototypeIndex ] <EOL> concept = factPrototype . concept <EOL> if concept is None : <EOL> if not self . conceptMessageIssued : <EOL> self . conceptMessageIssued = True <EOL> self . modelXbrl . modelManager . cntlr . showMessage ( _ ( "<STR_LIT>" ) ) <EOL> return <EOL> else : <EOL> self . conceptMessageIssued = False <EOL> entityIdentScheme = self . newFactItemOptions . entityIdentScheme <EOL> entityIdentValue = self . newFactItemOptions . entityIdentValue <EOL> periodType = concept . periodType <EOL> periodStart = self . newFactItemOptions . startDateDate if periodType == "<STR_LIT>" else None <EOL> periodEndInstant = self . newFactItemOptions . endDateDate <EOL> qnameDims = factPrototype . context . qnameDims <EOL> newAspectValues = self . newFactOpenAspects ( objId ) <EOL> if newAspectValues is None : <EOL> self . modelXbrl . modelManager . showStatus ( _ ( "<STR_LIT>" ) , <NUM_LIT> ) <EOL> continue <EOL> qnameDims . update ( newAspectValues ) <EOL> prevCntx = instance . matchContext ( <EOL> entityIdentScheme , entityIdentValue , periodType , periodStart , periodEndInstant , <EOL> qnameDims , [ ] , [ ] ) <EOL> if prevCntx is not None : <EOL> cntxId = prevCntx . id <EOL> else : <EOL> newCntx = instance . createContext ( entityIdentScheme , entityIdentValue , <EOL> periodType , periodStart , periodEndInstant , <EOL> concept . qname , qnameDims , [ ] , [ ] , <EOL> afterSibling = newCntx ) <EOL> cntxId = newCntx . id <EOL> if concept . isNumeric : <EOL> if concept . isMonetary : <EOL> unitMeasure = qname ( XbrlConst . iso4217 , self . newFactItemOptions . monetaryUnit ) <EOL> unitMeasure . prefix = "<STR_LIT>" <EOL> decimals = self . newFactItemOptions . monetaryDecimals <EOL> elif concept . isShares : <EOL> unitMeasure = XbrlConst . qnXbrliShares <EOL> decimals = self . newFactItemOptions . nonMonetaryDecimals <EOL> else : <EOL> unitMeasure = XbrlConst . qnXbrliPure <EOL> decimals = self . newFactItemOptions . nonMonetaryDecimals <EOL> prevUnit = instance . matchUnit ( [ unitMeasure ] , [ ] ) <EOL> if prevUnit is not None : <EOL> unitId = prevUnit . id <EOL> else : <EOL> newUnit = instance . createUnit ( [ unitMeasure ] , [ ] , afterSibling = newUnit ) <EOL> unitId = newUnit . id <EOL> attrs = [ ( "<STR_LIT>" , cntxId ) ] <EOL> if concept . isNumeric : <EOL> attrs . append ( ( "<STR_LIT>" , unitId ) ) <EOL> attrs . append ( ( "<STR_LIT>" , decimals ) ) <EOL> value = Locale . atof ( self . modelXbrl . locale , value , str . strip ) <EOL> newFact = instance . createFact ( concept . qname , attributes = attrs , text = value ) <EOL> tbl . setObjectId ( modifiedCell , <EOL> newFact . objectId ( ) ) <EOL> if self . factPrototypes [ factPrototypeIndex ] is not None : <EOL> self . factPrototypes [ factPrototypeIndex ] . clear ( ) <EOL> self . factPrototypes [ factPrototypeIndex ] = None <EOL> elif objId [ <NUM_LIT:0> ] != "<STR_LIT:a>" : <EOL> fact = self . modelXbrl . modelObject ( objId ) <EOL> if fact . concept . isNumeric : <EOL> value = Locale . atof ( self . modelXbrl . locale , value , str . strip ) <EOL> if fact . concept . isMonetary : <EOL> unitMeasure = qname ( XbrlConst . iso4217 , self . newFactItemOptions . monetaryUnit ) <EOL> unitMeasure . prefix = "<STR_LIT>" <EOL> decimals = self . newFactItemOptions . monetaryDecimals <EOL> elif fact . concept . isShares : <EOL> unitMeasure = XbrlConst . qnXbrliShares <EOL> decimals = self . newFactItemOptions . nonMonetaryDecimals <EOL> else : <EOL> unitMeasure = XbrlConst . qnXbrliPure <EOL> decimals = self . newFactItemOptions . nonMonetaryDecimals <EOL> if fact . value != str ( value ) : <EOL> if fact . isNil != ( not value ) : <EOL> fact . isNil = not value <EOL> if fact . isNil : <EOL> pass <EOL> if fact . concept . isNumeric and ( not fact . isNil ) : <EOL> fact . decimals = decimals <EOL> prevUnit = instance . matchUnit ( [ unitMeasure ] , [ ] ) <EOL> if prevUnit is not None : <EOL> unitId = prevUnit . id <EOL> else : <EOL> newUnit = instance . createUnit ( [ unitMeasure ] , [ ] , afterSibling = newUnit ) <EOL> unitId = newUnit . id <EOL> fact . unitID = unitId <EOL> fact . text = str ( value ) <EOL> instance . setIsModified ( ) <EOL> fact . xValid = UNVALIDATED <EOL> xmlValidate ( instance , fact ) <EOL> tbl . clearModificationStatus ( ) <EOL> def saveInstance ( self , newFilename = None , onSaved = None ) : <EOL> if ( not self . newFactItemOptions . entityIdentScheme or <EOL> not self . newFactItemOptions . entityIdentValue or <EOL> not self . newFactItemOptions . startDateDate or not self . newFactItemOptions . endDateDate ) : <EOL> if not getNewFactItemOptions ( self . modelXbrl . modelManager . cntlr , self . newFactItemOptions ) : <EOL> return <EOL> self . updateInstanceFromFactPrototypes ( ) <EOL> if self . modelXbrl . modelDocument . type != ModelDocument . Type . INSTANCE and newFilename is None : <EOL> newFilename = self . modelXbrl . modelManager . cntlr . fileSave ( view = self , fileType = "<STR_LIT>" ) <EOL> if not newFilename : <EOL> return <EOL> thread = threading . Thread ( target = lambda : self . backgroundSaveInstance ( newFilename , onSaved ) ) <EOL> thread . daemon = True <EOL> thread . start ( ) <EOL> def backgroundSaveInstance ( self , newFilename = None , onSaved = None ) : <EOL> cntlr = self . modelXbrl . modelManager . cntlr <EOL> if newFilename and self . modelXbrl . modelDocument . type != ModelDocument . Type . INSTANCE : <EOL> self . modelXbrl . modelManager . showStatus ( _ ( "<STR_LIT>" ) . format ( os . path . basename ( newFilename ) ) ) <EOL> self . modelXbrl . modelManager . cntlr . waitForUiThreadQueue ( ) <EOL> self . modelXbrl . createInstance ( newFilename ) <EOL> instance = self . modelXbrl <EOL> cntlr . showStatus ( _ ( "<STR_LIT>" ) . format ( instance . modelDocument . basename ) ) <EOL> cntlr . waitForUiThreadQueue ( ) <EOL> self . updateInstanceFromFactPrototypes ( ) <EOL> instance . saveInstance ( newFilename ) <EOL> cntlr . addToLog ( _ ( "<STR_LIT>" ) . format ( newFilename if newFilename is not None else instance . modelDocument . filepath ) ) <EOL> cntlr . showStatus ( _ ( "<STR_LIT>" ) . format ( instance . modelDocument . basename ) , clearAfter = <NUM_LIT> ) <EOL> if onSaved is not None : <EOL> self . modelXbrl . modelManager . cntlr . uiThreadQueue . put ( ( onSaved , [ ] ) ) <EOL> def newFactOpenAspects ( self , factObjectId ) : <EOL> aspectValues = { } <EOL> for aspectObjId in self . factPrototypeAspectEntryObjectIds [ factObjectId ] : <EOL> structuralNode = self . aspectEntryObjectIdsNode [ aspectObjId ] <EOL> for aspect in structuralNode . aspectsCovered ( ) : <EOL> if aspect != Aspect . DIMENSIONS : <EOL> break <EOL> gridCellItem = self . aspectEntryObjectIdsCell [ aspectObjId ] <EOL> value = gridCellItem . get ( ) <EOL> if value is not None and OPEN_ASPECT_ENTRY_SURROGATE in aspectObjId and len ( value ) == <NUM_LIT:0> : <EOL> return None <EOL> if value : <EOL> aspectValue = structuralNode . aspectEntryHeaderValues . get ( value ) <EOL> if aspectValue is None : <EOL> if isinstance ( aspect , QName ) : <EOL> dimConcept = self . modelXbrl . qnameConcepts [ aspect ] <EOL> if dimConcept . isExplicitDimension : <EOL> aspectValue = None <EOL> else : <EOL> typedDimElement = dimConcept . typedDomainElement <EOL> aspectValue = FunctionXfi . create_element ( <EOL> self . rendrCntx , None , ( typedDimElement . qname , ( ) , value ) ) <EOL> if aspectValue is not None : <EOL> aspectValues [ aspect ] = aspectValue <EOL> return aspectValues <EOL> def aspectEntryValues ( self , structuralNode ) : <EOL> for aspect in structuralNode . aspectsCovered ( ) : <EOL> if aspect != Aspect . DIMENSIONS : <EOL> break <EOL> depth = <NUM_LIT:0> <EOL> n = structuralNode <EOL> while ( n . parentStructuralNode is not None ) : <EOL> depth += <NUM_LIT:1> <EOL> root = n = n . parentStructuralNode <EOL> headers = set ( ) <EOL> headerValues = { } <EOL> def getHeaders ( n , d ) : <EOL> for childStructuralNode in n . childStructuralNodes : <EOL> if d == depth : <EOL> h = childStructuralNode . header ( lang = self . lang , <EOL> returnGenLabel = False , <EOL> returnMsgFormatString = False ) <EOL> if not childStructuralNode . isEntryPrototype ( ) and h : <EOL> headerValues [ h ] = childStructuralNode . aspectValue ( aspect ) <EOL> headers . add ( h ) <EOL> else : <EOL> getHeaders ( childStructuralNode , d + <NUM_LIT:1> ) <EOL> getHeaders ( root , <NUM_LIT:1> ) <EOL> structuralNode . aspectEntryHeaderValues = headerValues <EOL> headersList = sorted ( headers ) <EOL> if isinstance ( aspect , QName ) : <EOL> dimConcept = self . modelXbrl . qnameConcepts [ aspect ] <EOL> if dimConcept . isExplicitDimension : <EOL> if headersList : <EOL> headersList . append ( "<STR_LIT>" ) <EOL> else : <EOL> return self . explicitDimensionFilterMembers ( structuralNode , structuralNode ) <EOL> return headersList <EOL> def onAspectComboboxSelection ( self , event ) : <EOL> gridCombobox = event . widget <EOL> if gridCombobox . get ( ) == "<STR_LIT>" : <EOL> structuralNode = self . aspectEntryObjectIdsNode [ gridCombobox . objectId ] <EOL> self . comboboxLoadExplicitDimension ( gridCombobox , structuralNode , structuralNode ) <EOL> def comboboxLoadExplicitDimension ( self , gridCombobox , structuralNode , structuralNodeWithFilter ) : <EOL> gridCombobox [ "<STR_LIT>" ] = self . explicitDimensionFilterMembers ( structuralNode , structuralNodeWithFilter ) <EOL> def explicitDimensionFilterMembers ( self , structuralNode , structuralNodeWithFilter ) : <EOL> for aspect in structuralNodeWithFilter . aspectsCovered ( ) : <EOL> if isinstance ( aspect , QName ) : <EOL> break <EOL> valueHeaders = set ( ) <EOL> if structuralNode is not None : <EOL> headerValues = { } <EOL> dimFilterRels = structuralNodeWithFilter . definitionNode . filterRelationships <EOL> if dimFilterRels : <EOL> for rel in dimFilterRels : <EOL> dimFilter = rel . toModelObject <EOL> if dimFilter is not None : <EOL> for memberModel in dimFilter . memberProgs : <EOL> memQname = memberModel . qname <EOL> memConcept = self . modelXbrl . qnameConcepts . get ( memQname ) <EOL> if memConcept is not None and ( not memberModel . axis or memberModel . axis . endswith ( '<STR_LIT>' ) ) : <EOL> header = memConcept . label ( lang = self . lang ) <EOL> valueHeaders . add ( header ) <EOL> if rel . isUsable : <EOL> headerValues [ header ] = memQname <EOL> else : <EOL> headerValues [ header ] = memConcept <EOL> if memberModel . axis and memberModel . linkrole and memberModel . arcrole : <EOL> if memberModel . axis . endswith ( '<STR_LIT>' ) : <EOL> searchAxis = memberModel . axis [ : len ( memberModel . axis ) - len ( '<STR_LIT>' ) ] <EOL> else : <EOL> searchAxis = memberModel . axis <EOL> relationships = concept_relationships ( self . rendrCntx , <EOL> None , <EOL> ( memQname , <EOL> memberModel . linkrole , <EOL> memberModel . arcrole , <EOL> searchAxis ) , <EOL> False ) <EOL> for rel in relationships : <EOL> if rel . isUsable : <EOL> header = rel . toModelObject . label ( lang = self . lang ) <EOL> valueHeaders . add ( header ) <EOL> headerValues [ header ] = rel . toModelObject . qname <EOL> if not valueHeaders : <EOL> relationships = concept_relationships ( self . rendrCntx , <EOL> None , <EOL> ( aspect , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' ) , <EOL> False ) <EOL> for rel in relationships : <EOL> if ( rel . arcrole in ( XbrlConst . dimensionDomain , XbrlConst . domainMember ) <EOL> and rel . isUsable ) : <EOL> header = rel . toModelObject . label ( lang = self . lang ) <EOL> valueHeaders . add ( header ) <EOL> headerValues [ header ] = rel . toModelObject . qname <EOL> structuralNode . aspectEntryHeaderValues = headerValues <EOL> return sorted ( valueHeaders ) <EOL> from arelle . FunctionXfi import concept_relationships </s>
