def remove_link(self, link_obj): dlg = wx.MessageDialog( None, 'You are about to remove all data mappings that are associated with this link. Are you sure you want to perform this action?', 'Question', wx.YES_NO | wx.YES_DEFAULT | wx.ICON_WARNING) if dlg.ShowModal() != wx.ID_NO: # remove the link entry in self.links link = self.links.pop(link_obj) # remove the link from the cmd from_id = link[0].ID to_id = link[1].ID # get the link id links = engine.getLinksBtwnModels(from_id, to_id) # remove all links for link in links: success = engine.removeLinkById(link['id']) if not success: elog.error('ERROR|Could not remove link: %s' % link['id']) sPrint('ERROR|Could not remove link: %s' % link['id'], MessageType.ERROR) links = engine.getLinksBtwnModels(to_id, from_id) # Doing this a second time to remove bidirectional links for link in links: success = engine.removeLinkById(link['id']) if not success: elog.error('ERROR|Could not remove link: %s' % link['id']) sPrint('ERROR|Could not remove link: %s' % link['id'], MessageType.ERROR) self.remove_link_image(link_object=link_obj) self.remove_link_object_by_id(from_id, to_id)
def on_swap(self, event): link_id = self.get_selected_link_id() if link_id == "": elog.debug("No link is selected") return selected = self.get_selected_link_id() engine.removeLinkById(selected) self.__links.pop(selected) # Swapping components of models self.output_component, self.input_component = self.input_component, self.output_component self.__link_source_id = self.output_component["id"] self.__link_target_id = self.input_component["id"] self.input_combo.SetItems(self.get_exchange_item_from_engine(self.input_component, "INPUT")) self.output_combo.SetItems(self.get_exchange_item_from_engine(self.output_component, "OUTPUT")) self.input_combo.SetSelection(0) self.output_combo.SetSelection(0) self.on_new_button(1)
def on_swap(self, event): link_id = self.get_selected_link_id() if link_id == "": elog.debug("No link is selected") return selected = self.get_selected_link_id() engine.removeLinkById(selected) self.__links.pop(selected) # Swapping components of models self.output_component, self.input_component = self.input_component, self.output_component self.__link_source_id = self.output_component['id'] self.__link_target_id = self.input_component['id'] self.input_combo.SetItems(self.get_exchange_item_from_engine(self.input_component, "INPUT")) self.output_combo.SetItems(self.get_exchange_item_from_engine(self.output_component, "OUTPUT")) self.input_combo.SetSelection(0) self.output_combo.SetSelection(0) self.on_new_button(1)
def remove_link(self, link_obj): dlg = wx.MessageDialog(None, 'You are about to remove all data mappings that are associated with this link. Are you sure you want to perform this action?', 'Question', wx.YES_NO | wx.YES_DEFAULT | wx.ICON_WARNING) if dlg.ShowModal() != wx.ID_NO: # remove the link entry in self.links link = self.links.pop(link_obj) # remove the link from the cmd from_id = link[0].ID to_id = link[1].ID # get the link id links = engine.getLinksBtwnModels(from_id, to_id) # remove all links for link in links: success = engine.removeLinkById(link['id']) if not success: elog.error('ERROR|Could not remove link: %s' % link['id']) sPrint('ERROR|Could not remove link: %s' % link['id'], MessageType.ERROR) links = engine.getLinksBtwnModels(to_id, from_id) # Doing this a second time to remove bidirectional links for link in links: success = engine.removeLinkById(link['id']) if not success: elog.error('ERROR|Could not remove link: %s' % link['id']) sPrint('ERROR|Could not remove link: %s' % link['id'], MessageType.ERROR) self.remove_link_image(link_object=link_obj) self.remove_link_object_by_id(from_id, to_id)
def on_save(self, event): """ Saves all link objects to the engine and then closes the link creation window """ # Deleting the links that are in the delete queue for link_id in self.links_to_delete: engine.removeLinkById(link_id) if link_id in self.__links: self.__links.pop(link_id) warnings = [] errors = [] for l in self.__links.values(): if l.iei == "---" or l.oei == "--": warnings.append(l) else: try: kwargs = dict( source_id=l.source_id, source_item=l.oei, target_id=l.target_id, target_item=l.iei, spatial_interpolation=l.spatial_interpolation, temporal_interpolation=l.temporal_interpolation, uid=l.uid, ) # remove the existing link, if there is one engine.removeLinkById(l.uid) # add a new link inside the engine link_id = engine.addLink(**kwargs) if link_id: l.saved = True wx.PostEvent(self, LinkUpdatedEvent()) except: elog.error("ERROR|Could not save link: %s" % l.name) errors.append(l) if len(warnings) > 0: warning_links = "\n".join(l.name() for l in warnings) warning = wx.MessageDialog( self, "Could not save the following links because they lacking either input or output items: \n\n " + warning_links + "\n\n Would you like to discard these partial link objects?", "Question", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING, ) if warning.ShowModal() == wx.ID_YES: self.remove_warning_links(warnings=warnings) self.Destroy() else: return result = self.find_link_direction() if result: # todo: these images need to be coming from config instead of hardcoded self.replace_canvas_image(image="rightArrowBlue60.png", one_way=True) elif result is False: self.replace_canvas_image(image="multiArrow.png") else: self.replace_canvas_image(image="questionMark.png") self.Destroy()
def on_save(self, event): """ Saves all link objects to the engine and then closes the link creation window """ # Deleting the links that are in the delete queue for link_id in self.links_to_delete: engine.removeLinkById(link_id) if link_id in self.__links: self.__links.pop(link_id) warnings = [] errors = [] for l in self.__links.values(): if l.iei == '---' or l.oei == '--': warnings.append(l) else: try: kwargs = dict(source_id=l.source_id, source_item=l.oei, target_id=l.target_id, target_item=l.iei, spatial_interpolation=l.spatial_interpolation, temporal_interpolation=l.temporal_interpolation, uid=l.uid) # remove the existing link, if there is one engine.removeLinkById(l.uid) # add a new link inside the engine link_id = engine.addLink(**kwargs) if link_id: l.saved = True wx.PostEvent(self, LinkUpdatedEvent()) except: elog.error('ERROR|Could not save link: %s' % l.name) errors.append(l) if len(warnings) > 0: warning_links = '\n'.join(l.name() for l in warnings) warning = wx.MessageDialog(self, "Could not save the following links because they lacking either input or output items: \n\n " + warning_links + "\n\n Would you like to discard these partial link objects?", 'Question', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING) if warning.ShowModal() == wx.ID_YES: self.remove_warning_links(warnings=warnings) self.Destroy() else: return result = self.find_link_direction() if result: # todo: these images need to be coming from config instead of hardcoded self.replace_canvas_image(image="rightArrowBlue60.png", one_way=True) elif result is False: self.replace_canvas_image(image="multiArrow.png") else: self.replace_canvas_image(image="questionMark.png") self.Destroy()