def execute(self): sobject = self.sobject search_type = sobject.get_search_type_obj() config = WidgetConfigView.get_by_search_type(search_type, "custom") if not config: return self.element_names = config.get_element_names() # create all of the handlers action_handlers = [] for element_name in (self.element_names): action_handler_class = \ config.get_action_handler(element_name) if action_handler_class == "": action_handler_class = "DatabaseAction" action_handler = WidgetConfig.create_widget(action_handler_class) action_handler.set_name(element_name) action_handler.set_input_prefix("edit") action_options = config.get_action_options(element_name) for key, value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler) # set the sobject for each action handler for action_handler in action_handlers: action_handler.set_sobject(sobject) if action_handler.check(): action_handler.execute()
def execute(my): sobject = my.sobject search_type = sobject.get_search_type_obj() config = WidgetConfigView.get_by_search_type(search_type, "custom") if not config: return my.element_names = config.get_element_names() # create all of the handlers action_handlers = [] for element_name in (my.element_names): action_handler_class = \ config.get_action_handler(element_name) if action_handler_class == "": action_handler_class = "DatabaseAction" action_handler = WidgetConfig.create_widget( action_handler_class ) action_handler.set_name(element_name) action_handler.set_input_prefix("edit") action_options = config.get_action_options(element_name) for key, value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler) # set the sobject for each action handler for action_handler in action_handlers: action_handler.set_sobject(sobject) if action_handler.check(): action_handler.execute()
def init(my): # create all of the display elements if not my.config: # it shouldn't use the my.search_type_obj here as it would absorb the project info my.config = WidgetConfigView.get_by_search_type(my.search_type, my.config_base) my.element_names = my.config.get_element_names() my.element_titles = my.config.get_element_titles() # TODO: should probably be all the attrs my.element_widths = my.config.get_element_widths() simple_view = my.kwargs.get("show_simple_view") if simple_view == "true": simple_view = True else: simple_view = False # go through each element name and construct the handlers for idx, element_name in enumerate(my.element_names): # check to see if these are removed for this production #if element_name in invisible_elements: # continue simple_element = None display_handler = my.config.get_display_handler(element_name) new_display_handler = my.remap_display_handler(display_handler) if new_display_handler: display_handler = new_display_handler if not display_handler: # else get it from default of this type display_handler = my.get_default_display_handler(element_name) # get the display options display_options = my.config.get_display_options(element_name) try: if not display_handler: element = my.config.get_display_widget(element_name) else: element = WidgetConfig.create_widget( display_handler, display_options=display_options ) except Exception, e: from tactic.ui.common import WidgetTableElementWdg element = WidgetTableElementWdg() # FIXME: not sure why this doesn't work #from pyasm.widget import ExceptionWdg #log = ExceptionWdg(e) #element.add(log) # FIXME: not sure why this doesn't work from pyasm.widget import IconWdg icon = IconWdg("Error", IconWdg.ERROR) element.add(icon) element.add(e) # skip the empty elements like ThumbWdg if simple_element and not element.is_simple_viewable(): continue # make simple_element the element if it exists if simple_element: element = simple_element # if the element failed to create, then continue if element == None: continue element.set_name(element_name) title = my.element_titles[idx] element.set_title(title) # FIXME: this causes a circular reference which means the # Garbage collector can't clean it up # make sure the element knows about its layout engine element.set_layout_wdg(my) # TODO: should convert this to ATTRS or someting like that. Not # just width if idx >= len(my.element_widths): element.width = 150 else: element.width = my.element_widths[idx] if my.input_prefix: element.set_input_prefix(my.input_prefix) # get the display options #display_options = my.config.get_display_options(element_name) #for key in display_options.keys(): element.set_options(display_options) my.add_widget(element,element_name) # layout widgets also categorize their widgets based on type if element_name == "Filter": section_name = 'filter' else: section_name = 'default' section = my.sections.get(section_name) if not section: section = [] my.sections[section_name] = section section.append(element)
def init(self): # create all of the display elements if not self.config: # it shouldn't use the self.search_type_obj here as it would absorb the project info self.config = WidgetConfigView.get_by_search_type(self.search_type, self.config_base) self.element_names = self.config.get_element_names() self.element_titles = self.config.get_element_titles() # TODO: should probably be all the attrs self.element_widths = self.config.get_element_widths() simple_view = self.kwargs.get("show_simple_view") if simple_view == "true": simple_view = True else: simple_view = False self.extra_data = self.kwargs.get("extra_data") if self.extra_data and isinstance(self.extra_data, basestring): try: self.extra_data = jsonloads(self.extra_data) except: self.extra_data = self.extra_data.replace("'", '"') self.extra_data = jsonloads(self.extra_data) # go through each element name and construct the handlers for idx, element_name in enumerate(self.element_names): # check to see if these are removed for this production #if element_name in invisible_elements: # continue simple_element = None display_handler = self.config.get_display_handler(element_name) new_display_handler = self.remap_display_handler(display_handler) if new_display_handler: display_handler = new_display_handler if not display_handler: # else get it from default of this type display_handler = self.get_default_display_handler(element_name) # get the display options display_options = self.config.get_display_options(element_name) # add in extra_data if self.extra_data: for key, value in self.extra_data.items(): display_options[key] = value try: if not display_handler: element = self.config.get_display_widget(element_name) else: display_options['element_name'] = element_name element = WidgetConfig.create_widget( display_handler, display_options=display_options ) except Exception as e: from tactic.ui.common import WidgetTableElementWdg element = WidgetTableElementWdg() # FIXME: not sure why this doesn't work #from pyasm.widget import ExceptionWdg #log = ExceptionWdg(e) #element.add(log) # FIXME: not sure why this doesn't work from pyasm.widget import IconWdg icon = IconWdg("Error", IconWdg.ERROR) element.add(icon) element.add(e) # skip the empty elements like ThumbWdg if simple_element and not element.is_simple_viewable(): continue # make simple_element the element if it exists if simple_element: element = simple_element # if the element failed to create, then continue if element == None: continue element.set_name(element_name) title = self.element_titles[idx] element.set_title(title) # FIXME: this causes a circular reference which means the # Garbage collector can't clean it up # make sure the element knows about its layout engine element.set_layout_wdg(self) # TODO: should convert this to ATTRS or someting like that. Not # just width if idx >= len(self.element_widths): element.width = 150 else: element.width = self.element_widths[idx] if self.input_prefix: element.set_input_prefix(self.input_prefix) # get the display options #display_options = self.config.get_display_options(element_name) #for key in display_options.keys(): element.set_options(display_options) self.add_widget(element,element_name) # layout widgets also categorize their widgets based on type if element_name == "Filter": section_name = 'filter' else: section_name = 'default' section = self.sections.get(section_name) if not section: section = [] self.sections[section_name] = section section.append(element) # go through each widget and pass them the filter_data object from tactic.ui.filter import FilterData filter_data = FilterData.get() if not filter_data: filter_data = {} for widget in self.widgets: widget.set_filter_data(filter_data) # initialize all of the child widgets super(BaseConfigWdg,self).init()
def init(my): # create all of the display elements if not my.config: # it shouldn't use the my.search_type_obj here as it would absorb the project info my.config = WidgetConfigView.get_by_search_type( my.search_type, my.config_base) my.element_names = my.config.get_element_names() my.element_titles = my.config.get_element_titles() # TODO: should probably be all the attrs my.element_widths = my.config.get_element_widths() simple_view = my.kwargs.get("show_simple_view") if simple_view == "true": simple_view = True else: simple_view = False # go through each element name and construct the handlers for idx, element_name in enumerate(my.element_names): # check to see if these are removed for this production #if element_name in invisible_elements: # continue simple_element = None display_handler = my.config.get_display_handler(element_name) new_display_handler = my.remap_display_handler(display_handler) if new_display_handler: display_handler = new_display_handler if not display_handler: # else get it from default of this type display_handler = my.get_default_display_handler(element_name) # get the display options display_options = my.config.get_display_options(element_name) try: if not display_handler: element = my.config.get_display_widget(element_name) else: element = WidgetConfig.create_widget( display_handler, display_options=display_options) except Exception, e: from tactic.ui.common import WidgetTableElementWdg element = WidgetTableElementWdg() # FIXME: not sure why this doesn't work #from pyasm.widget import ExceptionWdg #log = ExceptionWdg(e) #element.add(log) # FIXME: not sure why this doesn't work from pyasm.widget import IconWdg icon = IconWdg("Error", IconWdg.ERROR) element.add(icon) element.add(e) # skip the empty elements like ThumbWdg if simple_element and not element.is_simple_viewable(): continue # make simple_element the element if it exists if simple_element: element = simple_element # if the element failed to create, then continue if element == None: continue element.set_name(element_name) title = my.element_titles[idx] element.set_title(title) # FIXME: this causes a circular reference which means the # Garbage collector can't clean it up # make sure the element knows about its layout engine element.set_layout_wdg(my) # TODO: should convert this to ATTRS or someting like that. Not # just width element.width = my.element_widths[idx] if my.input_prefix: element.set_input_prefix(my.input_prefix) # get the display options #display_options = my.config.get_display_options(element_name) #for key in display_options.keys(): element.set_options(display_options) my.add_widget(element, element_name) # layout widgets also categorize their widgets based on type if element_name == "Filter": section_name = 'filter' else: section_name = 'default' section = my.sections.get(section_name) if not section: section = [] my.sections[section_name] = section section.append(element)