def __preExpand(self):

        # this is the most common entry point into the ui
        # creation code, and unfortunately it's called from
        # a maya ui callback. maya appears to suppress all
        # exceptions which occur in such callbacks, so we
        # have to wrap with our own exception handling to
        # make sure any errors become visible.
        try:
            with IECoreMaya.UITemplate("attributeEditorTemplate"):
                if not self.__headerCreated:
                    self._createHeader(self.__columnLayout, **self.__kw)
                if not len(self.__childUIs):
                    self.__createChildUIs()
        except:

            IECore.msg(IECore.Msg.Level.Error, "IECoreMaya.ParameterUI",
                       traceback.format_exc())
    def replace(self, node, parameter):

        IECoreMaya.ParameterUI.replace(self, node, parameter)

        if self.__parameterIsCollapsible():
            collapsed = self._retrieveCollapsedState(self.getCollapsed())
            self.setCollapsed(collapsed, **self.__kw)

        if len(self.__childUIs):

            for pName in self.__childUIs.keys():

                ui = self.__childUIs[pName]
                p = self.parameter[pName]

                ui.replace(node, p)

        else:

            if not self.getCollapsed():
                with IECoreMaya.UITemplate("attributeEditorTemplate"):
                    self.__createChildUIs()
    def __updateChildUIs(self, classes=None, startFromScratch=False):

        if classes == None:
            classes = [c[1:] for c in self.parameter.getClasses(True)]

        # delete any uis for parameters which have disappeared

        parameterNamesSet = set([c[0] for c in classes])
        for parameterName in self.__childUIs.keys():
            if parameterName not in parameterNamesSet or startFromScratch:
                maya.cmds.deleteUI(
                    self.__childUIs[parameterName]._topLevelUI())
                del self.__childUIs[parameterName]

        # and create or reorder uis for remaining parameters

        attachForm = [
            (self.__buttonRow, "left",
             IECoreMaya.CompoundParameterUI._labelIndent(
                 self.__kw["hierarchyDepth"] + 1)),
            (self.__buttonRow, "bottom", 5),
        ]
        attachControl = []
        attachNone = []
        prevChildUI = None
        for i in range(0, len(classes)):

            parameterName = classes[i][0]

            longParameterName = self.__kw['longParameterName']
            if longParameterName:
                # If we have a path already, we need a separator, otherwise, not
                longParameterName += "."
            longParameterName += parameterName

            visible = True
            if 'visibleOnly' in self.__kw:

                visible = longParameterName in self.__kw['visibleOnly']

                if not visible:
                    for i in self.__kw['visibleOnly']:
                        if i.startswith(longParameterName + "."):
                            visible = True
                            break

            if not visible:
                continue

            childUI = self.__childUIs.get(parameterName, None)
            if childUI:
                # delete it if it's not the right sort any more
                if childUI.__className != classes[i][
                        1] or childUI.__classVersion != classes[i][2]:
                    maya.cmds.deleteUI(childUI._topLevelUI())
                    childUI = None

            if not childUI:
                with IECoreMaya.UITemplate("attributeEditorTemplate"):
                    maya.cmds.setParent(self.__formLayout)

                    if "longParameterName" in self.__kw:
                        # We have to append our 'name' (as worked out above), otherwise,
                        # the parameter path misseses it out as the parameter were passing down
                        # has '' as a name.
                        kw = self.__kw.copy()
                        kw["longParameterName"] = longParameterName
                        childUI = ChildUI(self.parameter[parameterName], **kw)
                    else:
                        childUI = ChildUI(self.parameter[parameterName],
                                          **self.__kw)

                    childUI.__className = classes[i][1]
                    childUI.__classVersion = classes[i][2]
                    self.__childUIs[parameterName] = childUI

            attachForm += [
                (childUI._topLevelUI(), "left", 0),
                (childUI._topLevelUI(), "right", 0),
            ]

            if i == 0:
                attachForm.append((childUI._topLevelUI(), "top", 5))
            else:
                attachControl.append((childUI._topLevelUI(), "top", 0,
                                      prevChildUI._topLevelUI()))

            attachNone.append((childUI._topLevelUI(), "bottom"))

            prevChildUI = childUI

        if prevChildUI:
            attachControl.append(
                (self.__buttonRow, "top", 5, prevChildUI._topLevelUI()))
        else:
            attachForm.append((self.__buttonRow, "top", 5))

        maya.cmds.formLayout(self.__formLayout,
                             edit=True,
                             attachForm=attachForm,
                             attachControl=attachControl,
                             attachNone=attachNone)