Beispiel #1
0
class EnvironmentEditor(_EnvironmentEditor):
    def __init__(self, conn, suite, name='EnvironmentEditor'):
        self.menu = make_menu(['update', 'create'], self.env_command)
        _EnvironmentEditor.__init__(self, conn, name=name)
        self.suite = suite
        self.traitparent = TraitParent(self.conn, self.suite)
        self.current_trait = None
        self.reset_rows()
        w, h = map(int, config.get_list('env_editor_size', section='management_gui'))
        self.set_size_request(w, h)
        
    def reset_rows(self):
        rows = self.main.select(fields=['trait'], table=ujoin(self.suite, 'traits'))
        self.set_rows(rows)
        self.set_row_select(self.trait_selected)

    def trait_selected(self, listbox, row, column, event):
        trait = listbox.get_selected_data()[0].trait
        self.select_trait(trait)
        
    def select_trait(self, trait):
        self.current_trait = trait
        environ = TraitEnvironment(self.conn, self.suite, trait)
        self.environ = self.traitparent.get_environment([self.current_trait])
        self.sections = dict([(k, v.keys()) for k,v in self.environ])
        self.remove_page('Environment')
        self.record = RecordBox(environ, name=self.current_trait)
        self.append_page(self.record, 'Environment')
        self.pages['Environment'].connect('button_press_event', self.box_pressed)
        #self.menu.connect('populate', self.populate_menu, self.menu)
        self.record.connect_entries('populate-popup', self.populate_menu, self.menu)
        

    def make_new_variable(self, *args):
        d = self.dialogs['create']
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        environ.update(dict([(d['name'], d['value'])]))

    def remove_item(self, *args):
        d = self.dialogs['remove']
        name = d.get_selected_data()[0].name
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        del environ[name]
        dialogs.Message('%s deleted' %name)
        self.destroy_dialog(d)
        
    def update_environment(self):
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        environ.update(self.record)

    def env_command(self, menuitem, command):
        if command == 'update':
            dialogs.Message('updating %s' % self.current_trait)
            self.update_environment()
        elif command == 'create':
            self.ask_new_entry()
        else:
            dialogs.Message('ack')
Beispiel #2
0
 def select_trait(self, trait):
     self.current_trait = trait
     environ = TraitEnvironment(self.conn, self.suite, trait)
     self.environ = self.traitparent.get_environment([self.current_trait])
     self.sections = dict([(k, v.keys()) for k, v in self.environ])
     self.remove_page('Environment')
     self.record = RecordBox(environ, name=self.current_trait)
     self.append_page(self.record, 'Environment')
     self.pages['Environment'].connect('button_press_event',
                                       self.box_pressed)
     #self.menu.connect('populate', self.populate_menu, self.menu)
     self.record.connect_entries('populate-popup', self.populate_menu,
                                 self.menu)
Beispiel #3
0
 def __init__(self, conn, name='_EnvironmentEditor'):
     ListNoteBook.__init__(self, name=name)
     self.conn = conn
     self.main = StatementCursor(self.conn, name=name)
     self.append_page(RecordBox({}), 'Environment')
     self.menu = SimpleMenu()
     self.delimiters = DELIMITERS['out-arrows']
     self.dialogs = {}.fromkeys(['create', 'remove'])
Beispiel #4
0
 def select_trait(self, trait):
     self.current_trait = trait
     environ = TraitEnvironment(self.conn, self.suite, trait)
     self.environ = self.traitparent.get_environment([self.current_trait])
     self.sections = dict([(k, v.keys()) for k,v in self.environ])
     self.remove_page('Environment')
     self.record = RecordBox(environ, name=self.current_trait)
     self.append_page(self.record, 'Environment')
     self.pages['Environment'].connect('button_press_event', self.box_pressed)
     #self.menu.connect('populate', self.populate_menu, self.menu)
     self.record.connect_entries('populate-popup', self.populate_menu, self.menu)
Beispiel #5
0
class EnvironmentEditor(_EnvironmentEditor):
    def __init__(self, conn, suite, name='EnvironmentEditor'):
        self.menu = make_menu(['update', 'create'], self.env_command)
        _EnvironmentEditor.__init__(self, conn, name=name)
        self.suite = suite
        self.traitparent = TraitParent(self.conn, self.suite)
        self.current_trait = None
        self.reset_rows()
        w, h = map(
            int, config.get_list('env_editor_size', section='management_gui'))
        self.set_size_request(w, h)

    def reset_rows(self):
        rows = self.main.select(fields=['trait'],
                                table=ujoin(self.suite, 'traits'))
        self.set_rows(rows)
        self.set_row_select(self.trait_selected)

    def trait_selected(self, listbox, row, column, event):
        trait = listbox.get_selected_data()[0].trait
        self.select_trait(trait)

    def select_trait(self, trait):
        self.current_trait = trait
        environ = TraitEnvironment(self.conn, self.suite, trait)
        self.environ = self.traitparent.get_environment([self.current_trait])
        self.sections = dict([(k, v.keys()) for k, v in self.environ])
        self.remove_page('Environment')
        self.record = RecordBox(environ, name=self.current_trait)
        self.append_page(self.record, 'Environment')
        self.pages['Environment'].connect('button_press_event',
                                          self.box_pressed)
        #self.menu.connect('populate', self.populate_menu, self.menu)
        self.record.connect_entries('populate-popup', self.populate_menu,
                                    self.menu)

    def make_new_variable(self, *args):
        d = self.dialogs['create']
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        environ.update(dict([(d['name'], d['value'])]))

    def remove_item(self, *args):
        d = self.dialogs['remove']
        name = d.get_selected_data()[0].name
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        del environ[name]
        dialogs.Message('%s deleted' % name)
        self.destroy_dialog(d)

    def update_environment(self):
        environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
        environ.update(self.record)

    def env_command(self, menuitem, command):
        if command == 'update':
            dialogs.Message('updating %s' % self.current_trait)
            self.update_environment()
        elif command == 'create':
            self.ask_new_entry()
        else:
            dialogs.Message('ack')