Exemplo n.º 1
0
    def removeNewField(self, dep, newField):
        """ Remote a new field on the fly.

        It removes a new field already created when conditions are not met.
        """
        if config.getResourceAttrDepsEnable(dep):
            # Delete dialog entry here, because conditions are not met.
            oldAttr = config.lookForResourceAttrWithName(self.resource, newField)
            if oldAttr:
                self.disableAttribute(oldAttr)
                self.disableAttributeDependency(dep)
                self.removeNewCtrl(oldAttr)
Exemplo n.º 2
0
    def createNewField(self, dep, newField):
        """ Create a new field on the fly.

        It creates a new field when conditions are met.
        """
        if not config.getResourceAttrDepsEnable(dep):
            # Create new dialog entry here.
            handler = config.getResourceAttrDepsHandler(dep)
            newAttr = config.lookForResourceAttrWithName(self.resource, newField)
            if newAttr:
                self.enableAttribute(newAttr, handler)
                self.enableAttributeDependency(dep)
                self.createNewCtrl(newAttr)
Exemplo n.º 3
0
    def OnTextCtrlAction(self, ev):
        """ Check if there are any condition to be met.

        It checks if the input field has any dependency, and proceed to create
        or remove fields when those dependencies are met or broken.
        """
        evObj = ev.GetEventObject()
        if evObj.customData is None:
            return
        for dep in evObj.customData:
            fields   = config.getResourceAttrDepsFields(dep)
            newField = config.getResourceAttrDepsNewField(dep)
            for field, fieldValue in fields.iteritems():
                attr      = config.lookForResourceAttrWithName(self.resource, field)
                attrValue = self.getSelectionFromResource(attr, self.ctrl)
                #if self.ctrl[field].GetValue() not in fieldValue:
                if attrValue not in fieldValue:
                    break
            else:
                self.createNewField(dep, newField)
                continue

            self.removeNewField(dep, newField)