Ejemplo n.º 1
0
    def createCtrl(self):
        """ Creates all widgets for a given resource.

        It creates all widget for all attributes in the given resource.
        """
        self.sizer = wx.FlexGridSizer(rows=len(config.getResourceAttrs(self.resource)), cols=2, hgap=5, vgap=10)
        self.lbl, self.ctrl = {}, {}
        for attr in config.getResourceAttrs(self.resource):
            if config.getResourceAttrEnable(attr):
                attrName = config.getResourceAttrName(attr)
                self.lbl[attrName], self.ctrl[attrName] = self.addCtrlFromResource(attr)
        return self.sizer
Ejemplo n.º 2
0
    def getData(self):
        """ Return data to be displayed in a log window.

        It returns a string with information to be displayed in edit/remove
        widget.
        """
        result  = '[%s] ' % config.getResourceTag(self._resource)
        result += '%s ' % self.name
        for data in [data for data in config.getResourceAttrs(self._resource) if data['name'] not in ('name', )]:
            if config.getResourceAttrEnable(data):
                result += '%s ' % getattr(self, data['name'], None)
        return result
Ejemplo n.º 3
0
    def getYamlDict(self):
        """ Return dictionary to be YAMLed.

        It returns the dictionary to be used to generate YAML data.
        """
        classId = config.getResourceId(self._resource)
        yamlData = {classId: {}, }
        yamlData[classId][self.name] = {}
        for attr in [attr for attr in config.getResourceAttrs(self._resource) if not config.isAttrTheAttrName(attr)]:
            attrName = config.getResourceAttrName(attr)
            if config.getResourceAttrEnable(attr):
                yamlData[classId][self.name][attrName] = getattr(self, attrName, None)
        return yamlData
Ejemplo n.º 4
0
    def GetSelection(self):
        """ Collect all dialog input data.

        It collects all information entered in the dialog for every widget and
        it creates an instance that contain that data to be used for YAML code
        generation.
        """
        # This will be the new way to pass the data retrieved from the dialog.
        dictToEntity = {}
        for attr in config.getResourceAttrs(self.resource):
            attrName = config.getResourceAttrName(attr)
            dictToEntity[attrName] = self.getSelectionFromResource(attr, self.ctrl)

        entity = Entity(copy.deepcopy(self.resource), dictToEntity)
        # After selection has been returned, return all attributes and
        # attribute dependencies to default values.
        self.disableAllAttributes()
        self.disableAllAtributeDependencies()
        return entity