def create_ui(self): self.set_spacing(16) self.content.add(self.schema_label, False, True) entry_box = mforms.newBox(True) entry_box.set_spacing(5) entry_box.add(mforms.newLabel("File Path:"), False, True) self.shapefile_path = mforms.newTextEntry() entry_box.add(self.shapefile_path, True, True) self.shapefile_browse_btn = newButton() self.shapefile_browse_btn.set_text("Browse...") self.shapefile_browse_btn.add_clicked_callback(self.shapefile_browse) entry_box.add(self.shapefile_browse_btn, False, False) self.content.add(entry_box, False, True) label = mforms.newLabel( """Select a shapefile containing spatial data to load into MySQL. A new table with the imported fields will be created in the selected schema, unless the append or update options are specified.""") self.content.add(label, False, False) self.dbf_box = mforms.newBox(True) self.dbf_box.set_spacing(8) self.dbf_icon = mforms.newImageBox() self.dbf_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.dbf_box.add(self.dbf_icon, False, True) dbf_label = mforms.newLabel("Check if dbf file is present") self.dbf_box.add(dbf_label, True, True) self.dbf_box.show(True) self.content.add(self.dbf_box, False, True) self.proj_box = mforms.newBox(True) self.proj_box.set_spacing(8) self.proj_icon = mforms.newImageBox() self.proj_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.proj_box.add(self.proj_icon, False, True) proj_label = mforms.newLabel("Check if prj file is present") self.proj_box.add(proj_label, True, True) self.proj_box.show(True) self.content.add(self.proj_box, False, True) self.warning_srs = mforms.newLabel("") self.content.add(self.warning_srs, False, True)
def create_ui(self): self.set_spacing(16) self.content.add(self.schema_label, False, True) entry_box = mforms.newBox(True) entry_box.set_spacing(5) entry_box.add(mforms.newLabel("File Path:"), False, True) self.shapefile_path = mforms.newTextEntry() entry_box.add(self.shapefile_path, True, True) self.shapefile_browse_btn = newButton() self.shapefile_browse_btn.set_text("Browse...") self.shapefile_browse_btn.add_clicked_callback(self.shapefile_browse) entry_box.add(self.shapefile_browse_btn, False, False) self.content.add(entry_box, False, True) label = mforms.newLabel("""Select a shapefile containing spatial data to load into MySQL. A new table with the imported fields will be created in the selected schema, unless the append or update options are specified.""") self.content.add(label, False, False) self.dbf_box = mforms.newBox(True) self.dbf_box.set_spacing(8) self.dbf_icon = mforms.newImageBox() self.dbf_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.dbf_box.add(self.dbf_icon, False, True) dbf_label = mforms.newLabel("Check if dbf file is present") self.dbf_box.add(dbf_label, True, True) self.dbf_box.show(True) self.content.add(self.dbf_box, False, True) self.proj_box = mforms.newBox(True) self.proj_box.set_spacing(8) self.proj_icon = mforms.newImageBox() self.proj_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.proj_box.add(self.proj_icon, False, True) proj_label = mforms.newLabel("Check if prj file is present") self.proj_box.add(proj_label, True, True) self.proj_box.show(True) self.content.add(self.proj_box, False, True) self.warning_srs = mforms.newLabel("") self.content.add(self.warning_srs, False, True)
def run_version_select_form(version): form = Form(Form.main_form()) top_vbox = newBox(False) top_vbox.set_padding(16) top_vbox.set_spacing(16) info_hbox = newBox(True) info_hbox.set_spacing(16) img_box = newImageBox() img_box.set_image("warning_icon.png") right_vbox = newBox(False) right_vbox.set_spacing(12) warn_label = newLabel("Server version %s is not supported by Workbench\nconfiguration file management tool." % ".".join(map(lambda x: str(x), version))) right_vbox.add(warn_label, False, False) warn_label = newLabel("Although, you can select different server version\nfor the tool to use. Suggested version " "is given\nbelow. You can either pick version or type one." ) right_vbox.add(warn_label, False, False) warn_label = newLabel("Valid version formats are X.Y.ZZ or X.Y.\nAll other variants will resort to default - 5.1.") right_vbox.add(warn_label, False, False) if (type(version) is not tuple): version = (5,1) dprint_ex(1, "Given version is not a valid tuple object") try: version_maj = int(version[0]) + int(version[1]) / 10.0 except (ValueError, IndexError), e: version_maj = 5.1
def __init__(self, owner): mforms.Box.__init__(self, True) self.set_release_on_add() self.set_managed() self.set_name("Connection Info Section") self.owner = owner self.set_spacing(35) self.icon = mforms.newImageBox() self.icon.set_image( mforms.App.get().get_resource_path("mysql-logo-00.png")) self.icon.set_name("Server Status Stamp") self.add(self.icon, False, True) vbox = mforms.newBox(False) self.vbox = vbox self.add(vbox, True, True) vbox.set_spacing(2) label = mforms.newLabel("Connection Name") label.set_name("Connection Name") vbox.add(label, False, True) self.connection_name = mforms.newLabel("?") self.connection_name.set_style(mforms.VeryBigStyle) self.connection_name.set_name("Connection Name Value") vbox.add(self.connection_name, False, True) self.info_table = None
def make_command_box(callable, title, desc, tooltip, options=None, extra_options=None): l = mforms.newLabel(title) l.set_style(mforms.BoldStyle) self.content.add(l, False, True) l = mforms.newLabel(desc) self.content.add(l, False, True) if extra_options: self.content.add(extra_options, False, True) hb = mforms.newBox(True) hb.set_spacing(12) l = mforms.newImageBox() l.set_image(mforms.App.get().get_resource_path("mini_notice.png")) l.set_tooltip(tooltip) hb.add(l, False, True) for o in options: hb.add(o, False, True) btn = mforms.newButton() btn.add_clicked_callback(callable) btn.set_text(title.strip()) hb.add_end(btn, False, True) self._buttons.append(btn) self.content.add(hb, False, True)
def __init__(self, owner): mforms.Box.__init__(self, True) self.set_release_on_add() self.set_managed() self.owner = owner self.set_spacing(35) self.icon = mforms.newImageBox() self.icon.set_image(mforms.App.get().get_resource_path("mysql-logo-00.png")) self.add(self.icon, False, True) vbox = mforms.newBox(False) self.vbox = vbox self.add(vbox, True, True) vbox.set_spacing(2) vbox.add(mforms.newLabel("Connection Name"), False, True) self.connection_name = mforms.newLabel("?") self.connection_name.set_style(mforms.VeryBigStyle) vbox.add(self.connection_name, False, True) self.info_table = None
def header_box(self): headBox = mforms.newBox(True) img = mforms.newImageBox() img.set_image(str(os.path.dirname(os.path.realpath(__file__))) + '/PropelUtility/propel-logo.png') img.set_size(self.defaults['width']/2-PropelForm.defaults['space']*2, 100) headBox.add(img, False, False) return headBox
def make_panel_header(icon, title, subtitle, button=None): table = mforms.newTable() table.set_name(title + " Panel") table.set_row_count(2) table.set_column_count(3) table.set_row_spacing(0) table.set_column_spacing(15) image = mforms.newImageBox() image.set_name(title + " Icon") image.set_image(mforms.App.get().get_resource_path(icon)) image.set_image_align(mforms.TopCenter) table.add(image, 0, 1, 0, 2, mforms.VFillFlag | mforms.HFillFlag) label = mforms.newLabel(title) label.set_name(title) label.set_text_align(mforms.BottomLeft) label.set_style(mforms.SmallStyle) table.add(label, 1, 2, 0, 1, mforms.HFillFlag | mforms.HExpandFlag | mforms.VFillFlag) label = mforms.newLabel(subtitle) label.set_name(subtitle) label.set_text_align(mforms.TopLeft) label.set_style(mforms.VeryBigStyle) table.add(label, 1, 2, 1, 2, mforms.HFillFlag | mforms.HExpandFlag | mforms.VFillFlag) if button: table.add(button, 2, 3, 0, 2, mforms.VFillFlag | mforms.HFillFlag) return table
def create_standard_header(self, icon, title, description, rightViewObject=None): header = mforms.newTable() header.set_row_count(2) header.set_column_count(3) header.set_row_spacing(0) header.set_column_spacing(15) header.set_padding(12) image = mforms.newImageBox() image.set_image(mforms.App.get().get_resource_path(icon)) image.set_image_align(mforms.TopCenter) label1 = mforms.newLabel(title) label1.set_text_align(mforms.BottomLeft) label1.set_style(mforms.SmallStyle) label2 = mforms.newLabel(description) label2.set_text_align(mforms.TopLeft) label2.set_style(mforms.VeryBigStyle) header.add(image, 0, 1, 0, 2, mforms.VFillFlag | mforms.HFillFlag) header.add(label1, 1, 2, 0, 1, mforms.HFillFlag | mforms.HExpandFlag | mforms.VFillFlag) header.add(label2, 1, 2, 1, 2, mforms.HFillFlag | mforms.HExpandFlag | mforms.VFillFlag) if rightViewObject: header.add(rightViewObject, 2, 3, 0, 2, mforms.VFillFlag | mforms.HFillFlag) return header
def make_command_box(callable, title, desc, tooltip, options = None, extra_options = None): l = mforms.newLabel(title) l.set_style(mforms.BoldStyle) self.content.add(l, False, True) l = mforms.newLabel(desc) self.content.add(l, False, True) if extra_options: self.content.add(extra_options, False, True) hb = mforms.newBox(True) hb.set_spacing(12) l = mforms.newImageBox() l.set_image(mforms.App.get().get_resource_path("mini_notice.png")) l.set_tooltip(tooltip) hb.add(l, False, True) for o in options: hb.add(o, False, True) btn = mforms.newButton() btn.add_clicked_callback(callable) btn.set_text(title.strip()) hb.add_end(btn, False, True) self._buttons.append(btn) self.content.add(hb, False, True)
def __init__(self, conn): mforms.Form.__init__(self, None) self._conn = conn self.set_title("Password Expired") vbox = mforms.newBox(False) vbox.set_padding(20) vbox.set_spacing(18) user = conn.parameterValues["userName"] l = newLabel("Password for MySQL account '%s'@%s expired.\nPlease pick a new password:"******"Mysql@", ""))) l.set_style(mforms.BoldStyle) vbox.add(l, False, True) box = mforms.newTable() box.set_padding(1) box.set_row_count(3) box.set_column_count(2) box.set_column_spacing(7) box.set_row_spacing(8) hbox = mforms.newBox(True) hbox.set_spacing(12) icon = mforms.newImageBox() icon.set_image(mforms.App.get().get_resource_path("wb_lock.png")) hbox.add(icon, False, True) hbox.add(box, True, True) vbox.add(hbox, False, True) self.old_password = mforms.newTextEntry(mforms.PasswordEntry) self.old_password.set_name("Old Password") box.add(newLabel("Old Password:"******"New Password") box.add(newLabel("New Password:"******"Confirm Password") box.add(newLabel("Confirm:", True), 0, 1, 2, 3, mforms.HFillFlag|mforms.VFillFlag) box.add(self.confirm, 1, 2, 2, 3, mforms.HFillFlag|mforms.HExpandFlag) bbox = newBox(True) bbox.set_spacing(8) self.ok = newButton() self.ok.set_text("OK") self.cancel = newButton() self.cancel.set_text("Cancel") mforms.Utilities.add_end_ok_cancel_buttons(bbox, self.ok, self.cancel) vbox.add_end(bbox, False, True) self.set_content(vbox) self.set_size(500, 300) self.center()
def __init__(self, ctrl_be, server_profile, main_view): mforms.Box.__init__(self, True) self.set_managed() self.set_release_on_add() self.set_name("Server Status Main") self.ui_created = False self.set_spacing(24) self.ctrl_be = ctrl_be self.server_profile = server_profile self.main_view = main_view lbox = mforms.newBox(False) lbox.set_name("Server Status Left Side") self.add(lbox, True, True) self.connection_info = ConnectionInfo(self) self.connection_info.set_padding(24) lbox.add(self.connection_info, False, True) self.scrollbox = mforms.newScrollPanel( mforms.ScrollPanelDrawBackground) self.scrollbox.set_padding(24) self.scrollbox.set_name("Extra Server Info Section") self.content = mforms.newBox(False) self.content.set_padding(20) self.content.set_spacing(4) self.scrollbox.add(self.content) lbox.add(self.scrollbox, True, True) image = mforms.newImageBox() image.set_name("Server Status Separator") if self.server_profile.host_os == "linux": image.set_image(mforms.App.get().get_resource_path( "mysql-status-separator-linux.png")) else: image.set_image(mforms.App.get().get_resource_path( "mysql-status-separator.png")) image.set_image_align(mforms.MiddleCenter) self.add(image, False, True) self.status = wb_admin_monitor.WbAdminMonitor(server_profile, self.ctrl_be) self.status.set_size(360, -1) self.status.set_padding(0, 24, 24, 24) self.add(self.status, False, True) self.controls = {} self.currently_started = None self.ctrl_be.add_me_for_event("server_started", self) self.ctrl_be.add_me_for_event("server_offline", self) self.ctrl_be.add_me_for_event("server_stopped", self) self.connection_info.update(self.ctrl_be)
def waitSummary(editor): statement = editor.currentStatement if statement: before_rows = [] after_rows = [] rset = editor.owner.executeScript( "select * from performance_schema.events_waits_summary_by_thread_by_event_name as e join performance_schema.threads as t on e.thread_id=t.thread_id where t.processlist_id=connection_id()" ) if rset: while rset[0].nextRow(): row = [] for i in range(7): if i == 1: row.append(rset[0].stringFieldValue(i)) else: row.append(rset[0].intFieldValue(i)) before_rows.append(row) editor.owner.executeScriptAndOutputToGrid(statement) rset = editor.owner.executeScript( "select * from performance_schema.events_waits_summary_by_thread_by_event_name as e join performance_schema.threads as t on e.thread_id=t.thread_id where t.processlist_id=connection_id()" ) if rset: while rset[0].nextRow(): row = [] for i in range(7): if i == 1: row.append(rset[0].stringFieldValue(i)) else: row.append(rset[0].intFieldValue(i)) after_rows.append(row) tree = event_waits_summary_by_thread_by_event_name_to_tree( before_rows, after_rows) print tree import cairo import cairo_utils surf = cairo_utils.ImageSurface(cairo.CAIRO_FORMAT_ARGB32, 800, 800) c = cairo_utils.Context(surf) c.set_source_rgb(0, 0, 0) c.paint() chart = TreePieChart(tree, c) chart.plot() surf.write_to_png("/tmp/explain.png") view = mforms.newAppView(True, "QueryEditorView", False) scroll = mforms.newScrollPanel(mforms.ScrollPanelNoFlags) scroll.set_visible_scrollers(True, True) image = mforms.newImageBox() image.set_size(800, 800) scroll.add(image) image.set_image("/tmp/explain.png") view.add(scroll, True, True) dock = mforms.fromgrt(editor.resultDockingPoint) dock.dock_view(view, "", 0) dock.set_view_title(view, "Explain") return 0
def make_label_with_tooltip(self, lbl, tooltip): box = mforms.newBox(True) box.add(mforms.newLabel(lbl), False, True) l = mforms.newImageBox() l.set_image(mforms.App.get().get_resource_path("mini_notice.png")) l.set_tooltip(tooltip) box.add(l, False, True) return box
def __init__(self, conn): mforms.Form.__init__(self, None) self._conn = conn self.set_title("Password Expired") vbox = mforms.newBox(False) vbox.set_padding(20) vbox.set_spacing(18) user = conn.parameterValues["userName"] l = newLabel("Password for MySQL account '%s'@%s expired.\nPlease pick a new password:"******"Mysql@", ""))) l.set_style(mforms.BoldStyle) vbox.add(l, False, True) box = mforms.newTable() box.set_padding(1) box.set_row_count(3) box.set_column_count(2) box.set_column_spacing(7) box.set_row_spacing(8) hbox = mforms.newBox(True) hbox.set_spacing(12) icon = mforms.newImageBox() icon.set_image(mforms.App.get().get_resource_path("wb_lock.png")) hbox.add(icon, False, True) hbox.add(box, True, True) vbox.add(hbox, False, True) self.old_password = mforms.newTextEntry(mforms.PasswordEntry) box.add(newLabel("Old Password:"******"New Password:"******"Confirm:", True), 0, 1, 2, 3, mforms.HFillFlag) box.add(self.confirm, 1, 2, 2, 3, mforms.HFillFlag|mforms.HExpandFlag) bbox = newBox(True) bbox.set_spacing(8) self.ok = newButton() self.ok.set_text("OK") self.cancel = newButton() self.cancel.set_text("Cancel") mforms.Utilities.add_end_ok_cancel_buttons(bbox, self.ok, self.cancel) vbox.add_end(bbox, False, True) self.set_content(vbox) self.set_size(500, 260) self.center()
def waitSummary(editor): statement = editor.currentStatement if statement: before_rows = [] after_rows = [] rset = editor.owner.executeScript("select * from performance_schema.events_waits_summary_by_thread_by_event_name as e join performance_schema.threads as t on e.thread_id=t.thread_id where t.processlist_id=connection_id()") if rset: while rset[0].nextRow(): row = [] for i in range(7): if i == 1: row.append(rset[0].stringFieldValue(i)) else: row.append(rset[0].intFieldValue(i)) before_rows.append(row) editor.owner.executeScriptAndOutputToGrid(statement) rset = editor.owner.executeScript("select * from performance_schema.events_waits_summary_by_thread_by_event_name as e join performance_schema.threads as t on e.thread_id=t.thread_id where t.processlist_id=connection_id()") if rset: while rset[0].nextRow(): row = [] for i in range(7): if i == 1: row.append(rset[0].stringFieldValue(i)) else: row.append(rset[0].intFieldValue(i)) after_rows.append(row) tree = event_waits_summary_by_thread_by_event_name_to_tree(before_rows, after_rows) print tree import cairo import cairo_utils surf = cairo_utils.ImageSurface(cairo.CAIRO_FORMAT_ARGB32, 800, 800) c = cairo_utils.Context(surf) c.set_source_rgb(0,0,0) c.paint() chart = TreePieChart(tree, c) chart.plot() surf.write_to_png("/tmp/explain.png") view = mforms.newAppView(True, "QueryEditorView", False) scroll = mforms.newScrollPanel(mforms.ScrollPanelNoFlags) scroll.set_visible_scrollers(True, True) image = mforms.newImageBox() image.set_size(800, 800) scroll.add(image) image.set_image("/tmp/explain.png") view.add(scroll, True, True) dock = mforms.fromgrt(editor.resultDockingPoint) dock.dock_view(view, "", 0) dock.set_view_title(view, "Explain") return 0
def __init__(self, ctrl_be, server_profile, main_view): mforms.Box.__init__(self, True) self.set_managed() self.set_release_on_add() self.ui_created = False self.set_spacing(24) self.ctrl_be = ctrl_be self.server_profile = server_profile self.main_view = main_view lbox = mforms.newBox(False) self.add(lbox, True, True) self.connection_info = ConnectionInfo() self.connection_info.set_padding(24) lbox.add(self.connection_info, False, True) self.scrollbox = mforms.newScrollPanel(mforms.ScrollPanelDrawBackground) self.scrollbox.set_padding(24) self.content = mforms.newBox(False) self.content.set_padding(20) self.content.set_spacing(4) self.scrollbox.add(self.content) lbox.add(self.scrollbox, True, True) image = mforms.newImageBox() if self.server_profile.host_os == "linux": image.set_image(mforms.App.get().get_resource_path("mysql-status-separator-linux.png")) else: image.set_image(mforms.App.get().get_resource_path("mysql-status-separator.png")) image.set_image_align(mforms.MiddleCenter) self.add(image, False, True) self.on_icon = mforms.App.get().get_resource_path("mysql-status-on.png") self.off_icon = mforms.App.get().get_resource_path("mysql-status-off.png") self.status = wb_admin_monitor.WbAdminMonitor(server_profile, self.ctrl_be) self.status.set_size(360, -1) self.status.set_padding(0, 24, 24, 24) self.add(self.status, False, False) self.controls = {} self.currently_started = None self.ctrl_be.add_me_for_event("server_started", self) self.ctrl_be.add_me_for_event("server_stopped", self) self.connection_info.update(self.ctrl_be)
def __init__(self, icon, title, text, button1, button2=None): mforms.Table.__init__(self) self.set_managed() self.set_release_on_add() self.set_padding(-1) # center contents self.set_column_spacing(12) self.set_row_spacing(12) self.set_row_count(4) self.set_column_count(2) self._buttonBox = None if icon: image = mforms.newImageBox() image.set_image(mforms.App.get().get_resource_path(icon)) self.add(image, 0, 1, 0, 3, 0) self._label = mforms.newLabel(title) self._label.set_style(mforms.BigBoldStyle) self._label.set_text_align(mforms.MiddleCenter) self.add(self._label, 1, 2, 0, 1, mforms.VFillFlag | mforms.HFillFlag) self.add(mforms.newLabel(text), 1, 2, 1, 2, mforms.VFillFlag | mforms.HFillFlag) if button1 or button2: self._buttonBox = mforms.newBox(True) self._buttonBox.set_spacing(12) if button1: button_caption, button_action = button1 self._button = mforms.newButton() self._button.set_text(button_caption) self._button.add_clicked_callback(button_action) self._buttonBox.add_end(self._button, False, True) else: self._button = None if button2: button_caption, button_action = button2 self._alt_button = mforms.newButton() self._alt_button.set_text(button_caption) self._alt_button.add_clicked_callback(button_action) self._buttonBox.add_end(self._alt_button, False, True) else: self._alt_button = None if button1 or button2: self.add(self._buttonBox, 1, 2, 2, 3, mforms.VFillFlag | mforms.HFillFlag)
def __init__(self, icon, title, text, button1, button2=None): mforms.Table.__init__(self) self.set_managed() self.set_release_on_add() self.set_padding(-1) # center contents self.set_column_spacing(12) self.set_row_spacing(12) self.set_row_count(3) self.set_column_count(2) if icon: image = mforms.newImageBox() image.set_image(mforms.App.get().get_resource_path(icon)) self.add(image, 0, 1, 0, 3, 0) self._label = mforms.newLabel(title) self._label.set_style(mforms.BigBoldStyle) self._label.set_text_align(mforms.MiddleCenter) self.add(self._label, 1, 2, 0, 1, mforms.HFillFlag) self.add(mforms.newLabel(text), 1, 2, 1, 2, mforms.HFillFlag) if button1 or button2: bbox = mforms.newBox(True) bbox.set_spacing(12) if button1: button_caption, button_action = button1 self._button = mforms.newButton() self._button.set_text(button_caption) self._button.add_clicked_callback(button_action) bbox.add_end(self._button, False, True) else: self._button = None if button2: button_caption, button_action = button2 self._alt_button = mforms.newButton() self._alt_button.set_text(button_caption) self._alt_button.add_clicked_callback(button_action) bbox.add_end(self._alt_button, False, True) else: self._alt_button = None if button1 or button2: self.add(bbox, 1, 2, 2, 3, 0)
def create_labeled_info(self, lbl_txt, lbl_name, tooltip_name = None): lbox = newBox(True) lbox.set_spacing(5) l = mforms.newLabel(lbl_txt) lbox.add(l, False, False) setattr(self, lbl_name, mforms.newLabel("")) l.set_style(mforms.BoldStyle) lbox.add(getattr(self, lbl_name), False, False) if tooltip_name != None: i = mforms.newImageBox() i.set_image(mforms.App.get().get_resource_path("mini_notice.png")) i.set_tooltip("") lbox.add(i, False, False) setattr(self, tooltip_name, i) return lbox
def create_labeled_info(self, lbl_txt, lbl_name, tooltip_name = None): lbox = newBox(True) lbox.set_spacing(5) l = mforms.newLabel(lbl_txt) lbox.add(l, False, False) setattr(self, lbl_name, mforms.newLabel("")) l.set_style(mforms.BoldStyle) lbox.add(getattr(self, lbl_name), False, False) if tooltip_name != None: i = mforms.newImageBox() i.set_image(mforms.App.get().get_resource_path("mini_notice.png")) i.set_tooltip("") lbox.add(i, False, False) setattr(self, tooltip_name, i) return lbox
def __init__(self): mforms.Box.__init__(self, True) self.set_release_on_add() self.set_managed() if not self.on_icon: self.on_icon = mforms.App.get().get_resource_path("mysql-status-on.png") self.off_icon = mforms.App.get().get_resource_path("mysql-status-off.png") self.set_spacing(8) self.image = mforms.newImageBox() self.image.set_image(self.off_icon) self.add(self.image, False, True) self.label = mforms.newLabel("n/a") self.add(self.label, False, True) self.text = None
def __init__(self, owner, func, label): mforms.Box.__init__(self, True) self.set_managed() self.set_release_on_add() self.owner = owner self.label = label self.func = func self._icon = mforms.newImageBox() self._label = mforms.newLabel(label) self._enabled = True self.set_spacing(8) self.add(self._icon, False, True) self.add(self._label, True, True) self.reset()
def make_panel_header(icon, title, subtitle, button=None): table = mforms.newTable() table.set_row_count(2) table.set_column_count(3) table.set_row_spacing(0) table.set_column_spacing(15) image = mforms.newImageBox() image.set_image(mforms.App.get().get_resource_path(icon)) image.set_image_align(mforms.TopCenter) table.add(image, 0, 1, 0, 2, mforms.HFillFlag) label = mforms.newLabel(title) label.set_style(mforms.SmallStyle) table.add(label, 1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag) label = mforms.newLabel(subtitle) label.set_style(mforms.VeryBigStyle) table.add(label, 1, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag) if button: table.add(button, 2, 3, 0, 2, mforms.HFillFlag) return table
def __init__(self, owner, func, label): mforms.Box.__init__(self, True) self.set_managed() self.set_release_on_add() self.owner = owner self.label = label self.func = func self._icon = mforms.newImageBox() self._label = mforms.newLabel(label) self._enabled = True self.set_spacing(8) self.add(self._icon, False, True) self.add(self._label, True, True) self.reset()
def mkswitch(self, state, text = None): box = mforms.newBox(True) box.set_spacing(8) image = mforms.newImageBox() box.add(image, False, True) if state: image.set_image(self.on_icon) box.add(mforms.newLabel("On"), False, True) elif state is None: image.set_image(self.off_icon) box.add(mforms.newLabel("n/a"), False, True) else: image.set_image(self.off_icon) box.add(mforms.newLabel("Off"), False, True) if text: l = mforms.newLabel(text) l.set_style(mforms.BoldStyle) l.set_color("#555555") box.add(l, False, True) return box
def mkswitch(self, state, text=None): box = mforms.newBox(True) box.set_spacing(8) image = mforms.newImageBox() box.add(image, False, True) if state: image.set_image(self.on_icon) box.add(mforms.newLabel("On"), False, True) elif state is None: image.set_image(self.off_icon) box.add(mforms.newLabel("n/a"), False, True) else: image.set_image(self.off_icon) box.add(mforms.newLabel("Off"), False, True) if text: l = mforms.newLabel(text) l.set_style(mforms.BoldStyle) l.set_color("#555555") box.add(l, False, True) return box
def run_version_select_form(version): form = Form(Form.main_form()) top_vbox = newBox(False) top_vbox.set_padding(16) top_vbox.set_spacing(16) info_hbox = newBox(True) info_hbox.set_spacing(16) img_box = newImageBox() img_box.set_image("warning_icon.png") right_vbox = newBox(False) right_vbox.set_spacing(12) warn_label = newLabel( "Server version %s is not supported by Workbench\nconfiguration file management tool." % ".".join(map(lambda x: str(x), version))) right_vbox.add(warn_label, False, False) warn_label = newLabel( "Although, you can select different server version\nfor the tool to use. Suggested version " "is given\nbelow. You can either pick version or type one.") right_vbox.add(warn_label, False, False) warn_label = newLabel( "Valid version formats are X.Y.ZZ or X.Y.\nAll other variants will resort to default - 5.1." ) right_vbox.add(warn_label, False, False) if (type(version) is not tuple): version = (5, 1) dprint_ex(1, "Given version is not a valid tuple object") try: version_maj = int(version[0]) + int(version[1]) / 10.0 except (ValueError, IndexError), e: version_maj = 5.1
def __init__(self): mforms.Box.__init__(self, True) self.set_release_on_add() self.set_managed() self.set_spacing(35) self.icon = mforms.newImageBox() self.icon.set_image( mforms.App.get().get_resource_path("mysql-logo-00.png")) self.add(self.icon, False, True) vbox = mforms.newBox(False) self.vbox = vbox self.add(vbox, True, True) vbox.set_spacing(2) vbox.add(mforms.newLabel("Connection Name"), False, True) self.connection_name = mforms.newLabel("?") self.connection_name.set_style(mforms.VeryBigStyle) vbox.add(self.connection_name, False, True) self.info_table = None
def __init__(self, owner): mforms.Box.__init__(self, False) self.set_managed() self.owner = owner self._selected_user = None self._selected_user_original = None self.valid = False self.suspend_layout() self.set_padding(8) self.set_spacing(8) top_box = newBox(True) top_box.set_spacing(8) self.add(top_box, True, True) bottom_box = newBox(True) bottom_box.set_spacing(8) self.add_button = newButton() self.add_button.set_text("Add Account") bottom_box.add(self.add_button, False, True) self.add_button.add_clicked_callback(self.add_account) self.dup_button = newButton() self.dup_button.set_text("Duplicate") #bottom_box.add(self.dup_button, False, True) self.dup_button.add_clicked_callback(self.dup_account) self.del_button = newButton() self.del_button.set_text("Remove") bottom_box.add(self.del_button, False, True) self.del_button.add_clicked_callback(self.del_account) self.refresh_button = newButton() self.refresh_button.set_text("Refresh") self.refresh_button.add_clicked_callback(self.owner.refresh) bottom_box.add_end(self.refresh_button, False, True) self.save_button = newButton() self.save_button.set_text("Apply") bottom_box.add_end(self.save_button, False, True) self.save_button.add_clicked_callback(self.commit) self.revert_button = newButton() self.revert_button.set_text("Revert") bottom_box.add_end(self.revert_button, False, True) self.revert_button.add_clicked_callback(self.revert) self.revoke_all_button = newButton() self.revoke_all_button.set_text("Revoke All Privileges") bottom_box.add_end(self.revoke_all_button, False, True) self.revoke_all_button.add_clicked_callback(self.revoke_all) self.revoke_all_button.set_tooltip( "Immediately remove all privileges from the account, from every object at all levels.\nThe account itself will be left untouched and logins will still be possible." ) self.add(bottom_box, False, True) account_list_box = newBox(False) account_list_box.set_spacing(8) account_list_box.set_size(220, -1) top_box.add(account_list_box, False, True) label = newLabel("User Accounts") account_list_box.add(label, False, True) #searchbox = TextEntry(SearchEntry) #account_list_box.add(searchbox, False, True) self.user_list = newTreeView(mforms.TreeDefault) self.user_list.add_column(mforms.StringColumnType, "User", 80, False) self.user_list.add_column(mforms.StringColumnType, "From Host", 120, False) self.user_list.end_columns() self.user_list.add_changed_callback(self.user_selected) self.user_list.set_allow_sorting(True) account_list_box.add(self.user_list, True, True) self.content_box = abox = newBox(False) abox.set_spacing(8) top_box.add(abox, True, True) self.account_label = newLabel( "Select an account to edit or click Add Account to create a new one" ) self.account_label.set_style(mforms.BoldStyle) abox.add(self.account_label, False, True) tabView = newTabView(False) abox.add(tabView, True, True) ## vbox = newBox(False) vbox.set_spacing(12) vbox.set_padding(12) tabView.add_page(vbox, "Login") table = newTable() vbox.add(table, False, True) table.set_row_count(7) table.set_column_count(3) table.set_row_spacing(8) table.set_column_spacing(8) self.username = newTextEntry() self.username.set_size(150, -1) self.username.add_changed_callback(self.set_dirty) self.username.set_max_length(16) # max username length for mysql self.password = newTextEntry(mforms.PasswordEntry) self.password.set_size(150, -1) self.password.add_changed_callback(self.set_dirty) self.confirm = newTextEntry(mforms.PasswordEntry) self.confirm.set_size(150, -1) self.confirm.add_changed_callback(self.set_dirty) self.hostlimithost = newTextEntry() self.hostlimithost.add_changed_callback(self.validate_hostlimithost) table.add(rLabel("Login Name:"), 0, 1, 0, 1, mforms.HFillFlag) table.add(self.username, 1, 2, 0, 1, mforms.HFillFlag) table.add( dLabel( "You may create multiple accounts with the same name\nto connect from different hosts." ), 2, 3, 0, 1, mforms.HFillFlag | mforms.HExpandFlag) self.has_extra_plugins = len([ p for p in self.active_plugins if p not in ("mysql_native_password", "mysql_old_password") ]) > 0 if self.has_extra_plugins: self.auth_type_label = rLabel("Authentication Type:") table.add(self.auth_type_label, 0, 1, 1, 2, mforms.HFillFlag) self.auth_type_sel = newSelector() table.add(self.auth_type_sel, 1, 2, 1, 2, mforms.HFillFlag | mforms.HExpandFlag) table.add( dLabel( "\nFor the standard password and/or host based authentication,\nselect 'Standard'.\n" ), 2, 3, 1, 2, mforms.HFillFlag) self.auth_type_sel.add_changed_callback(self.auth_type_changed) self.auth_type_list = [] for plugin in [None] + self.active_plugins: if plugin in ("mysql_native_password", "mysql_old_password"): continue if AUTHENTICATION_PLUGIN_TYPES.has_key(plugin): self.auth_type_sel.add_item( AUTHENTICATION_PLUGIN_TYPES[plugin]["name"]) else: self.auth_type_sel.add_item(plugin) self.auth_type_list.append(plugin) else: self.auth_type_list = None self.auth_string_param = None self.auth_type_password_labels = [] def add(label, l=self.auth_type_password_labels): l.append(label) return label table.add(add(rLabel("Limit Connectivity to Hosts Matching:")), 0, 1, 2, 3, mforms.HFillFlag) table.add(self.hostlimithost, 1, 2, 2, 3, mforms.HFillFlag) self.hostlimit_box = newBox(True) self.hostlimithost_valid_icon = newImageBox() self.hostlimit_box.add(self.hostlimithost_valid_icon, False, False) self.hostlimit_box.add(add(dLabel("% and _ wildcards may be used")), True, True) table.add(self.hostlimit_box, 2, 3, 2, 3, mforms.HFillFlag | mforms.HExpandFlag) table.add(add(rLabel("Password:"******"Type a password to reset it.")), 2, 3, 3, 4, mforms.HFillFlag | mforms.HExpandFlag) table.add(add(rLabel("Confirm Password:"******"Enter password again to confirm.")), 2, 3, 4, 5, mforms.HFillFlag | mforms.HExpandFlag) table.add(newLabel(""), 1, 2, 5, 6, mforms.HFillFlag) if self.has_extra_plugins: self.auth_string_param = newTextEntry() self.auth_string_param.add_changed_callback(self.set_dirty) self.auth_string_label = rLabel("Authentication String:") table.add(self.auth_string_label, 0, 1, 6, 7, mforms.HFillFlag) table.add(self.auth_string_param, 1, 2, 6, 7, mforms.HFillFlag | mforms.HExpandFlag) table.add(dLabel("Authentication plugin specific parameters."), 2, 3, 6, 7, mforms.HFillFlag) self.auth_string_help = newLabel("") vbox.add(self.auth_string_help, False, True) #### box = newBox(False) tabView.add_page(box, "Administrative Roles") lbox = newBox(True) box.add(lbox, True, True) lbox.set_spacing(12) lbox.set_padding(12) self.role_list = newTreeView(mforms.TreeDefault) self.role_list.add_column(mforms.CheckColumnType, "", 30, True) self.role_list.add_column(mforms.StringColumnType, "Role", 150, False) self.role_list.add_column(mforms.StringColumnType, "Description", 300, False) self.role_list.end_columns() lbox.add(self.role_list, True, True) self.role_list.set_cell_edited_callback(self.role_list_toggled) self.role_priv_list = newTreeView(mforms.TreeDefault) self.role_priv_list.add_column(mforms.StringColumnType, "Global Privileges Assigned to User", 200, False) self.role_priv_list.end_columns() self.role_priv_list.set_size(220, -1) self.role_priv_list.set_allow_sorting(True) lbox.add(self.role_priv_list, False, True) self.role_list.clear_rows() for name, desc, privs in SecurityAdminRoles: row = self.role_list.add_row() self.role_list.set_bool(row, 0, False) self.role_list.set_string(row, 1, name) self.role_list.set_string(row, 2, desc) ### table = newTable() tabView.add_page(table, "Account Limits") table.set_padding(12) table.set_column_spacing(8) table.set_row_spacing(8) table.set_row_count(4) table.set_column_count(3) table.add(rLabel("Max. Queries:"), 0, 1, 0, 1, 0) self.max_questions = newTextEntry() self.max_questions.set_size(60, -1) self.max_questions.add_changed_callback(self.set_dirty) table.add(self.max_questions, 1, 2, 0, 1, mforms.HFillFlag) table.add( dLabel( "Number of queries the account can execute within one hour."), 2, 3, 0, 1, mforms.HFillFlag | mforms.HExpandFlag) table.add(rLabel("Max. Updates:"), 0, 1, 1, 2, 0) self.max_updates = newTextEntry() self.max_updates.set_size(60, -1) self.max_updates.add_changed_callback(self.set_dirty) table.add(self.max_updates, 1, 2, 1, 2, mforms.HFillFlag) table.add( dLabel( "Number of updates the account can execute within one hour."), 2, 3, 1, 2, mforms.HFillFlag | mforms.HExpandFlag) table.add(rLabel("Max. Connections:"), 0, 1, 2, 3, 0) self.max_connections = newTextEntry() self.max_connections.set_size(60, -1) self.max_connections.add_changed_callback(self.set_dirty) table.add(self.max_connections, 1, 2, 2, 3, mforms.HFillFlag) table.add( dLabel( "The number of times the account can connect to the server per hour." ), 2, 3, 2, 3, mforms.HFillFlag | mforms.HExpandFlag) table.add(rLabel("Concurrent Connections:"), 0, 1, 3, 4, 0) self.max_uconnections = newTextEntry() self.max_uconnections.set_size(60, -1) self.max_uconnections.add_changed_callback(self.set_dirty) table.add(self.max_uconnections, 1, 2, 3, 4, mforms.HFillFlag) table.add( dLabel( "The number of simultaneous connections to the server the account can have." ), 2, 3, 3, 4, mforms.HFillFlag | mforms.HExpandFlag) self.resume_layout() self.user_selected()
def create_ui(self): self.suspend_layout() if not self.server_profile.admin_enabled: self.add(no_remote_admin_warning_label(self.server_profile), False, True) self.resume_layout() return self.main_view.ui_profile.apply_style(self, 'page') self.set_padding(8) # TODO check padding # Top layout structure. content = newBox(False) self.add(content, True, True) # A spacer at the bottom of the page. spacer = newBox(True) spacer.set_size(-1, 40) self.add(spacer, False, True) # Left pane (start/stop). heading = newLabel("Database Server Status") heading.set_style(mforms.BoldStyle) content.add(heading, False, True) left_pane = newBox(False) left_pane.set_spacing(8) self.long_status_msg = newLabel("The database server is stopped") self.long_status_msg.set_style(mforms.SmallStyle) left_pane.add(self.long_status_msg, False, True) status_message_part = newLabel("The database server instance is ") self.short_status_msg = newLabel("...") self.short_status_msg.set_color("#DD0000") self.start_stop_btn = newButton() self.start_stop_btn.set_text("Start server") self.start_stop_btn.add_clicked_callback(self.start_stop_clicked) start_stop_hbox = newBox(True) start_stop_hbox.add(status_message_part, False, True) start_stop_hbox.add(self.short_status_msg, False, True) start_stop_hbox.add(newLabel(" "), False, False) start_stop_hbox.add(self.start_stop_btn, False, False) left_pane.add(start_stop_hbox, False, False) left_pane.add(self.long_status_msg, False, False) left_pane.add(start_stop_hbox, False, False) description = newLabel( "If you stop the server, you and your applications will not be able to use the Database and all current connections will be closed" ) description.set_style(mforms.SmallStyle) left_pane.add(description, False, False) separator = newImageBox() separator.set_image("options-horizontal-separator.png") left_pane.add(separator, False, True) auto_start_checkbox = newCheckBox() auto_start_checkbox.set_text( "Automatically Start Database Server on Startup") auto_start_checkbox.set_active(True) description = newLabel( "You may select to have the Database server start automatically whenever the computer starts up." ) description.set_style(mforms.SmallStyle) description.set_wrap_text(True) content.add(left_pane, False, True) # Right pane (log). heading = newLabel("Startup Message Log") heading.set_style(mforms.BoldStyle) content.add(heading, False, True) right_pane = newBox(False) right_pane.set_spacing(8) self.startup_msgs_log = newTextBox(mforms.BothScrollBars) self.startup_msgs_log.set_read_only(True) right_pane.add(self.startup_msgs_log, True, True) button_box = newBox(True) self.refresh_button = newButton() self.refresh_button.set_text("Refresh Status") self.refresh_button.add_clicked_callback(lambda: self.refresh(2)) button_box.add(self.refresh_button, False, False) self.copy_to_clipboard_button = newButton() self.copy_to_clipboard_button.set_size(150, -1) self.copy_to_clipboard_button.set_text("Copy to Clipboard") self.copy_to_clipboard_button.add_clicked_callback( self.copy_to_clipboard) button_box.add_end(self.copy_to_clipboard_button, False, False) self.clear_messages_button = newButton() self.clear_messages_button.set_size(150, -1) self.clear_messages_button.set_text("Clear Messages") self.clear_messages_button.add_clicked_callback(self.clear_messages) button_box.add_end(self.clear_messages_button, False, False) right_pane.add(button_box, False, True) content.add(right_pane, True, True) self.resume_layout() self.ctrl_be.add_me_for_event("server_started", self) self.ctrl_be.add_me_for_event("server_stopped", self)
def create_ui(self): self.suspend_layout() if not self.server_profile.admin_enabled: self.add(no_remote_admin_warning_label(self.server_profile), False, True) self.resume_layout() return self.main_view.ui_profile.apply_style(self, 'page') self.set_padding(8) # TODO check padding # Top layout structure. content = newBox(False) self.add(content, True, True) # A spacer at the bottom of the page. spacer = newBox(True) spacer.set_size(-1, 40) self.add(spacer, False, True) # Left pane (start/stop). heading = newLabel("Database Server Status") heading.set_style(mforms.BoldStyle) content.add(heading, False, True) left_pane = newBox(False) left_pane.set_spacing(8) self.long_status_msg = newLabel("The database server is stopped") self.long_status_msg.set_style(mforms.SmallStyle) left_pane.add(self.long_status_msg, False, True) status_message_part = newLabel("The database server instance is ") self.short_status_msg = newLabel("...") self.short_status_msg.set_color("#DD0000") self.start_stop_btn = newButton() self.start_stop_btn.set_text("Start server") self.start_stop_btn.add_clicked_callback(self.start_stop_clicked) start_stop_hbox = newBox(True) start_stop_hbox.add(status_message_part, False, True) start_stop_hbox.add(self.short_status_msg, False, True) start_stop_hbox.add(newLabel(" "), False, False) start_stop_hbox.add(self.start_stop_btn, False, False) left_pane.add(start_stop_hbox, False, False) left_pane.add(self.long_status_msg, False, False) left_pane.add(start_stop_hbox, False, False) description = newLabel("If you stop the server, you and your applications will not be able to use the Database and all current connections will be closed") description.set_style(mforms.SmallStyle) left_pane.add(description, False, False) separator = newImageBox() separator.set_image("options-horizontal-separator.png") left_pane.add(separator, False, True) auto_start_checkbox = newCheckBox() auto_start_checkbox.set_text("Automatically Start Database Server on Startup") auto_start_checkbox.set_active(True) description = newLabel("You may select to have the Database server start automatically whenever the computer starts up.") description.set_style(mforms.SmallStyle) description.set_wrap_text(True) content.add(left_pane, False, True) # Right pane (log). heading = newLabel("Startup Message Log") heading.set_style(mforms.BoldStyle) content.add(heading, False, True) right_pane = newBox(False) right_pane.set_spacing(8) self.startup_msgs_log = newTextBox(mforms.BothScrollBars) self.startup_msgs_log.set_read_only(True) right_pane.add(self.startup_msgs_log, True, True) button_box = newBox(True) self.refresh_button = newButton() self.refresh_button.set_text("Refresh Status") self.refresh_button.add_clicked_callback(lambda:self.refresh(2)) button_box.add(self.refresh_button, False, False) self.copy_to_clipboard_button = newButton() self.copy_to_clipboard_button.set_size(150, -1) self.copy_to_clipboard_button.set_text("Copy to Clipboard") self.copy_to_clipboard_button.add_clicked_callback(self.copy_to_clipboard) button_box.add_end(self.copy_to_clipboard_button, False, False) self.clear_messages_button = newButton() self.clear_messages_button.set_size(150, -1) self.clear_messages_button.set_text("Clear Messages") self.clear_messages_button.add_clicked_callback(self.clear_messages) button_box.add_end(self.clear_messages_button, False, False) right_pane.add(button_box, False, True) content.add(right_pane, True, True) self.resume_layout() self.ctrl_be.add_me_for_event("server_started", self) self.ctrl_be.add_me_for_event("server_stopped", self)
def __init__(self, types_to_display, database_objects, ui_settings={}): super(DatabaseObjectSelector, self).__init__(False) self.database_objects = database_objects self.supported_object_types = types_to_display self.ui_settings = { 'tables': { 'icon': 'db.Table.many.32x32.png', 'small_icon': 'db.Table.16x16.png', 'group_label': 'Migrate Table objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'views': { 'icon': 'db.View.many.32x32.png', 'small_icon': 'db.View.16x16.png', 'group_label': 'Migrate View objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'routines': { 'icon': 'db.Routine.many.32x32.png', 'small_icon': 'db.Routine.16x16.png', 'group_label': 'Migrate Routine objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'routineGroups': { 'icon': 'db.RoutineGroup.48x48.png', 'small_icon': 'db.RoutineGroup.16x16.png', 'group_label': 'Migrate Routine Group/Package objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'synonyms': { 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Synonym objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'structuredTypes': { 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Structured Type objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'sequences': { 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Sequence objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, } # Update the ui settings dict with the custom settings supplied by the user (if any): if isinstance(ui_settings, dict): for key, value in list(ui_settings.items()): if key not in self.ui_settings or not isinstance(value, dict): continue self.ui_settings[key].update(value) # Create UI: self.set_padding(8) self.set_spacing(8) self.ui = {} for group in self.supported_object_types: if group not in self.database_objects or group not in self.ui_settings: continue self.ui[group] = {} group_objects = self.database_objects[group] group_panel = mforms.newPanel(mforms.BorderedPanel) group_box = mforms.newBox(False) group_box.set_padding(8) group_box.set_spacing(8) header_box = mforms.Box(True) header_box.set_spacing(8) icon = mforms.newImageBox() icon.set_image(self.ui_settings[group]['icon']) header_box.add(icon, False, True) text_box = mforms.Box(False) group_selector = mforms.newCheckBox() group_selector.set_text(self.ui_settings[group]['group_label']) group_selector.set_active( bool(self.ui_settings[group]['group_selected'])) group_selector.add_clicked_callback( functools.partial(self.group_checkbox_clicked, group=group)) text_box.add(group_selector, False, True) info_label = mforms.newLabel( self.ui_settings[group]['status_text'] % { 'total': len(group_objects), 'selected': len(group_objects) if self.ui_settings[group]['group_selected'] else 0 }) info_label.set_style(mforms.SmallHelpTextStyle) text_box.add(info_label, False, True) header_box.add(text_box, False, True) show_details = self.ui_settings[group]['show_details'] self.ui_settings[group]['_showing_details'] = show_details filter_button = mforms.newButton() filter_button.set_text( 'Hide Selection' if show_details else 'Show Selection') filter_button.set_enabled( bool(self.ui_settings[group]['group_selected'])) filter_button.add_clicked_callback( functools.partial(self.filter_button_clicked, group=group)) header_box.add_end(filter_button, False, True) group_box.add(header_box, False, True) # The invisible stuff: if len(group_objects) > 0: box = mforms.newBox(True) search_entry = mforms.newTextEntry(mforms.SearchEntry) search_entry.set_name("Search Entry") search_entry.set_placeholder_text( "Filter objects (wildcards chars * and ? are allowed)") search_entry.add_changed_callback( functools.partial(self.search_entry_changed, group=group)) box.add(search_entry, False, True) group_box.add(box, True, True) search_entry.set_size(350, -1) filter_container = mforms.newBox(True) filter_container.set_spacing(8) available_list = mforms.newTreeView(mforms.TreeFlatList) available_list.set_name("Available List") available_list.add_column(mforms.IconColumnType, 'Available Objects', 300, False) available_list.end_columns() available_list.set_selection_mode(mforms.TreeSelectMultiple) available_list.set_allow_sorting(False) filter_container.add(available_list, True, True) control_box = mforms.newBox(False) control_box.set_padding(0, 30, 0, 30) control_box.set_spacing(4) add_button = mforms.newButton() add_button.set_text('>') add_button.enable_internal_padding(False) add_button.add_clicked_callback( functools.partial(self.move_button_clicked, group=group, operation='add')) add_button.set_size(90, 30) control_box.add(add_button, False) remove_button = mforms.newButton() remove_button.set_text('<') remove_button.enable_internal_padding(False) remove_button.add_clicked_callback( functools.partial(self.move_button_clicked, group=group, operation='remove')) remove_button.set_size(90, 30) control_box.add(remove_button, False, True) add_all_button = mforms.newButton() add_all_button.set_text('>>') add_all_button.enable_internal_padding(False) add_all_button.add_clicked_callback( functools.partial(self.move_button_clicked, group=group, operation='add_all')) add_all_button.set_size(90, 30) control_box.add(add_all_button, False, True) remove_all_button = mforms.newButton() remove_all_button.set_text('<<') remove_all_button.enable_internal_padding(False) remove_all_button.add_clicked_callback( functools.partial(self.move_button_clicked, group=group, operation='remove_all')) remove_all_button.set_size(90, 30) control_box.add(remove_all_button, False) filter_container.add(control_box, False, True) selected_list = mforms.newTreeView(mforms.TreeFlatList) selected_list.set_name("Selected List") selected_list.add_column(mforms.IconColumnType, 'Objects to Migrate', 300, False) selected_list.end_columns() selected_list.set_selection_mode(mforms.TreeSelectMultiple) selected_list.set_allow_sorting(False) for item in sorted(group_objects): node = selected_list.add_node() node.set_icon_path(0, self.ui_settings[group]['small_icon']) node.set_string(0, item) filter_container.add(selected_list, True, True) group_box.add(filter_container, True, True) filter_container.show(bool(show_details)) self.ui[group].update({ 'filter_container': filter_container, 'available_list': available_list, 'selected_list': selected_list, 'search_entry': search_entry, }) else: # Empty object list filter_button.set_enabled(False) self.ui[group].update({ 'icon': icon, 'group_selector': group_selector, 'group_panel': group_panel, 'info_label': info_label, 'filter_button': filter_button, 'all_objects': set(group_objects), 'has_elements': bool(len(group_objects)), 'available': set(), 'selected': set(group_objects), 'objects_passing_filter': set(group_objects), }) group_panel.add(group_box) self.add(group_panel, False, True)
def create_uix(self): container = mforms.newBox(True) container.set_spacing(30) left_side_box = mforms.newBox(False) left_side_box.set_padding(8) logo_image = mforms.newImageBox() logo_image.set_image('migration_logo.png') left_side_box.add(logo_image, False, False) container.add(left_side_box, False, False) # Main layout structure content = mforms.newBox(False) content.set_padding(8) content.set_spacing(12) title_image = mforms.newImageBox() title_image.set_image('migration_title.png') content.add(title_image, False, False) help_label = mforms.newLabel('''To perform a new migration click the [Start New Migration] button below. To re-run a previous migration or to perform a new migration based on a previous migration please double click one of the migration projects below.''') content.add(help_label, False, False) wrapper_button_box = mforms.newBox(True) wrapper_button_box.set_padding(8) button_new_migration = mforms.newButton() button_new_migration.set_text('Start New Migration') #button_new_migration.add_clicked_callback(lambda x: x) wrapper_button_box.add(button_new_migration, False, False) content.add(wrapper_button_box, False, False) project_box = mforms.newBox(False) project_box.set_spacing(8) project_label = mforms.newLabel('Project Overview') project_label.set_style(mforms.BoldStyle) project_box.add(project_label, False, False) project_tree = mforms.newTreeNodeView(mforms.TreeDefault) project_box.add(project_tree, True, True) project_button_box = mforms.newBox(True) project_button_box.set_spacing(8) button_rerun_migration = mforms.newButton() button_rerun_migration.set_text('Re-Run Migration') button_edit_migration = mforms.newButton() button_edit_migration.set_text('Edit Migration Project') project_button_box.add(button_rerun_migration, False, False) project_button_box.add(button_edit_migration, False, False) project_box.add(project_button_box, False, True) content.add(project_box, False, False) container.add(content, False, False) # Right side layout structure right_side_box = mforms.newBox(False) right_side_image = mforms.newImageBox() right_side_image.set_image('migration_background.png') right_side_image.set_image_align(mforms.TopRight) right_side_box.add(right_side_image, False, False) container.add(right_side_box, True, True) self.add(container, True, True)
def __init__(self, owner): mforms.Box.__init__(self, True) self.set_managed() self.owner = owner self._selected_user = None self._selected_user_original = None self.suspend_layout() self.set_spacing(8) self.set_padding(8) schema_list_box = newBox(False) schema_list_box.set_spacing(8) schema_list_box.set_size(150, -1) self.add(schema_list_box, False, True) #searchbox = TextEntry(SearchEntry) #schema_list_box.add(searchbox, False, True) self.user_list = newTreeView(mforms.TreeDefault) self.user_list.add_column(mforms.StringColumnType, "Users", 140, False) self.user_list.end_columns() self.user_list.add_changed_callback(self.user_selected) self.user_list.set_allow_sorting(True) schema_list_box.add(self.user_list, True, True) self.schema_rights_checks = {} self.content_box = priv_vbox = newBox(False) priv_vbox.set_spacing(8) self.add(priv_vbox, True, True) priv_vbox.add( newLabel( "Select a user and pick the privileges it has for a given Schema and Host combination." ), False, True) self.privs_list = newTreeView(mforms.TreeDefault) self.privs_list.add_column(mforms.StringColumnType, "Host", 100, True) self.privs_list.add_column(mforms.StringColumnType, "Schema", 100, True) self.privs_list.add_column(mforms.StringColumnType, "Privileges", 800, False) self.privs_list.end_columns() self.privs_list.add_changed_callback(self.schema_priv_selected) priv_vbox.add(self.privs_list, True, True) bbox = newBox(True) bbox.set_spacing(8) bbox.add( dLabel( "Schema and Host fields may use % and _ wildcards. The server will match specific entries before wildcarded ones." ), False, True) self.add_entry_button = newButton() self.add_entry_button.set_text("Add Entry...") bbox.add_end(self.add_entry_button, False, True) self.add_entry_button.add_clicked_callback(self.add_entry) self.del_entry_button = newButton() self.del_entry_button.set_text("Delete Entry") bbox.add_end(self.del_entry_button, False, True) self.del_entry_button.add_clicked_callback(self.del_entry) priv_vbox.add(bbox, False, True) self.schema_priv_label = newLabel("") priv_vbox.add(self.schema_priv_label, False, True) hbox = newBox(True) hbox.set_homogeneous(True) hbox.set_spacing(8) priv_vbox.add(hbox, False, True) self.schema_object_privs_panel = panel = newPanel( mforms.TitledBoxPanel) panel.set_title("Object Rights") box = newBox(False) box.set_padding(8) for name in SCHEMA_OBJECT_RIGHTS: cb = newCheckBox() label, desc = PrivilegeInfo.get(name, ("", None)) cb.set_text(label) if desc: cb.set_tooltip(desc) cb.add_clicked_callback(self.schema_priv_checked) box.add(cb, False, False) self.schema_rights_checks[name] = cb panel.add(box) hbox.add(panel, False, True) self.schema_ddl_privs_panel = panel = newPanel(mforms.TitledBoxPanel) panel.set_title("DDL Rights") box = newBox(False) box.set_padding(8) for name in SCHEMA_DDL_RIGHTS: cb = newCheckBox() label, desc = PrivilegeInfo.get(name, ("", None)) cb.set_text(label) if desc: cb.set_tooltip(desc) cb.add_clicked_callback(self.schema_priv_checked) box.add(cb, False, False) self.schema_rights_checks[name] = cb panel.add(box) hbox.add(panel, False, True) self.schema_other_privs_panel = panel = newPanel(mforms.TitledBoxPanel) panel.set_title("Other Rights") box = newBox(False) box.set_padding(8) for name in SCHEMA_OTHER_RIGHTS: cb = newCheckBox() label, desc = PrivilegeInfo.get(name, ("", None)) cb.set_text(label) if desc: cb.set_tooltip(desc) cb.add_clicked_callback(self.schema_priv_checked) box.add(cb, False, False) self.schema_rights_checks[name] = cb panel.add(box) hbox.add(panel, False, True) bottom_box = newBox(True) bottom_box.set_spacing(8) if 0: img = newImageBox() if App.get().get_resource_path("task_warning_mac.png"): img.set_image("task_warning_mac.png") else: img.set_image("task_warning.png") bottom_box.add(img, False, True) bottom_box.add( dLabel( "There are %i schema privilege entries for accounts that don't exist" ), False, True) purge = newButton() purge.set_text("Purge") bottom_box.add(purge, False, True) self.grant_all = newButton() self.grant_all.set_text('Select "ALL"') bottom_box.add(self.grant_all, False, True) self.grant_all.add_clicked_callback(self.grant_all_schema_privs) self.revoke_all = newButton() self.revoke_all.set_text("Unselect All") bottom_box.add(self.revoke_all, False, True) self.revoke_all.add_clicked_callback(self.revoke_all_schema_privs) self.save_button = newButton() self.save_button.set_text("Save Changes") bottom_box.add_end(self.save_button, False, True) self.save_button.add_clicked_callback(self.commit) self.revert_button = newButton() self.revert_button.set_text("Revert") bottom_box.add_end(self.revert_button, False, True) self.revert_button.add_clicked_callback(self.revert) priv_vbox.add(bottom_box, False, True) self.resume_layout()
def __init__(self, types_to_display, database_objects, ui_settings={}): super(DatabaseObjectSelector, self).__init__(False) self.database_objects = database_objects self.supported_object_types = types_to_display self.ui_settings = { 'tables' : { 'icon': 'db.Table.many.32x32.png', 'small_icon': 'db.Table.16x16.png', 'group_label': 'Migrate Table objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'views' : { 'icon': 'db.View.many.32x32.png', 'small_icon': 'db.View.16x16.png', 'group_label': 'Migrate View objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'routines':{ 'icon': 'db.Routine.many.32x32.png', 'small_icon': 'db.Routine.16x16.png', 'group_label': 'Migrate Routine objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'routineGroups':{ 'icon': 'db.RoutineGroup.48x48.png', 'small_icon': 'db.RoutineGroup.16x16.png', 'group_label': 'Migrate Routine Group/Package objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'synonyms':{ 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Synonym objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'structuredTypes':{ 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Structured Type objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, 'sequences':{ 'icon': 'grt_object.png', 'small_icon': 'grt_object.png', 'group_label': 'Migrate Sequence objects', 'group_selected': True, 'status_text': '%(total)d total, %(selected)d selected', 'show_details': False, }, } # Update the ui settings dict with the custom settings supplied by the user (if any): if isinstance(ui_settings, dict): for key, value in ui_settings.iteritems(): if key not in self.ui_settings or not isinstance(value, dict): continue self.ui_settings[key].update(value) # Create UI: self.set_padding(8) self.set_spacing(8) self.ui = {} for group in self.supported_object_types: if group not in self.database_objects or group not in self.ui_settings: continue self.ui[group] = {} group_objects = self.database_objects[group] group_panel = mforms.newPanel(mforms.BorderedPanel) group_box = mforms.newBox(False) group_box.set_padding(8) group_box.set_spacing(8) header_box = mforms.Box(True) header_box.set_spacing(8) icon = mforms.newImageBox() icon.set_image(self.ui_settings[group]['icon']) header_box.add(icon, False) text_box = mforms.Box(False) group_selector = mforms.newCheckBox() group_selector.set_text(self.ui_settings[group]['group_label']) group_selector.set_active(bool(self.ui_settings[group]['group_selected'])) group_selector.add_clicked_callback(functools.partial(self.group_checkbox_clicked, group=group)) text_box.add(group_selector, False) info_label = mforms.newLabel(self.ui_settings[group]['status_text'] % {'total': len(group_objects), 'selected': len(group_objects) if self.ui_settings[group]['group_selected'] else 0 }) info_label.set_style(mforms.SmallHelpTextStyle) text_box.add(info_label, False) header_box.add(text_box, False) show_details = self.ui_settings[group]['show_details'] self.ui_settings[group]['_showing_details'] = show_details filter_button = mforms.newButton() filter_button.set_text('Hide Selection' if show_details else 'Show Selection') filter_button.set_enabled(bool(self.ui_settings[group]['group_selected'])) filter_button.add_clicked_callback(functools.partial(self.filter_button_clicked, group=group)) header_box.add_end(filter_button, False, True) group_box.add(header_box, False) # The invisible stuff: if len(group_objects) > 0: box = mforms.newBox(True) search_entry = mforms.newTextEntry(mforms.SearchEntry) search_entry.set_placeholder_text("Filter objects (wildcards chars * and ? are allowed)") search_entry.add_changed_callback(functools.partial(self.search_entry_changed, group=group)) box.add(search_entry, False, True) group_box.add(box, False, True) search_entry.set_size(350, -1) filter_container = mforms.newBox(True) filter_container.set_spacing(8) available_list = mforms.newTreeNodeView(mforms.TreeFlatList) available_list.add_column(mforms.IconColumnType, 'Available Objects', 300, False) available_list.end_columns() available_list.set_selection_mode(mforms.TreeSelectMultiple) available_list.set_allow_sorting(False) filter_container.add(available_list, True, True) control_box = mforms.newBox(False) control_box.set_padding(0, 30, 0, 30) control_box.set_spacing(4) add_button = mforms.newButton() add_button.set_text('>') add_button.enable_internal_padding(False) add_button.add_clicked_callback(functools.partial(self.move_button_clicked, group=group, operation='add')) control_box.add(add_button, False) remove_button = mforms.newButton() remove_button.set_text('<') remove_button.enable_internal_padding(False) remove_button.add_clicked_callback(functools.partial(self.move_button_clicked, group=group, operation='remove')) control_box.add(remove_button, False) add_all_button = mforms.newButton() add_all_button.set_text('>>') add_all_button.enable_internal_padding(False) add_all_button.add_clicked_callback(functools.partial(self.move_button_clicked, group=group, operation='add_all')) control_box.add(add_all_button, False) remove_all_button = mforms.newButton() remove_all_button.set_text('<<') remove_all_button.enable_internal_padding(False) remove_all_button.add_clicked_callback(functools.partial(self.move_button_clicked, group=group, operation='remove_all')) control_box.add(remove_all_button, False) filter_container.add(control_box, False, False) selected_list = mforms.newTreeNodeView(mforms.TreeFlatList) selected_list.add_column(mforms.IconColumnType, 'Objects to Migrate', 300, False) selected_list.end_columns() selected_list.set_selection_mode(mforms.TreeSelectMultiple) selected_list.set_allow_sorting(False) for item in sorted(group_objects): node = selected_list.add_node() node.set_icon_path(0, self.ui_settings[group]['small_icon']) node.set_string(0, item) filter_container.add(selected_list, True, True) group_box.add(filter_container, True, True) filter_container.show(bool(show_details)) self.ui[group].update( { 'filter_container': filter_container, 'available_list': available_list, 'selected_list': selected_list, 'search_entry': search_entry, } ) else: # Empty object list filter_button.set_enabled(False) self.ui[group].update ( { 'icon': icon, 'group_selector': group_selector, 'group_panel': group_panel, 'info_label': info_label, 'filter_button': filter_button, 'all_objects': set(group_objects), 'has_elements': bool(len(group_objects)), 'available': set(), 'selected': set(group_objects), 'objects_passing_filter': set(group_objects), } ) group_panel.add(group_box) self.add(group_panel, False, True)
def __init__(self, main): WizardPage.__init__(self, main, "Data Transfer Setup") self.main.add_wizard_page(self, "DataMigration", "Data Transfer Setup") label = mforms.newLabel( "Select options for the copy of the migrated schema tables in the target MySQL server and click [Next >] to execute." ) self.content.add(label, False, True) panel = mforms.newPanel(mforms.TitledBoxPanel) panel.set_title("Data Copy") self.content.add(panel, False, True) box = mforms.newBox(False) panel.add(box) box.set_padding(16) box.set_spacing(16) rid = mforms.RadioButton.new_id() self._copy_db = mforms.newRadioButton(rid) self._copy_db.set_text("Online copy of table data to target RDBMS") self._copy_db.add_clicked_callback(self._script_radio_option_callback) box.add(self._copy_db, False, True) # XXX TODO #box.add(mforms.newLabel(""), False, True) #self._add_script_checkbox_option(box, "dump_to_file", "Create a dump file with the data", "Dump File:", "Save As") if sys.platform == "win32": self._add_script_radiobutton_option( box, "copy_script", "Create a batch file to copy the data at another time", "Batch File:", "Save As", "You should edit this file to add the source and target server passwords before running it.", rid) else: self._add_script_radiobutton_option( box, "copy_script", "Create a shell script to copy the data from outside Workbench", "Shell Script File:", "Save As", "You should edit this file to add the source and target server passwords before running it.", rid) self._add_script_radiobutton_option( box, "bulk_copy_script", "Create a shell script to use native server dump and load abilities for fast migration", "Bulk Data Copy Script:", "Save As", "Edit the generated file and change passwords at the top of the generated script.\nRun it on the source server to create a zip package containing a data dump as well as a load script.\nCopy this to the target server, extract it, and run the import script. See the script output for further details.", rid) panel = mforms.newPanel(mforms.TitledBoxPanel) panel.set_title("Options") self.content.add(panel, False, True) self.options_box = mforms.newBox(False) self.options_box.set_padding(12) self.options_box.set_spacing(8) panel.add(self.options_box) self._truncate_db = mforms.newCheckBox() self._truncate_db.set_text( "Truncate target tables (i.e. delete contents) before copying data" ) self.options_box.add(self._truncate_db, False, True) hbox = mforms.newBox(True) hbox.set_spacing(16) hbox.add(mforms.newLabel("Worker tasks"), False, True) self._worker_count = mforms.newTextEntry() self._worker_count.set_value("2") self._worker_count.set_size(30, -1) hbox.add(self._worker_count, False, True) l = mforms.newImageBox() l.set_image(mforms.App.get().get_resource_path("mini_notice.png")) l.set_tooltip( "Number of tasks to use for data transfer. Each task will open a " + "connection to both source and target RDBMSes to copy table rows.\nDefault value 2." ) hbox.add(l, False, True) self.options_box.add(hbox, False, True) self._debug_copy = mforms.newCheckBox() self._debug_copy.set_text("Enable debug output for table copy") self.options_box.add(self._debug_copy, False, True) self._driver_sends_utf8 = mforms.newCheckBox() self._driver_sends_utf8.set_text( "Driver sends data already encoded as UTF-8.") self.options_box.add(self._driver_sends_utf8, False, True) ### self._advanced_panel = mforms.newPanel(mforms.TitledBoxPanel) self._advanced_panel.set_title("Tables to Copy") self.content.add(self._advanced_panel, True, True) box = mforms.newBox(False) box.set_padding(12) box.set_spacing(8) l = mforms.newLabel( """You can limit the number of rows to be copied for certain tables. Tables that are referenced by foreign keys from other tables cannot be limited, unless data copy from the referencing tables is also disabled. All tables are copied by default.""") l.set_style(mforms.SmallHelpTextStyle) box.add(l, False, True) self._tree = mforms.newTreeNodeView(mforms.TreeDefault) self._tree.add_column(mforms.IconStringColumnType, "Table", 200, False) self._tree.add_column(mforms.StringColumnType, "Limit Copy", 100, True) self._tree.add_column(mforms.StringColumnType, "Referencing Tables", 500, False) self._tree.end_columns() box.add(self._tree, True, True) self._advanced_panel.add(box) self._tree.set_cell_edited_callback(self._cell_edited) self._advbox_shown = False self._advanced_panel.show(False)
def __init__(self, json): mforms.AppView.__init__(self, False, "QueryExplain", False) self.json_data = json self.toolbar = mforms.newToolBar(mforms.SecondaryToolBar) get_resource_path = mforms.App.get().get_resource_path #btn = newToolBarItem(mforms.SegmentedToggleItem) #btn.set_icon(get_resource_path("qe_resultset-tb-switcher_grid_off_mac.png")) #btn.set_alt_icon(get_resource_path("qe_resultset-tb-switcher_grid_on_mac.png")) #self.toolbar.add_item(btn) #btn = newToolBarItem(mforms.SegmentedToggleItem) #btn.set_icon(get_resource_path("qe_resultset-tb-switcher_explain_off.png")) #btn.set_alt_icon(get_resource_path("qe_resultset-tb-switcher_explain_on.png")) #self.toolbar.add_item(btn) #s = newToolBarItem(mforms.SeparatorItem) #self.toolbar.add_item(s) l = newToolBarItem(mforms.LabelItem) l.set_text("Spacing:") self.toolbar.add_item(l) btn = newToolBarItem(mforms.TextActionItem) btn.set_icon(get_resource_path("tiny_more_space.png")) btn.set_tooltip("Increase spacing between nodes.") btn.add_activated_callback(self.spacing_inc) self.toolbar.add_item(btn) btn = newToolBarItem(mforms.TextActionItem) btn.set_icon(get_resource_path("tiny_less_space.png")) btn.set_tooltip("Decrease spacing between nodes.") btn.add_activated_callback(self.spacing_dec) self.toolbar.add_item(btn) #s = newToolBarItem(mforms.SeparatorItem) #self.toolbar.add_item(s) #l = newToolBarItem(mforms.LabelItem) #l.set_text("Layout:") #self.toolbar.add_item(l) #btn = newToolBarItem(mforms.ToggleItem) #btn.set_icon(get_resource_path("tiny_align_h_middle.png")) #btn.add_activated_callback(lambda x:self.change_layout(True)) #self.toolbar.add_item(btn) #btn = newToolBarItem(mforms.ToggleItem) #btn.set_icon(get_resource_path("tiny_align_v_middle.png")) #btn.add_activated_callback(lambda x:self.change_layout(False)) #self.toolbar.add_item(btn) s = newToolBarItem(mforms.SeparatorItem) self.toolbar.add_item(s) btn = newToolBarItem(mforms.ActionItem) btn.set_icon(get_resource_path("tiny_saveas.png")) btn.add_activated_callback(self.save) btn.set_tooltip("Save image to an external file.") self.toolbar.add_item(btn) self.add(self.toolbar, False, True) self.scroll = mforms.newScrollPanel(mforms.ScrollPanelNoFlags) self.scroll.set_back_color("#ffffff") self.scroll.set_visible_scrollers(True, True) self.img = mforms.newImageBox() self.scroll.add(self.img) self.add(self.scroll, True, True)
def create_ui(self): self.set_spacing(16) self.content.add(self.schema_label, False, True) entry_box = mforms.newBox(True) entry_box.set_spacing(5) entry_box.add(mforms.newLabel("File Path:"), False, True) self.shapefile_path = mforms.newTextEntry() entry_box.add(self.shapefile_path, True, True) self.shapefile_browse_btn = newButton() self.shapefile_browse_btn.set_text("Browse...") self.shapefile_browse_btn.set_name("Browse") self.shapefile_browse_btn.add_clicked_callback(self.shapefile_browse) entry_box.add(self.shapefile_browse_btn, False, True) self.content.add(entry_box, False, True) label = mforms.newLabel( """Select a shapefile containing spatial data to load into MySQL. A new table with the imported fields will be created in the selected schema, unless the append or update options are specified.""") self.content.add(label, False, True) self.ogrinfo_box = mforms.newBox(True) self.ogrinfo_box.set_spacing(8) self.ogrinfo_icon = mforms.newImageBox() self.ogrinfo_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.ogrinfo_box.add(self.ogrinfo_icon, False, True) ogrinfo_label = mforms.newLabel("Check if ogrinfo tool is present.") self.ogrinfo_box.add(ogrinfo_label, True, True) self.content.add(self.ogrinfo_box, False, True) self.ogrinfo_missing_lbl = mforms.newLabel( "ogrinfo executable wasn't found. Please check if it's available in the PATH." ) self.ogrinfo_missing_lbl.show(False) self.content.add(self.ogrinfo_missing_lbl, False, True) self.ogr2ogr_box = mforms.newBox(True) self.ogr2ogr_box.set_spacing(8) self.ogr2ogr_icon = mforms.newImageBox() self.ogr2ogr_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.ogr2ogr_box.add(self.ogr2ogr_icon, False, True) ogr2ogr_label = mforms.newLabel("Check if ogr2ogr tool is present.") self.ogr2ogr_box.add(ogr2ogr_label, True, True) self.content.add(self.ogr2ogr_box, False, True) self.ogr2ogr_missing_lbl = mforms.newLabel( "ogr2ogr executable wasn't find. Please check if it's available in the PATH." ) self.ogr2ogr_missing_lbl.show(False) self.content.add(self.ogr2ogr_missing_lbl, False, True) self.dbf_box = mforms.newBox(True) self.dbf_box.set_spacing(8) self.dbf_icon = mforms.newImageBox() self.dbf_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.dbf_box.add(self.dbf_icon, False, True) dbf_label = mforms.newLabel("Check if dbf file is present.") self.dbf_box.add(dbf_label, True, True) self.dbf_box.show(True) self.content.add(self.dbf_box, False, True) self.proj_box = mforms.newBox(True) self.proj_box.set_spacing(8) self.proj_icon = mforms.newImageBox() self.proj_icon.set_image("task_unchecked%s.png" % os_icon_suffix) self.proj_box.add(self.proj_icon, False, True) proj_label = mforms.newLabel("Check if prj file is present.") self.proj_box.add(proj_label, True, True) self.proj_box.show(True) self.content.add(self.proj_box, False, True) self.warning_srs = mforms.newLabel("") self.content.add(self.warning_srs, False, True) self.check_ogr_executables()
def __init__(self, json): mforms.AppView.__init__(self, False, "QueryExplain", False) self.json_data = json self.toolbar = mforms.newToolBar(mforms.SecondaryToolBar) get_resource_path = mforms.App.get().get_resource_path #btn = newToolBarItem(mforms.SegmentedToggleItem) #btn.set_icon(get_resource_path("qe_resultset-tb-switcher_grid_off_mac.png")) #btn.set_alt_icon(get_resource_path("qe_resultset-tb-switcher_grid_on_mac.png")) #self.toolbar.add_item(btn) #btn = newToolBarItem(mforms.SegmentedToggleItem) #btn.set_icon(get_resource_path("qe_resultset-tb-switcher_explain_off.png")) #btn.set_alt_icon(get_resource_path("qe_resultset-tb-switcher_explain_on.png")) #self.toolbar.add_item(btn) #s = newToolBarItem(mforms.SeparatorItem) #self.toolbar.add_item(s) l = newToolBarItem(mforms.LabelItem) l.set_text("Spacing:") self.toolbar.add_item(l) btn = newToolBarItem(mforms.TextActionItem) btn.set_icon(get_resource_path("tiny_more_space.png")) btn.set_tooltip("Increase spacing between nodes.") btn.add_activated_callback(self.spacing_inc) self.toolbar.add_item(btn) btn = newToolBarItem(mforms.TextActionItem) btn.set_icon(get_resource_path("tiny_less_space.png")) btn.set_tooltip("Decrease spacing between nodes.") btn.add_activated_callback(self.spacing_dec) self.toolbar.add_item(btn) #s = newToolBarItem(mforms.SeparatorItem) #self.toolbar.add_item(s) #l = newToolBarItem(mforms.LabelItem) #l.set_text("Layout:") #self.toolbar.add_item(l) #btn = newToolBarItem(mforms.ToggleItem) #btn.set_icon(get_resource_path("tiny_align_h_middle.png")) #btn.add_activated_callback(lambda x:self.change_layout(True)) #self.toolbar.add_item(btn) #btn = newToolBarItem(mforms.ToggleItem) #btn.set_icon(get_resource_path("tiny_align_v_middle.png")) #btn.add_activated_callback(lambda x:self.change_layout(False)) #self.toolbar.add_item(btn) s = newToolBarItem(mforms.SeparatorItem) self.toolbar.add_item(s) btn = newToolBarItem(mforms.ActionItem) btn.set_icon(get_resource_path("tiny_saveas.png")) btn.add_activated_callback(self.save) btn.set_tooltip("Save image to an external file.") self.toolbar.add_item(btn) self.add(self.toolbar, False, True) self.scroll = mforms.newScrollPanel(mforms.ScrollPanelNoFlags) self.scroll.set_back_color("#ffffff") self.scroll.set_visible_scrollers(True, True) self.img = mforms.newImageBox() self.scroll.add(self.img) self.add(self.scroll, True, True)
def create_uix(self): container = mforms.newBox(True) container.set_spacing(30) left_side_box = mforms.newBox(False) left_side_box.set_padding(8) logo_image = mforms.newImageBox() logo_image.set_image('migration_logo.png') left_side_box.add(logo_image, False, True) container.add(left_side_box, False, True) # Main layout structure content = mforms.newBox(False) content.set_padding(8) content.set_spacing(12) title_image = mforms.newImageBox() title_image.set_image('migration_title.png') content.add(title_image, False, True) help_label = mforms.newLabel( '''To perform a new migration click the [Start New Migration] button below. To re-run a previous migration or to perform a new migration based on a previous migration please double click one of the migration projects below.''') content.add(help_label, False, True) wrapper_button_box = mforms.newBox(True) wrapper_button_box.set_padding(8) button_new_migration = mforms.newButton() button_new_migration.set_text('Start New Migration') #button_new_migration.add_clicked_callback(lambda x: x) wrapper_button_box.add(button_new_migration, False, True) content.add(wrapper_button_box, False, True) project_box = mforms.newBox(False) project_box.set_spacing(8) project_label = mforms.newLabel('Project Overview') project_label.set_style(mforms.BoldStyle) project_box.add(project_label, False, True) project_tree = mforms.newTreeView(mforms.TreeDefault) project_box.add(project_tree, True, True) project_button_box = mforms.newBox(True) project_button_box.set_spacing(8) button_rerun_migration = mforms.newButton() button_rerun_migration.set_text('Re-Run Migration') button_edit_migration = mforms.newButton() button_edit_migration.set_text('Edit Migration Project') project_button_box.add(button_rerun_migration, False, True) project_button_box.add(button_edit_migration, False, True) project_box.add(project_button_box, False, True) content.add(project_box, False, True) container.add(content, False, True) # Right side layout structure right_side_box = mforms.newBox(False) right_side_image = mforms.newImageBox() right_side_image.set_image('migration_background.png') right_side_image.set_image_align(mforms.TopRight) right_side_box.add(right_side_image, False, True) container.add(right_side_box, True, True) self.add(container, True, True)
def create_ui(self): dprint_ex(4, "Enter") self.suspend_layout() self.create_basic_ui("title_connections.png", "Client Connections") if self.new_processlist(): widths = grt.root.wb.state.get("wb.admin:ConnectionListColumnWidthsPS", None) else: widths = grt.root.wb.state.get("wb.admin:ConnectionListColumnWidths", None) if widths: column_widths = [int(i) for i in widths.split(",")] else: column_widths = None self.connection_box = mforms.newBox(True) self.connection_box.set_spacing(8) self.connection_list = newTreeNodeView(mforms.TreeDefault|mforms.TreeFlatList|mforms.TreeAltRowColors) self.connection_list.set_selection_mode(mforms.TreeSelectMultiple) self.connection_list.add_column_resized_callback(self.column_resized) for i, (field, type, caption, width) in enumerate(self.columns): if column_widths and i < len(column_widths): width = column_widths[i] self.connection_list.add_column(type, caption, width, False) self.connection_list.end_columns() self.connection_list.set_allow_sorting(True) self.connection_list.add_changed_callback(weakcb(self, "connection_selected")) self.connection_box.add(self.connection_list, True, True) info_table = mforms.newTable() info_table.set_row_count(2) info_table.set_column_count(5) info_table.set_row_spacing(4) info_table.set_column_spacing(20) info_table.add(self.create_labeled_info("Threads Connected:", "lbl_Threads_connected"), 0, 1, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Running:", "lbl_Threads_running"), 1, 2, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Created:", "lbl_Threads_created"), 2, 3, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Cached:", "lbl_Threads_cached"), 3, 4, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Rejected (over limit):", "lbl_Connection_errors_max_connections"), 4, 5, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Total Connections:", "lbl_Connections"), 0, 1, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Connection Limit:", "lbl_max_connections"), 1, 2, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Aborted Clients:", "lbl_Aborted_clients"), 2, 3, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Aborted Connections:", "lbl_Aborted_connects"), 3, 4, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Errors:", "lbl_errors", "tooltip_errors"), 4, 5, 1, 2, mforms.HFillFlag) self.info_table = info_table self.add(info_table, False, True) #self.set_padding(8) self.add(self.connection_box, True, True) box = newBox(True) self.button_box = box self.add_end(box, False, True) box.set_spacing(12) refresh_button = newButton() refresh_button.set_text("Refresh") box.add_end(refresh_button, False, True) refresh_button.add_clicked_callback(weakcb(self, "refresh")) self.kill_button = newButton() self.kill_button.set_text("Kill Connection(s)") box.add_end(self.kill_button, False, True) self.kill_button.add_clicked_callback(weakcb(self, "kill_connection")) self.killq_button = newButton() self.killq_button.set_text("Kill Query(s)") box.add_end(self.killq_button, False, True) self.killq_button.add_clicked_callback(weakcb(self, "kill_query")) refresh_label = newLabel("Refresh Rate:") box.add(refresh_label, False, True) self._menu = mforms.newContextMenu() self._menu.add_will_show_callback(self.menu_will_show) self.connection_list.set_context_menu(self._menu) self.refresh_values = [0.5, 1, 2, 3, 4, 5, 10, 15, 30] self.refresh_values_size = len(self.refresh_values) self.refresh_selector = newSelector() self.refresh_selector.set_size(100,-1) for s in self.refresh_values: self.refresh_selector.add_item(str(s) + " seconds") self.refresh_selector.add_item("Don't Refresh") refresh_rate_index = grt.root.wb.options.options.get('Administrator:refresh_connections_rate_index', 9) self.refresh_selector.set_selected(refresh_rate_index) self.update_refresh_rate() self.refresh_selector.add_changed_callback(weakcb(self, "update_refresh_rate")) box.add(self.refresh_selector, False, True) self.check_box = newBox(True) self.check_box.set_spacing(12) self.hide_sleep_connections = newCheckBox() self.hide_sleep_connections.set_text('Hide sleeping connections') self.hide_sleep_connections.add_clicked_callback(self.refresh) self.hide_sleep_connections.set_tooltip('Remove connections in the Sleeping state from the connection list.') self.check_box.add(self.hide_sleep_connections, False, True) self.mdl_locks_page = None self._showing_extras = False if self.new_processlist(): self.hide_background_threads = newCheckBox() self.hide_background_threads.set_active(True) self.hide_background_threads.set_text('Hide background threads') self.hide_background_threads.set_tooltip('Remove background threads (internal server threads) from the connection list.') self.hide_background_threads.add_clicked_callback(self.refresh) self.check_box.add(self.hide_background_threads, False, True) self.truncate_info = newCheckBox() self.truncate_info.set_active(True) self.truncate_info.set_text('Don\'t load full thread info') self.truncate_info.set_tooltip('Toggle whether to load the entire query information for all connections or just the first 255 characters.\nEnabling this can have a large impact in busy servers or server executing large INSERTs.') self.truncate_info.add_clicked_callback(self.refresh) self.check_box.add(self.truncate_info, False, True) # tab with some extra info, only available if PS exists self.extra_info_tab = mforms.newTabView(mforms.TabViewSystemStandard) self.extra_info_tab.set_size(350, -1) self.extra_info_tab.add_tab_changed_callback(self.extra_tab_changed) self.connection_details_scrollarea = mforms.newScrollPanel() self.connection_details = ConnectionDetailsPanel(self) self.connection_details_scrollarea.add(self.connection_details) self.details_page = self.extra_info_tab.add_page(self.connection_details_scrollarea, "Details") self.mdl_list_box = None if self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 7, 3): self.mdl_list_box_scrollarea = mforms.newScrollPanel() self.mdl_list_box = mforms.newBox(False) self.mdl_list_box_scrollarea.add(self.mdl_list_box) self.mdl_label = mforms.newLabel('Metadata locks (MDL) protect concurrent access to\nobject metadata (not table row/data locks)') self.mdl_list_box.add(self.mdl_label, False, True) label = mforms.newLabel("\nGranted Locks (and threads waiting on them)") label.set_style(mforms.BoldStyle) self.mdl_list_box.add(label, False, True) label = mforms.newLabel("Locks this connection currently owns and\nconnections that are waiting for them.") label.set_style(mforms.SmallHelpTextStyle) self.mdl_list_box.add(label, False, True) self.mdl_list_held = mforms.newTreeNodeView(mforms.TreeAltRowColors) self.mdl_list_held.add_column(mforms.IconStringColumnType, "Object", 130, False) self.mdl_list_held.add_column(mforms.StringColumnType, "Type", 100, False) self.mdl_list_held.add_column(mforms.StringColumnType, "Duration", 100, False) self.mdl_list_held.end_columns() self.mdl_list_held.set_size(0, 100) self.mdl_list_box.add(self.mdl_list_held, True, True) label = mforms.newLabel("\nPending Locks") label.set_style(mforms.BoldStyle) self.mdl_list_box.add(label, False, True) hbox = mforms.newBox(True) hbox.set_spacing(4) self.mdl_blocked_icon = mforms.newImageBox() self.mdl_blocked_icon.set_image(mforms.App.get().get_resource_path("message_warning.png")) hbox.add(self.mdl_blocked_icon, False, True) self.mdl_waiting_label = mforms.newLabel("Locks this connection is currently waiting for.") hbox.add(self.mdl_waiting_label, True, True) self.mdl_list_box.add(hbox, False, True) self.mdl_locks_page = self.extra_info_tab.add_page(self.mdl_list_box_scrollarea, "Locks") if self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 6, 0): self.attributes_list = mforms.newTreeNodeView(mforms.TreeFlatList|mforms.TreeAltRowColors) self.attributes_list.add_column(mforms.StringColumnType, "Attribute", 150, False) self.attributes_list.add_column(mforms.StringColumnType, "Value", 200, False) self.attributes_list.end_columns() self.attributes_page = self.extra_info_tab.add_page(self.attributes_list, "Attributes") self.connection_box.add(self.extra_info_tab, False, True) self.extra_info_tab.show(False) self.show_extras = newButton() self.show_extras.set_text('Show Details') self.show_extras.add_clicked_callback(self.toggle_extras) self.check_box.add_end(self.show_extras, False, True) self.add(self.check_box, False, True) self.resume_layout() self.connection_selected() dprint_ex(4, "Leave")
def __init__(self, main): WizardPage.__init__(self, main, "Data Transfer Setup") self.main.add_wizard_page(self, "DataMigration", "Data Transfer Setup") label = mforms.newLabel( "Select options for the copy of the migrated schema tables in the target MySQL server and click [Next >] to execute." ) self.content.add(label, False, True) panel = mforms.newPanel(mforms.TitledBoxPanel) panel.set_title("Data Copy") self.content.add(panel, False, True) box = mforms.newBox(False) panel.add(box) box.set_padding(16) box.set_spacing(16) rid = mforms.RadioButton.new_id() self._copy_db = mforms.newRadioButton(rid) self._copy_db.set_text("Online copy of table data to target RDBMS") self._copy_db.add_clicked_callback(self._script_radio_option_callback) box.add(self._copy_db, False, True) # XXX TODO # box.add(mforms.newLabel(""), False, True) # self._add_script_checkbox_option(box, "dump_to_file", "Create a dump file with the data", "Dump File:", "Save As") if sys.platform == "win32": self._add_script_radiobutton_option( box, "copy_script", "Create a batch file to copy the data at another time", "Batch File:", "Save As", "You should edit this file to add the source and target server passwords before running it.", rid, ) else: self._add_script_radiobutton_option( box, "copy_script", "Create a shell script to copy the data from outside Workbench", "Shell Script File:", "Save As", "You should edit this file to add the source and target server passwords before running it.", rid, ) self._add_script_radiobutton_option( box, "bulk_copy_script", "Create a shell script to use native server dump and load abilities for fast migration", "Bulk Data Copy Script:", "Save As", "Edit the generated file and change passwords at the top of the generated script.\nRun it on the source server to create a zip package containing a data dump as well as a load script.\nCopy this to the target server, extract it, and run the import script. See the script output for further details.", rid, ) panel = mforms.newPanel(mforms.TitledBoxPanel) panel.set_title("Options") self.content.add(panel, False, True) self.options_box = mforms.newBox(False) self.options_box.set_padding(12) self.options_box.set_spacing(8) panel.add(self.options_box) self._truncate_db = mforms.newCheckBox() self._truncate_db.set_text("Truncate target tables (i.e. delete contents) before copying data") self.options_box.add(self._truncate_db, False, True) hbox = mforms.newBox(True) hbox.set_spacing(16) hbox.add(mforms.newLabel("Worker tasks"), False, True) self._worker_count = mforms.newTextEntry() self._worker_count.set_value("2") self._worker_count.set_size(30, -1) hbox.add(self._worker_count, False, True) l = mforms.newImageBox() l.set_image(mforms.App.get().get_resource_path("mini_notice.png")) l.set_tooltip( "Number of tasks to use for data transfer. Each task will open a " + "connection to both source and target RDBMSes to copy table rows.\nDefault value 2." ) hbox.add(l, False, True) self.options_box.add(hbox, False, True) self._debug_copy = mforms.newCheckBox() self._debug_copy.set_text("Enable debug output for table copy") self.options_box.add(self._debug_copy, False, True) ### self._advanced_panel = mforms.newPanel(mforms.TitledBoxPanel) self._advanced_panel.set_title("Tables to Copy") self.content.add(self._advanced_panel, True, True) box = mforms.newBox(False) box.set_padding(12) box.set_spacing(8) l = mforms.newLabel( """You can limit the number of rows to be copied for certain tables. Tables that are referenced by foreign keys from other tables cannot be limited, unless data copy from the referencing tables is also disabled. All tables are copied by default.""" ) l.set_style(mforms.SmallHelpTextStyle) box.add(l, False, True) self._tree = mforms.newTreeNodeView(mforms.TreeDefault) self._tree.add_column(mforms.IconStringColumnType, "Table", 200, False) self._tree.add_column(mforms.StringColumnType, "Limit Copy", 100, True) self._tree.add_column(mforms.StringColumnType, "Referencing Tables", 500, False) self._tree.end_columns() box.add(self._tree, True, True) self._advanced_panel.add(box) self._tree.set_cell_edited_callback(self._cell_edited) self._advbox_shown = False self._advanced_panel.show(False)
def create_ui(self): dprint_ex(4, "Enter") self.suspend_layout() self.create_basic_ui("title_connections.png", "Client Connections") if self.new_processlist(): widths = grt.root.wb.state.get("wb.admin:ConnectionListColumnWidthsPS", None) else: widths = grt.root.wb.state.get("wb.admin:ConnectionListColumnWidths", None) if widths: column_widths = [int(i) for i in widths.split(",")] else: column_widths = None self.connection_box = mforms.newBox(True) self.connection_box.set_spacing(8) self.connection_list = newTreeNodeView(mforms.TreeDefault|mforms.TreeFlatList|mforms.TreeAltRowColors) self.connection_list.set_selection_mode(mforms.TreeSelectMultiple) self.connection_list.add_column_resized_callback(self.column_resized) for i, (field, type, caption, width) in enumerate(self.columns): if column_widths and i < len(column_widths): width = column_widths[i] self.connection_list.add_column(type, caption, width, False) self.connection_list.end_columns() self.connection_list.set_allow_sorting(True) self.connection_list.add_changed_callback(weakcb(self, "connection_selected")) self.connection_box.add(self.connection_list, True, True) info_table = mforms.newTable() info_table.set_row_count(2) info_table.set_column_count(5) info_table.set_row_spacing(4) info_table.set_column_spacing(20) info_table.add(self.create_labeled_info("Threads Connected:", "lbl_Threads_connected"), 0, 1, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Running:", "lbl_Threads_running"), 1, 2, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Created:", "lbl_Threads_created"), 2, 3, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Threads Cached:", "lbl_Threads_cached"), 3, 4, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Rejected (over limit):", "lbl_Connection_errors_max_connections"), 4, 5, 0, 1, mforms.HFillFlag) info_table.add(self.create_labeled_info("Total Connections:", "lbl_Connections"), 0, 1, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Connection Limit:", "lbl_max_connections"), 1, 2, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Aborted Clients:", "lbl_Aborted_clients"), 2, 3, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Aborted Connections:", "lbl_Aborted_connects"), 3, 4, 1, 2, mforms.HFillFlag) info_table.add(self.create_labeled_info("Errors:", "lbl_errors", "tooltip_errors"), 4, 5, 1, 2, mforms.HFillFlag) self.info_table = info_table self.add(info_table, False, True) #self.set_padding(8) self.add(self.connection_box, True, True) box = newBox(True) self.button_box = box self.add_end(box, False, True) box.set_spacing(12) refresh_button = newButton() refresh_button.set_text("Refresh") box.add_end(refresh_button, False, True) refresh_button.add_clicked_callback(weakcb(self, "refresh")) self.kill_button = newButton() self.kill_button.set_text("Kill Connection(s)") box.add_end(self.kill_button, False, True) self.kill_button.add_clicked_callback(weakcb(self, "kill_connection")) self.killq_button = newButton() self.killq_button.set_text("Kill Query(s)") box.add_end(self.killq_button, False, True) self.killq_button.add_clicked_callback(weakcb(self, "kill_query")) refresh_label = newLabel("Refresh Rate:") box.add(refresh_label, False, True) self._menu = mforms.newContextMenu() self._menu.add_will_show_callback(self.menu_will_show) self.connection_list.set_context_menu(self._menu) self.refresh_values = [0.5, 1, 2, 3, 4, 5, 10, 15, 30] self.refresh_values_size = len(self.refresh_values) self.refresh_selector = newSelector() self.refresh_selector.set_size(100,-1) for s in self.refresh_values: self.refresh_selector.add_item(str(s) + " seconds") self.refresh_selector.add_item("Don't Refresh") refresh_rate_index = grt.root.wb.options.options.get('Administrator:refresh_connections_rate_index', 9) self.refresh_selector.set_selected(refresh_rate_index) self.update_refresh_rate() self.refresh_selector.add_changed_callback(weakcb(self, "update_refresh_rate")) box.add(self.refresh_selector, False, True) self.check_box = newBox(True) self.check_box.set_spacing(12) self.hide_sleep_connections = newCheckBox() self.hide_sleep_connections.set_text('Hide sleeping connections') self.hide_sleep_connections.add_clicked_callback(self.refresh) self.hide_sleep_connections.set_tooltip('Remove connections in the Sleeping state from the connection list.') self.check_box.add(self.hide_sleep_connections, False, True) self.mdl_locks_page = None self._showing_extras = False if self.new_processlist(): self.hide_background_threads = newCheckBox() self.hide_background_threads.set_active(True) self.hide_background_threads.set_text('Hide background threads') self.hide_background_threads.set_tooltip('Remove background threads (internal server threads) from the connection list.') self.hide_background_threads.add_clicked_callback(self.refresh) self.check_box.add(self.hide_background_threads, False, True) self.truncate_info = newCheckBox() self.truncate_info.set_active(True) self.truncate_info.set_text('Don\'t load full thread info') self.truncate_info.set_tooltip('Toggle whether to load the entire query information for all connections or just the first 255 characters.\nEnabling this can have a large impact in busy servers or server executing large INSERTs.') self.truncate_info.add_clicked_callback(self.refresh) self.check_box.add(self.truncate_info, False, True) # tab with some extra info, only available if PS exists self.extra_info_tab = mforms.newTabView(mforms.TabViewSystemStandard) self.extra_info_tab.set_size(350, -1) self.extra_info_tab.add_tab_changed_callback(self.extra_tab_changed) self.connection_details_scrollarea = mforms.newScrollPanel() self.connection_details = ConnectionDetailsPanel(self) self.connection_details_scrollarea.add(self.connection_details) self.details_page = self.extra_info_tab.add_page(self.connection_details_scrollarea, "Details") self.mdl_list_box = None if self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 7, 3): self.mdl_list_box_scrollarea = mforms.newScrollPanel() self.mdl_list_box = mforms.newBox(False) self.mdl_list_box_scrollarea.add(self.mdl_list_box) self.mdl_label = mforms.newLabel('Metadata locks (MDL) protect concurrent access to\nobject metadata (not table row/data locks)') self.mdl_list_box.add(self.mdl_label, False, True) label = mforms.newLabel("\nGranted Locks (and threads waiting on them)") label.set_style(mforms.BoldStyle) self.mdl_list_box.add(label, False, True) label = mforms.newLabel("Locks this connection currently owns and\nconnections that are waiting for them.") label.set_style(mforms.SmallHelpTextStyle) self.mdl_list_box.add(label, False, True) self.mdl_list_held = mforms.newTreeNodeView(mforms.TreeAltRowColors) self.mdl_list_held.add_column(mforms.IconStringColumnType, "Object", 130, False) self.mdl_list_held.add_column(mforms.StringColumnType, "Type", 100, False) self.mdl_list_held.add_column(mforms.StringColumnType, "Duration", 100, False) self.mdl_list_held.end_columns() self.mdl_list_held.set_size(0, 100) self.mdl_list_box.add(self.mdl_list_held, True, True) label = mforms.newLabel("\nPending Locks") label.set_style(mforms.BoldStyle) self.mdl_list_box.add(label, False, True) hbox = mforms.newBox(True) hbox.set_spacing(4) self.mdl_blocked_icon = mforms.newImageBox() self.mdl_blocked_icon.set_image(mforms.App.get().get_resource_path("message_warning.png")) hbox.add(self.mdl_blocked_icon, False, True) self.mdl_waiting_label = mforms.newLabel("Locks this connection is currently waiting for.") hbox.add(self.mdl_waiting_label, True, True) self.mdl_list_box.add(hbox, False, True) self.mdl_locks_page = self.extra_info_tab.add_page(self.mdl_list_box_scrollarea, "Locks") if self.ctrl_be.target_version.is_supported_mysql_version_at_least(5, 6, 0): self.attributes_list = mforms.newTreeNodeView(mforms.TreeFlatList|mforms.TreeAltRowColors) self.attributes_list.add_column(mforms.StringColumnType, "Attribute", 150, False) self.attributes_list.add_column(mforms.StringColumnType, "Value", 200, False) self.attributes_list.end_columns() self.attributes_page = self.extra_info_tab.add_page(self.attributes_list, "Attributes") self.connection_box.add(self.extra_info_tab, False, True) self.extra_info_tab.show(False) self.show_extras = newButton() self.show_extras.set_text('Show Details') self.show_extras.add_clicked_callback(self.toggle_extras) self.check_box.add_end(self.show_extras, False, True) self.add(self.check_box, False, True) self.resume_layout() self.connection_selected() dprint_ex(4, "Leave")