Exemplo n.º 1
0
class FamilyView(ViewBrowser):
    def __init__(self, parent):
        ViewBrowser.__init__(self, parent, FamilyDoc)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.family = Family(self.conn)

    def set_family(self, family):
        self.doc.set_family(family)
        self.setText(self.doc.output())
        self.family.set_family(family)

    def resetView(self):
        self.set_family(self.family.current)

    def setSource(self, url):
        action, context, ident = split_url(url)
        if action == 'edit':
            if context == 'variables':
                config = self.family.getVariablesConfig(self.family.current)
                newconfig = config.edit()
                config.update(newconfig)
                self.set_family(ident)
            elif context == 'parents':
                dialog = FamilyParentAssigner(self, ident)
                dialog.connect(dialog, SIGNAL('okClicked()'), self.resetView)
                dialog.show()
            else:
                KMessageBox.error(self,
                                  'unable to edit %s for family' % context)
        elif action == 'delete':
            if context == 'family':
                #KMessageBox.information(self, 'delete family %s is unimplemented' % ident)
                msg = "Really delete family %s" % ident
                answer = KMessageBox.questionYesNo(self, msg)
                if answer == KMessageBox.Yes:
                    self.family.delete_family(ident)
                    msg = "family %s deleted" % ident
                    KMessageBox.information(self, msg)
                    self.parent().parent().refreshListView()
                    self.setText('')
            else:
                KMessageBox.error(self,
                                  'unable to delete %s for family' % context)
        else:
            KMessageBox.error(self, 'action %s unimpletmented' % url)
Exemplo n.º 2
0
class FamilyView(ViewBrowser):
    def __init__(self, parent):
        ViewBrowser.__init__(self, parent, FamilyDoc)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.family = Family(self.conn)

    def set_family(self, family):
        self.doc.set_family(family)
        self.setText(self.doc.output())
        self.family.set_family(family)

    def resetView(self):
        self.set_family(self.family.current)
        

    def setSource(self, url):
        action, context, ident = split_url(url)
        if action == 'edit':
            if context == 'variables':
                config = self.family.getVariablesConfig(self.family.current)
                newconfig = config.edit()
                config.update(newconfig)
                self.set_family(ident)
            elif context == 'parents':
                dialog = FamilyParentAssigner(self, ident)
                dialog.connect(dialog, SIGNAL('okClicked()'), self.resetView)
                dialog.show()
            else:
                KMessageBox.error(self, 'unable to edit %s for family' % context)
        elif action == 'delete':
            if context == 'family':
                #KMessageBox.information(self, 'delete family %s is unimplemented' % ident)
                msg = "Really delete family %s" % ident
                answer = KMessageBox.questionYesNo(self, msg)
                if answer == KMessageBox.Yes:
                    self.family.delete_family(ident)
                    msg = "family %s deleted" % ident
                    KMessageBox.information(self, msg)
                    self.parent().parent().refreshListView()
                    self.setText('')
            else:
                KMessageBox.error(self, 'unable to delete %s for family' % context)
        else:
            KMessageBox.error(self, 'action %s unimpletmented' % url)
Exemplo n.º 3
0
class FamilyView(ViewBrowser):
    def __init__(self, parent):
        ViewBrowser.__init__(self, parent, FamilyDoc)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.family = Family(self.conn)

    def set_family(self, family):
        self.doc.set_family(family)
        self.setText(self.doc.output())
        self.family.set_family(family)

    def setSource(self, url):
        action, context, ident = split_url(url)
        if action == 'edit':
            config = self.family.getVariablesConfig(self.family.current)
            newconfig = config.edit()
            config.update(newconfig)
            self.set_family(ident)
        else:
            KMessageBox.error(self, 'action %s unimpletmented' % url)
Exemplo n.º 4
0
class FamilyView(ViewBrowser):
    def __init__(self, app, parent):
        ViewBrowser.__init__(self, app, parent, FamilyDoc)
        self.family = Family(self.app.conn)

    def set_family(self, family):
        self.doc.set_family(family)
        self.setText(self.doc.toxml())
        self.family.set_family(family)

    def setSource(self, url):
        action, context, id = str(url).split('.')
        if action == 'show':
            if context == 'parent':
                win = TraitMainWindow(self.app, self.parent(), self.doc.suite)
                win.view.set_trait(id)
            elif context == 'template':
                fid = id.replace(',', '.')
                package, template = fid.split('...')
                win = ViewWindow(self.app, self.parent(), SimpleEdit,
                                 'TemplateView')
                templatefile = self.doc.trait._templates.templatedata(
                    package, template)
                win.view.setText(templatefile)
                win.resize(600, 800)
            elif context == 'script':
                scriptfile = self.doc.trait._scripts.scriptdata(id)
                win = ViewWindow(self.app, self.parent(), SimpleEdit,
                                 'ScriptView')
                win.view.setText(scriptfile)
                win.resize(600, 800)
        elif action == 'edit':
            #KMessageBox.information(self, 'edit the family %s ' % id)
            config = self.family.getVariablesConfig(self.family.current)
            newconfig = config.edit()
            config.update(newconfig)
            self.set_family(id)

        else:
            KMessageBox.information(self, 'called %s' % url)
Exemplo n.º 5
0
class FamilyView(ViewBrowser):
    def __init__(self, app, parent):
        ViewBrowser.__init__(self, app, parent, FamilyDoc)
        self.family = Family(self.app.conn)
        
    def set_family(self, family):
        self.doc.set_family(family)
        self.setText(self.doc.toxml())
        self.family.set_family(family)
        
    def setSource(self, url):
        action, context, id = str(url).split('.')
        if action == 'show':
            if context == 'parent':
                win = TraitMainWindow(self.app, self.parent(), self.doc.suite)
                win.view.set_trait(id)
            elif context == 'template':
                fid = id.replace(',', '.')
                package, template = fid.split('...')
                win = ViewWindow(self.app, self.parent(), SimpleEdit, 'TemplateView')
                templatefile = self.doc.trait._templates.templatedata(package, template)
                win.view.setText(templatefile)
                win.resize(600, 800)
            elif context == 'script':
                scriptfile = self.doc.trait._scripts.scriptdata(id)
                win = ViewWindow(self.app, self.parent(), SimpleEdit, 'ScriptView')
                win.view.setText(scriptfile)
                win.resize(600, 800)
        elif action == 'edit':
            #KMessageBox.information(self, 'edit the family %s ' % id)
            config = self.family.getVariablesConfig(self.family.current)
            newconfig = config.edit()
            config.update(newconfig)
            self.set_family(id)
            
                
        else:
            KMessageBox.information(self, 'called %s' % url)
Exemplo n.º 6
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)