def get_display(self): # set up the self refresh event for other widgets or callbacks to call event_container = WebContainer.get_event_container() script = ClipboardWdg.get_self_refresh_script(show_progress=False) event_container.add_listener(self.EVENT_ID, script, replace=True ) if self.is_from_ajax(): div = Widget() else: div = DivWdg() div.set_id(self.ID) div.add_style("display: block") div.add_class("background_box") div.add_style("padding-left: 3px") div.add_style("padding-right: 3px") div.add_style("height: 1.5em") div.add_style("width: 150px") # handle the ajax self.set_ajax_top_id(self.ID) self.register_cmd(ClipboardClearCbk) refresh_script = self.get_refresh_script() search = Search("sthpw/clipboard") search.add_user_filter() search.add_filter("category", "select") count = search.get_count() div.add("Clipboard: %s items: " % count) web = WebContainer.get_web() url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.widget.ClipboardListWdg") ref = url.to_string() iframe = WebContainer.get_iframe() iframe.set_width(64) action = iframe.get_on_script(ref) button = IconButtonWdg("View Clipboard", IconWdg.LOAD) button.add_event("onclick", action) div.add(button) # add the clear clipboard icon clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR) clear_icon.add_event("onclick", refresh_script) div.add(clear_icon) return div
def get_display(self): # set up the self refresh event for other widgets or callbacks to call event_container = WebContainer.get_event_container() script = ClipboardWdg.get_self_refresh_script(show_progress=False) event_container.add_listener(self.EVENT_ID, script, replace=True) if self.is_from_ajax(): div = Widget() else: div = DivWdg() div.set_id(self.ID) div.add_style("display: block") div.add_class("background_box") div.add_style("padding-left: 3px") div.add_style("padding-right: 3px") div.add_style("height: 1.5em") div.add_style("width: 150px") # handle the ajax self.set_ajax_top_id(self.ID) self.register_cmd(ClipboardClearCbk) refresh_script = self.get_refresh_script() search = Search("sthpw/clipboard") search.add_user_filter() search.add_filter("category", "select") count = search.get_count() div.add("Clipboard: %s items: " % count) web = WebContainer.get_web() url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.widget.ClipboardListWdg") ref = url.to_string() iframe = WebContainer.get_iframe() iframe.set_width(64) action = iframe.get_on_script(ref) button = IconButtonWdg("View Clipboard", IconWdg.LOAD) button.add_event("onclick", action) div.add(button) # add the clear clipboard icon clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR) clear_icon.add_event("onclick", refresh_script) div.add(clear_icon) return div
def __init__(my, event_name): my.event_name = event_name my.event_container = WebContainer.get_event_container()
def __init__(self, event_name): self.event_name = event_name self.event_container = WebContainer.get_event_container()
def get_preview_wdg(self): widget = Widget() web = WebContainer.get_web() csv_parser = CsvParser(self.file_path) csv_parser.parse() csv_titles = csv_parser.get_titles() csv_data = csv_parser.get_data() ajax = AjaxCmd() ajax.set_option("search_type", self.search_type) ajax.set_option("file_path", self.file_path) ajax.add_element_name("has_title") event = WebContainer.get_event_container() caller = event.get_event_caller(SiteMenuWdg.EVENT_ID) div = ajax.generate_div() div.set_post_ajax_script(caller) widget.add(div) columns = [] num_columns = len(csv_titles) ajax.set_option("num_columns", num_columns) for i in range(0, num_columns): column = web.get_form_value("column_%s" % i) if column: column = csv_titles[i] else: column = web.get_form_value("column_new_%s" % i) columns.append(column) ajax.add_element_name("column_%s" % i) ajax.add_element_name("new_column_%s" % i) ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd") import_button = IconButtonWdg("Import", IconWdg.REFRESH, True) import_button.add_event("onclick", ajax.get_on_script(show_progress=False)) import_button.add_style("float: right") widget.add(import_button) preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True) preview_submit.add_style("float: right") widget.add(preview_submit) sobject_title = self.search_type_obj.get_title() widget.add("<p>4. Import</p>") widget.add(HtmlElement.br()) widget.add( "<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title) table = Table(css="table") table.add_style("width: 100%") table.add_row() for i, title in enumerate(columns): if not title: title = "<b style='color:red'>*</b>" table.add_header(title) for i, row in enumerate(csv_data): if i > 100: break table.add_row() for j, cell in enumerate(row): table.add_cell(cell) widget.add(table) return widget
def get_preview_wdg(my): widget = Widget() web = WebContainer.get_web() csv_parser = CsvParser(my.file_path) csv_parser.parse() csv_titles = csv_parser.get_titles() csv_data = csv_parser.get_data() ajax = AjaxCmd() ajax.set_option("search_type", my.search_type) ajax.set_option("file_path", my.file_path) ajax.add_element_name("has_title") event = WebContainer.get_event_container() caller = event.get_event_caller(SiteMenuWdg.EVENT_ID) div = ajax.generate_div() div.set_post_ajax_script(caller) widget.add(div) columns = [] num_columns = len(csv_titles) ajax.set_option("num_columns", num_columns) for i in range(0, num_columns): column = web.get_form_value("column_%s" % i) if column: column = csv_titles[i] else: column = web.get_form_value("column_new_%s" % i) columns.append(column) ajax.add_element_name("column_%s" % i) ajax.add_element_name("new_column_%s" % i) ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd") import_button = IconButtonWdg("Import", IconWdg.REFRESH, True) import_button.add_event("onclick", ajax.get_on_script(show_progress=False)) import_button.add_style("float: right") widget.add( import_button ) preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True) preview_submit.add_style("float: right") widget.add(preview_submit) sobject_title = my.search_type_obj.get_title() widget.add("<p>4. Import</p>") widget.add(HtmlElement.br()) widget.add("<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title) table = Table(css="table") table.add_style("width: 100%") table.add_row() for i, title in enumerate(columns): if not title: title = "<b style='color:red'>*</b>" table.add_header(title) for i, row in enumerate(csv_data): if i > 100: break table.add_row() for j, cell in enumerate(row): table.add_cell(cell) widget.add(table) return widget
def __init__(my, event_name): my.event_name = event_name my.event_container = WebContainer.get_event_container()