Esempio n. 1
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)
        
    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SectionTitle('Family:  %s' % family)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'

        self.body.append(title)
        parent_anchor = Anchor('Parents', href='edit.parents.%s' % family)
        self.body.append(SectionTitle(parent_anchor))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.append(ListItem(p))
            self.body.append(plist)
        vtitle = Anchor('Variables', href='edit.variables.%s' % self.family.current)
        self.body.append(SectionTitle(vtitle))
        if len(erows):
            self.body.append(PVarTable(erows, bgcolor='MistyRose2'))
        self.body.append(Ruler())
        del_anchor = Anchor('delete', href='delete.family.%s' % family)
        self.body.append(del_anchor)
Esempio n. 2
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)

    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SectionTitle('Family:  %s' % family)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'

        self.body.append(title)
        parent_anchor = Anchor('Parents', href='edit.parents.%s' % family)
        self.body.append(SectionTitle(parent_anchor))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.append(ListItem(p))
            self.body.append(plist)
        vtitle = Anchor('Variables',
                        href='edit.variables.%s' % self.family.current)
        self.body.append(SectionTitle(vtitle))
        if len(erows):
            self.body.append(PVarTable(erows, bgcolor='MistyRose2'))
        self.body.append(Ruler())
        del_anchor = Anchor('delete', href='delete.family.%s' % family)
        self.body.append(del_anchor)
Esempio n. 3
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)

    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SimpleTitleElement("Family:  %s" % family, bgcolor="IndianRed", width="100%")
        self.body.appendChild(title)
        self.body.appendChild(SectionTitle("Parents"))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.appendChild(ListItem(p))
            self.body.appendChild(plist)
        vtitle = Anchor("edit.variables.%s" % self.family.current, "Variables")
        self.body.appendChild(SectionTitle(vtitle))
        if len(erows):
            self.body.appendChild(PVarTable(erows, bgcolor="MistyRose2"))
Esempio n. 4
0
class FamilyDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.family = Family(self.conn)

    def set_family(self, family):
        self.family.set_family(family)
        parents = self.family.parents()
        erows = self.family.environment_rows()
        self.clear_body()
        title = SimpleTitleElement('Family:  %s' % family,
                                   bgcolor='IndianRed',
                                   width='100%')
        self.body.appendChild(title)
        self.body.appendChild(SectionTitle('Parents'))
        if len(parents):
            plist = UnorderedList()
            for p in parents:
                plist.appendChild(ListItem(p))
            self.body.appendChild(plist)
        vtitle = Anchor('edit.variables.%s' % self.family.current, 'Variables')
        self.body.appendChild(SectionTitle(vtitle))
        if len(erows):
            self.body.appendChild(PVarTable(erows, bgcolor='MistyRose2'))
Esempio n. 5
0
class FamilyBrowser(ListNoteBook):
    def __init__(self, conn):
        self.menu = make_menu(['delete'], self.modify_family)
        ListNoteBook.__init__(self)
        self.conn = conn
        self.family = Family(self.conn)
        self.var_menu = make_menu(['edit', 'nothing', 'nothing', 'drop'],
                              self.var_menu_selected)
        self.parent_menu = make_menu(['drop'], self.modify_parent)
        self.reset_rows()
        self.append_page(ScrollCList(rcmenu=self.var_menu), 'environment')
        self.append_page(ScrollCList(rcmenu=self.parent_menu), 'parents')
        self.set_size_request(400, 300)

    def modify_parent(self, menuitem, action):
        if action == 'drop':
            parents = self._get_listbox_col_('parents', 'family')
            self.trait.delete_parents(parents)
            self.__set_pages(self.current_family)

    def modify_family(self, menuitem, action):
        if action == 'delete':
            trait = self.listbox.get_selected_data()[0].family
            self.trait.delete_family(family)
            self.reset_rows()
            
    def reset_rows(self):
        self.set_rows(self.family.family_rows())
        self.set_row_select(self.family_selected)

    def __set_droptargets__(self, pages):
        set_receive_targets(pages['environment'].listbox,
                            self.drop_variable, TARGETS.get('variable', 'flavor'))
        set_receive_targets(pages['parents'].listbox,
                            self.drop_family, TARGETS.get('family', 'flavor'))

    def set_package(self, menu_item, action):
        raise Error, 'this call (set_package) is not needed in Family'
        packages = self._get_listbox_col_('packages', 'package')
        trait = self.current_family
        self.trait.set_action(action, packages)
        self.__set_pages(self.current_trait)

    def var_menu_selected(self, menu_item, action):
        if action == 'edit':
            config = self.family.getVariablesConfig(self.current_family)
            newconfig = config.edit()
            config.update(newconfig)
            self.select_family(self.current_family)
        elif action == 'drop':
            pages = dict(self.pages)
            listbox = pages['environment'].listbox
            rows = listbox.get_selected_data()
            for row in rows:
                self.family.deleteVariable(row.trait, row.name, self.current_family)
            
    def pop_mymenu(self, widget, event, menu):
        if right_click_pressed(event):
            menu.popup(None, None, None, event.button, event.time)

    def family_selected(self, listbox, row, column, event):
        family = listbox.get_selected_data()[0].family
        self.select_family(family)
        
    def select_family(self, family):
        self.current_family = family
        self.family.set_family(family)
        self.__set_pages(self.current_family)

    def __set_pages(self, family):
        pages = dict(self.pages)
        pages['environment'].set_rows(self.family.environment_rows())
        pages['environment'].set_select_mode('multi')
        pages['parents'].set_rows(self.family.parents(), ['family'])
        pages['parents'].set_select_mode('multi')
        self.__set_droptargets__(pages)

    def drop_family(self, listbox, context, x, y, selection, targettype, time):
        families = Set(selection.data.split('^&^'))
        self.family.insert_parents(families)
        self.__set_pages(self.current_family)

    def drop_variable(self, listbox, context, x, y, selection, targettype, time):
        table = 'family_environment'
        trips = [x.split('<=>') for x in selection.data.split('^&^')]
        rows = [dict(trait=x[0], name=x[1], value=x[2]) for x in trips]
        for r in trips:
            trait, name, value = r
            self.family.insertVariable(trait, name, value, family=self.current_family)
        self.__set_pages(self.current_family)

    def _get_listbox_col_(self, page, field):
        pages = dict(self.pages)
        return [row[field] for row in pages[page].listbox.get_selected_data()]

    def make_families_window(self):
        rows = self.family.family_rows()
        FamiliesWindow(rows)

    def make_variables_window(self):
        rows = self.family.get_all_defaults()
        VariablesWindow(rows)