Exemplo n.º 1
0
 def delete_filter(self, event):
     name = self.filters_list.GetStringSelection()
     del datastore.filters[name]
     self.filter = None
     self.detail_panel.filter = None
     self.remove_button.Disable()
     events.post_change(self, 'filters')
Exemplo n.º 2
0
 def delete_template(self, event):
     name = self.templates_list.GetStringSelection()
     del datastore.templates[name]
     events.post_change(self, "templates")
     self.fieldlist.template = None
     self.template_label.SetLabel("Template")
     self.statusbar.SetStatusText('Template "%s" deleted.' % name)
Exemplo n.º 3
0
    def update_attribute(self, att_name='', att_type='', att_unit='',
                         is_output=False, in_use=False, previous_att=None):

        # TODO: I think it would be an improvement to change this so that the
        # attributes are modified within the list itself, and the add attribute
        # button just adds a new row to the list for the user to fill out.
        # Not going to worry about it right now, though.
        dlg = AddAttribute(self, att_name, att_type, att_unit, is_output, in_use)
        if dlg.ShowModal() == wx.ID_OK:
            if not dlg.field_name:
                return
            if dlg.field_name not in datastore.sample_attributes or dlg.field_name == previous_att:
                if previous_att:
                    del datastore.sample_attributes[previous_att]

                datastore.sample_attributes.add_attribute(dlg.field_name,
                                dlg.field_type, dlg.field_unit, dlg.is_output,
                                dlg.has_uncertainty)
                events.post_change(self, 'attributes')
                row = datastore.sample_attributes.indexof(dlg.field_name)
            else:
                wx.MessageBox('Attribute "%s" already exists!' % dlg.field_name,
                        "Duplicate Attribute", wx.OK | wx.ICON_INFORMATION)

        dlg.Destroy()
 def create_plan(self, event):
     wiz = PlanWizard(self)
     if wiz.RunWizard():
         plan = wiz.make_plan()
         datastore.computation_plans.add(plan)
         events.post_change(self, 'cplans', plan.name)
     wiz.Destroy()
Exemplo n.º 5
0
 def remove_attribute(self, event):
     """Moves the selected attribute from the view listbox to available."""
     strs = self.order_box.GetStrings()
     try:
         self.view.remove(strs[self.order_box.GetListCtrl().GetFocusedItem()])
     except ValueError:
         pass
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 6
0
 def update_template_field(self, prev_name='', prev_type='', prev_key=False):
     dlg = EditTemplateField(self, prev_name, prev_type, prev_key)
     if dlg.ShowModal() == wx.ID_OK:
         if prev_name:
             del self.template[prev_name]
         self.template.add_field(dlg.field_name, dlg.field_type, dlg.is_key)
         events.post_change(self, 'template_fields', self.template.name)
     dlg.Destroy()
Exemplo n.º 7
0
 def delete_attribute(self, event):
     row = self.listctrl.GetFirstSelected()
     att = datastore.sample_attributes.getkeyat(row)
     self.listctrl.Select(row, False)
     del datastore.sample_attributes[att]
     events.post_change(self, 'attributes')
     
     
Exemplo n.º 8
0
 def update_template_field(self, prev_name="", prev_type="", prev_key=False):
     dlg = EditTemplateField(self, prev_name, prev_type, prev_key)
     if dlg.ShowModal() == wx.ID_OK:
         if prev_name:
             del self.template[prev_name]
         self.template.add_field(dlg.field_name, dlg.field_type, dlg.is_key)
         events.post_change(self, "template_fields", self.template.name)
     dlg.Destroy()
Exemplo n.º 9
0
 def remove_attribute(self, event):
     strs = self.view_list.GetStrings()
     for sel in self.view_list.GetSelections():
         try:
             self.view.remove(strs[sel])
         except ValueError:
             self.statusbar.SetStatusText('Cannot remove attribute(s): '
                             'some attributes are required in all views.')
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 10
0
 def remove_attribute(self, event):
     """Moves the selected attribute from the view listbox to available."""
     strs = self.order_box.GetStrings()
     try:
         self.view.remove(
             strs[self.order_box.GetListCtrl().GetFocusedItem()])
     except ValueError:
         pass
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 11
0
 def on_make_new(self, event):
     dialog = WorkflowDialog(self)
     if dialog.ShowModal() == wx.ID_OK:
         newflow = dialog.do_save()
         #current implementation of event seems to need to post it
         #from an actual app-window, which is this window's grandparent, so...
         events.post_change(self.GrandParent, 'workflows')
         self.flowchoice.Append(newflow.name)
         self.flowchoice.SetStringSelection(newflow.name)
     dialog.Destroy()
Exemplo n.º 12
0
    def add_filter(self, event):
        suffix = 1
        name = "Untitled %d" % suffix
        while name in datastore.filters:
            suffix += 1
            name = "Untitled %d" % suffix

        new_filter = views.Filter(name, all)
        datastore.filters.add(new_filter)
        events.post_change(self, 'filters', name)
Exemplo n.º 13
0
 def on_make_new(self, event):
     dialog = WorkflowDialog(self)
     while dialog.ShowModal() == wx.ID_OK:
         newflow = dialog.do_save()
         if newflow:
             #current implementation of event seems to need to post it
             #from an actual app-window, which is this window's grandparent, so...
             events.post_change(self.GrandParent, 'workflows')
             self.flowchoice.Append(newflow.name)
             self.flowchoice.SetStringSelection(newflow.name)
             break
     dialog.Destroy()
Exemplo n.º 14
0
 def create_new_milieu(self, event):
     dlg = CreateMilieu(self)
     if dlg.ShowModal() == wx.ID_OK:
         template = datastore.templates[dlg.template]
         #TODO: handle errors!
         #TODO: waiting cursor!
         with open(dlg.path, 'rU') as input_file:
             coll = template.new_milieu(csv.DictReader(input_file, dlg.order))
         coll.name = dlg.name
         datastore.milieus.add(coll)
         events.post_change(self, 'milieus', coll.name)
     dlg.Destroy()        
Exemplo n.º 15
0
 def OnDeleteSample(self, event):
     
     indexes = self.grid.SelectedRowset
     samples = [self.displayed_samples[index] for index in indexes]
     ids = [sample['id'] for sample in samples]
     
     dialog = wx.MessageDialog(None, 'Are you sure that you want to delete the following samples: %s' % (ids), "Are you sure?", wx.YES_NO | wx.ICON_EXCLAMATION)
     if dialog.ShowModal() == wx.ID_YES:
         for s_id in ids:
             del self.core[depth]
         self.grid.ClearSelection()
         events.post_change(self, 'samples')                
Exemplo n.º 16
0
    def save_changes(self, event):
        if not self.Validate():
            return

        # need to update the name, here...
        oldname = self.filter.name
        #clear out all the old filter items
        del self.filter[:]
        self.name_panel.save(self.filter)
        self.item_panel.save(self.filter)
        #also saves the new filter, because reasons, for now
        datastore.filters.rename(oldname, self.filter)
        events.post_change(self, 'filters', self.filter.name)
Exemplo n.º 17
0
 def delete_plan(self, event):
     item = self.planlist.GetStringSelection()
     experiment = datastore.computation_plans[item]
             
     updates = False
     for core in datastore.cores.itervalues():
         upd = [core.strip_experiment(experiment.name)]
         updates = updates or any(upd)
     if updates:
         events.post_change(self, 'samples')
         
     del datastore.computation_plans[experiment.name]
     events.post_change(self, 'cplans')
Exemplo n.º 18
0
 def create_new_milieu(self, event):
     dlg = CreateMilieu(self)
     if dlg.ShowModal() == wx.ID_OK:
         template = datastore.templates[dlg.template]
         #TODO: handle errors!
         #TODO: waiting cursor!
         with open(dlg.path, 'rU') as input_file:
             coll = template.new_milieu(
                 csv.DictReader(input_file, dlg.order))
         coll.name = dlg.name
         datastore.milieus.add(coll)
         events.post_change(self, 'milieus', coll.name)
     dlg.Destroy()
Exemplo n.º 19
0
 def delete_view(self, event):
     if self.views_list.GetSelection() != wx.NOT_FOUND:
         name = self.view.name
         if name == "All":
             wx.MessageBox("Can't delete the 'All' View", "Delete Fail",
                           wx.OK | wx.ICON_INFORMATION)
         else:
             datastore.views.delete_one(self.view)
             self.views_list.Delete(self.views_list.GetSelection())
             self.clear_view()
             events.post_change(self, 'views', name)
     else:
         wx.MessageBox("Nothing selected", "Delete Fail",
                       wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 20
0
 def OnDatingDone(self, dresult, planname, core, dialog):
     try:
         result = dresult.get()
     except Exception as exc:
         core.strip_experiment(planname)
         print exc
         wx.MessageBox("There was an error running the requested computation."
                       " Please contact support.")
     else:
         dialog.EndModal(wx.ID_OK)
         events.post_change(self, 'samples')
     finally:
         self.button_panel.Enable()
         self.plotbutton.Enable()
Exemplo n.º 21
0
 def OnStripExperiment(self, event):
     
     indexes = list(self.grid.SelectedRowset)
     samples = [self.displayed_samples[index] for index in indexes]
     
     dialog = wx.MessageDialog(None, 'This operation will strip all performed computations from the selected samples. (Note: Input cannot be deleted.) Are you sure you want to do this?', "Are you sure?", wx.YES_NO | wx.ICON_EXCLAMATION)
     if dialog.ShowModal() == wx.ID_YES:
         for sample in samples:
             for exp in sample.keys():
                 if exp != 'input':
                     del sample[exp]
     
         self.grid.ClearSelection()
         events.post_change(self, 'samples')
Exemplo n.º 22
0
 def delete_view(self, event):
     if self.views_list.GetSelection() != wx.NOT_FOUND:
         name = self.view.name
         if name == "All":
             wx.MessageBox("Can't delete the 'All' View",
                     "Delete Fail", wx.OK | wx.ICON_INFORMATION)
         else:
             datastore.views.delete_one(self.view)
             self.views_list.Delete(self.views_list.GetSelection())
             self.clear_view()
             events.post_change(self, 'views', name)
     else:
         wx.MessageBox("Nothing selected",
                 "Delete Fail", wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 23
0
    def create_plan(self, event):
        wiz = PlanWizard(self)
        if wiz.RunWizard():
            plan = wiz.make_plan()
            datastore.computation_plans.add(plan)
            events.post_change(self, 'cplans', plan.name)

            v = View('Data For "%s"' % plan.name)
            atts = datastore.workflows[plan.workflow].find_sample_attributes()
            atts.difference_update(v)
            v.extend(atts)
            datastore.views.add(v)
            events.post_change(self, 'views', v.name)
            
        wiz.Destroy()
Exemplo n.º 24
0
    def create_plan(self, event):
        wiz = PlanWizard(self)
        if wiz.RunWizard():
            plan = wiz.make_plan()
            datastore.computation_plans.add(plan)
            events.post_change(self, 'cplans', plan.name)

            v = View('Data For "%s"' % plan.name)
            atts = datastore.workflows[plan.workflow].find_sample_attributes()
            atts.difference_update(v)
            v.extend(atts)
            datastore.views.add(v)
            events.post_change(self, 'views', v.name)

        wiz.Destroy()
Exemplo n.º 25
0
    def import_samples(self, event):
        importwizard = io.ImportWizard(self)
        if importwizard.RunWizard():
            events.post_change(self, "samples")
            self.selected_core.SetItems(sorted(datastore.cores.keys()))
            if importwizard.swapcore:
                self.filter = None
                self.grid_statusbar.SetStatusText("", self.INFOPANE_ROW_FILT_FIELD)
                self.set_view("All")
                self.select_core(corename=importwizard.corename)
            else:
                self.selected_core.SetStringSelection(self.core.name)
            if importwizard.saverepo:
                self.save_repository()

        importwizard.Destroy()
Exemplo n.º 26
0
 def add_vatt(self, event):
     dialog = wx.TextEntryDialog(self, "Enter Attribute Name", "New Hierarchy",
                                 style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         dialog.Destroy()
         if value:
             if not value in datastore.sample_attributes:
                 datastore.sample_attributes.add_virtual_att(value, [datastore.sample_attributes[u'depth']])
                 events.post_change(self, 'attributes', value)
             else:
                 wx.MessageBox('Attribute "%s" already exists!' % value,
                         "Duplicate Attribute Name", wx.OK | wx.ICON_INFORMATION)
         else:
             wx.MessageBox('Attribute name not specified!',
                         "Illegal Attribute Name", wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 27
0
    def OnDating(self, event=None):
        dlg = ComputationDialog(self, self.core)
        ret = dlg.ShowModal()
        plan = dlg.plan
        # depths = dlg.depths
        dlg.Destroy()
        if ret != wx.ID_OK:
            return
        computation_plan = datastore.computation_plans[plan]
        workflow = datastore.workflows[computation_plan["workflow"]]
        vcore = self.core.new_computation(plan)
        self.SetCursor(wx.HOURGLASS_CURSOR)

        # TODO: as workflows become more interactive, it becomes less and less
        # sensible to perform all computation (possibly any computation) in its
        # own thread, as we'll be continuing to demand user attention throughout

        # leaving in some way to abort would be useful, so we should consider
        # how to do that; the issue is that wxpython leaks memory when you try
        # to construct windows in a new thread, which is yuck. So all of this
        # should be reconsidered in light of interactive-type workflows.

        # see http://stackoverflow.com/questions/13654559/how-to-thread-wxpython-progress-bar
        # for some further information
        # wx.lib.delayedresult.startWorker(self.OnDatingDone, workflow.execute,
        #                          cargs=(plan, dialog),
        #                          wargs=(computation_plan, vcore, aborting))

        try:
            workflow.execute(computation_plan, vcore)
        except:
            msg = (
                "We're sorry, something went wrong while running that computation. "
                + "Please tell someone appropriate!\n\n\n\n\n\n\n******DEBUG******\n\n"
                + traceback.format_exc()
            )
            dlg = wx.lib.dialogs.ScrolledMessageDialog(self, msg, "Computation Error")
            dlg.ShowModal()
            raise
        else:
            events.post_change(self, "samples")
            self.filter = datastore.filters['Plan "%s"' % plan]
            self.set_view('Data For "%s"' % plan)

            wx.CallAfter(
                wx.MessageBox, "Computation finished successfully. " "Results are now displayed in the main window."
            )
Exemplo n.º 28
0
 def add_view(self, event):
     dialog = wx.TextEntryDialog(self, "Enter View Name", "New View",
                                 style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         dialog.Destroy()
         if value:
             if not value in datastore.views:
                 datastore.views.add(View(value))
                 self.clear_view()
                 events.post_change(self, 'views', value)
             else:
                 wx.MessageBox('View "%s" already exists!' % value,
                         "Duplicate View Name", wx.OK | wx.ICON_INFORMATION)
         else:
             wx.MessageBox('View name not specified!',
                         "Illegal View Name", wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 29
0
 def add_template(self, event):
     dialog = wx.TextEntryDialog(self, "Enter Template Name",
                                 "Template Entry Dialog", style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         if value:
             if value not in datastore.templates:
                 template = Template(name=value)
                 datastore.templates.add(template)
                 events.post_change(self, 'templates', value)
             else:
                 dialog = wx.MessageDialog(None, 'Template "' + value + '" already exists!', "Duplicate Template", wx.OK | wx.ICON_INFORMATION)
                 dialog.ShowModal()
         else:
             dialog = wx.MessageDialog(None, 'Template name not specified!', "Illegal Template Name", wx.OK | wx.ICON_INFORMATION)
             dialog.ShowModal()
     dialog.Destroy()
Exemplo n.º 30
0
 def add_template(self, event):
     dialog = wx.TextEntryDialog(self, "Enter Template Name",
                                 "Template Entry Dialog", style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         if value:
             if value not in datastore.templates:
                 template = Template(name=value)
                 datastore.templates.add(template)
                 events.post_change(self, 'templates', value)
             else:
                 dialog = wx.MessageDialog(None, 'Template "' + value + '" already exists!', "Duplicate Template", wx.OK | wx.ICON_INFORMATION)
                 dialog.ShowModal()
         else:
             dialog = wx.MessageDialog(None, 'Template name not specified!', "Illegal Template Name", wx.OK | wx.ICON_INFORMATION)
             dialog.ShowModal()
     dialog.Destroy()
Exemplo n.º 31
0
    def do_add_dlg(self, typelist, collection):
        # TODO: I think it would be an improvement to change this so that the
        # attributes are modified within the list itself, and the add attribute
        # button just adds a new row to the list for the user to fill out.
        # Not going to worry about it right now, though.
        dlg = AddAttribute(self, typelist)
        if dlg.ShowModal() == wx.ID_OK:
            if not dlg.field_name:
                return
            if dlg.field_name not in collection:

                collection.add_attribute(dlg.field_name,
                                dlg.field_type, dlg.field_unit, dlg.is_output,
                                dlg.has_error)
                events.post_change(self, 'attributes')
            else:
                wx.MessageBox('Attribute "%s" already exists!' % dlg.field_name,
                        "Duplicate Attribute", wx.OK | wx.ICON_INFORMATION)

        dlg.Destroy()
Exemplo n.º 32
0
 def add_view(self, event):
     dialog = wx.TextEntryDialog(self,
                                 "Enter View Name",
                                 "New View",
                                 style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         dialog.Destroy()
         if value:
             if not value in datastore.views:
                 datastore.views.add(View(value))
                 self.clear_view()
                 events.post_change(self, 'views', value)
             else:
                 wx.MessageBox('View "%s" already exists!' % value,
                               "Duplicate View Name",
                               wx.OK | wx.ICON_INFORMATION)
         else:
             wx.MessageBox('View name not specified!', "Illegal View Name",
                           wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 33
0
 def add_vatt(self, event):
     dialog = wx.TextEntryDialog(self,
                                 "Enter Attribute Name",
                                 "New Hierarchy",
                                 style=wx.OK | wx.CANCEL)
     if dialog.ShowModal() == wx.ID_OK:
         value = dialog.GetValue()
         dialog.Destroy()
         if value:
             if not value in datastore.sample_attributes:
                 datastore.sample_attributes.add_virtual_att(
                     value, [datastore.sample_attributes[u'depth']])
                 events.post_change(self, 'attributes', value)
             else:
                 wx.MessageBox('Attribute "%s" already exists!' % value,
                               "Duplicate Attribute Name",
                               wx.OK | wx.ICON_INFORMATION)
         else:
             wx.MessageBox('Attribute name not specified!',
                           "Illegal Attribute Name",
                           wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 34
0
 def save_changes(self, event):
     if not self.Validate():
         return
         
     # need to update filters that point at the old filter name to use
     # the new filter name
     oldname = self.filter.name
     #in case the name has changed, delete the old filter
     del datastore.filters[self.filter.name]
     #clear out all the old filter items
     del self.filter[:]
     self.name_panel.save(self.filter)
     self.item_panel.save(self.filter)
     datastore.filters[self.filter.name] = self.filter
     #rename any subfilters
     for f in datastore.filters.itervalues():
         for item in f:
             if item.depends_on(oldname):
                 item.filter = self.filter
     
     events.post_change(self, 'filters', self.filter.name)
Exemplo n.º 35
0
 def update_attribute(self, att_name='', att_type='', 
                      is_output=False, in_use=False, previous_att=None):
     dlg = AddAttribute(self, att_name, att_type, is_output, in_use)
     if dlg.ShowModal() == wx.ID_OK:
         if not dlg.field_name:
             return
         if dlg.field_name not in datastore.sample_attributes or dlg.field_name == previous_att:
             if previous_att:
                 del datastore.sample_attributes[previous_att]
                 
             datastore.sample_attributes.add(Attribute(dlg.field_name, 
                                         dlg.field_type, dlg.is_output))
             events.post_change(self, 'attributes')
             self.listctrl.Select(self.listctrl.GetFirstSelected(), False)
             
             row = datastore.sample_attributes.indexof(dlg.field_name)
             #self.grid.MakeCellVisible(row, 0)    
             
         else:
             wx.MessageBox('Attribute "%s" already exists!' % dlg.field_name, 
                     "Duplicate Attribute", wx.OK | wx.ICON_INFORMATION)
     dlg.Destroy()
Exemplo n.º 36
0
 def delete_template_field(self, event):
     field = self.template.getitemat(self.fieldlist.GetFirstSelected())
     del self.template[field.name]
     events.post_change(self, "template_fields", self.template.name)
     self.editfieldbutton.Disable()
     self.deletefieldbutton.Disable()
Exemplo n.º 37
0
 def delete_template_field(self, event):
     field = self.template.getitemat(self.fieldlist.GetFirstSelected())
     del self.template[field.name]
     events.post_change(self, 'template_fields', self.template.name)
     self.editfieldbutton.Disable()
     self.deletefieldbutton.Disable()
Exemplo n.º 38
0
 def save_changes(self, event=None):
     self.view = View(name=self.view.name, atts=self.order_box.GetStrings())
     datastore.views[self.view.name] = self.view
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 39
0
 def save_changes(self, event=None):
     self.vatt.aggatts = self.order_box.Strings[:]
     if not self.vatt.aggatts:
         self.vatt.aggatts = [u'depth']
     events.post_change(self, 'attributes', self.vatt.name)
Exemplo n.º 40
0
 def add_attribute(self, event):
     strs = self.avail_list.GetStrings()
     for sel in self.avail_list.GetSelections():
         self.view.append(strs[sel])
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 41
0
 def save_changes(self, event=None):
     self.view = View(name=self.view.name, atts=self.order_box.GetStrings())
     datastore.views[self.view.name] = self.view
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 42
0
 def add_attribute(self, event):
     strs = self.avail_list.GetStrings()
     for sel in self.avail_list.GetSelections():
         self.view.append(strs[sel])
     events.post_change(self, 'view_atts', self.view.name)
Exemplo n.º 43
0
 def delete_view(self, event):
     self.clear_view()
     name = self.views_list.GetStringSelection()
     del datastore.views[name]
     events.post_change(self, 'views', name)
     self.statusbar.SetStatusText('%s Deleted' % name)