Exemplo n.º 1
0
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
Exemplo n.º 2
0
    def __init__(self, context, main_view):
        super(WbAdminEnterpriseBackup, self).__init__(False)
        self._ui_created = False
        self.context = context
        self.ctrl_be = context.ctrl_be
        self._main_view = main_view

        self._current_label = None

        self.set_padding(0)
        self.set_spacing(12)
        self.set_back_color("#ffffff")

        table = mforms.newTable()
        table.set_padding(12)
        table.set_row_count(5)
        table.set_column_count(2)
        table.set_row_spacing(6)
        table.set_column_spacing(4)

        self._server_info_table = table
        self._host = add_table_info_row(table, 0, "Target Host:")
        self._server_version = add_table_info_row(table, 1, "Server Version:")
        self._source_datadir = add_table_info_row(table, 2, "MySQL Data Directory:")
        self._operating_system = add_table_info_row(table, 3, "Server Operating System:")
        self._backups_home = add_table_info_row(table, 4, "Backups Home:")

        self.add(table, False, True)
    def refresh(self):
        if not self._tree:
            self._pbar = mforms.newProgressBar()
            self._pbar.set_indeterminate(True)
            self._pbar.start()
            self._pbar.set_size(400, -1)

            self._wait_table = mforms.newTable()
            self._wait_table.set_row_spacing(8)
            self._wait_table.set_row_count(2)
            self._wait_table.set_column_count(1)
            self._wait_table.set_padding(-1)
            self._wait_table.add(
                mforms.newLabel("Querying performance schema %s..." %
                                self.caption.encode("utf8")), 0, 1, 0, 1,
                mforms.HFillFlag)
            self._wait_table.add(self._pbar, 0, 1, 1, 2, mforms.HFillFlag)

            self.add(self._wait_table, True, True)

        if not self._busy:
            self._busy = True
            if self._refresh:
                self._refresh.set_enabled(False)

            self.result = None
            self._thr = Thread(target=self.run_query)
            self._check_timeout = mforms.Utilities.add_timeout(
                1.0, self.check_if_finished)
            self._thr.start()
Exemplo n.º 4
0
    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 update(self, ctrl_be):
        self.suspend_layout()
        self.connection_name.set_text(ctrl_be.server_profile.name)

        info = ctrl_be.server_variables

        if self.info_table:
            self.vbox.remove(self.info_table)

        self.info_table = mforms.newTable()
        self.info_table.set_column_count(2)
        self.info_table.set_row_count(5)
        self.info_table.set_column_spacing(18)
        self.info_table.set_row_spacing(5)
        self.vbox.add(self.info_table, True, True)

        stradd(self.info_table, 0, "\nHost:", "\n"+info.get("hostname", "n/a"))
        stradd(self.info_table, 1, "Socket:", info.get("socket", "n/a"))
        stradd(self.info_table, 2, "Port:", info.get("port", "n/a"))
        stradd(self.info_table, 3, "Version:", "%s\n%s" % (info.get("version", "n/a"), info.get("version_comment", "")))
        stradd(self.info_table, 4, "Compiled For:", "%s (%s)" % (info.get("version_compile_os", "n/a"), info.get("version_compile_machine", "n/a")))

        server_version = ctrl_be.get_server_version()
        if server_version and info:
            x, y = server_version[:2]
            icon = mforms.App.get().get_resource_path("mysql-logo-%i%i.png" % (x, y))
            if icon:
                self.icon.set_image(icon)
        self.resume_layout()
Exemplo n.º 6
0
    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 update(self, ctrl_be):
        self.suspend_layout()
        self.connection_name.set_text(ctrl_be.server_profile.name)

        info = ctrl_be.server_variables
        status = ctrl_be.status_variables

        if self.info_table:
            self.vbox.remove(self.info_table)

        self.info_table = mforms.newTable()
        self.info_table.set_column_count(2)
        self.info_table.set_row_count(8)
        self.info_table.set_column_spacing(18)
        self.info_table.set_row_spacing(5)

        stradd(self.info_table, 0, "\nHost",
               "\n" + info.get("hostname", "n/a"))
        stradd(self.info_table, 1, "Socket", info.get("socket", "n/a"))
        stradd(self.info_table, 2, "Port", info.get("port", "n/a"))
        stradd(
            self.info_table, 3, "Version", "%s (%s)" %
            (info.get("version", "n/a"), info.get("version_comment", "")))
        stradd(
            self.info_table, 4, "Compiled For",
            "%s   (%s)" % (info.get("version_compile_os", "n/a"),
                           info.get("version_compile_machine", "n/a")))

        stradd(self.info_table, 5, "Configuration File",
               ctrl_be.server_profile.config_file_path or "unknown")

        uptime = status.get("Uptime", None)
        if uptime:
            uptime = long(uptime)
            stradd(
                self.info_table, 6, "Running Since", "%s (%s)" %
                (time.ctime(ctrl_be.status_variables_time - uptime),
                 format_duration(uptime, True)))
        else:
            stradd(self.info_table, 6, "Running Since", "n/a")
        self.vbox.add(self.info_table, True, True)

        box = mforms.newBox(True)
        refresh = mforms.newButton()
        refresh.set_text("Refresh")
        refresh.set_tooltip("Refresh server status information")
        refresh.add_clicked_callback(self.owner.refresh_status)
        box.add(refresh, False, False)
        self.info_table.add(box, 1, 2, 7, 8, mforms.VFillFlag)

        version = ctrl_be.target_version
        if version and info:
            icon = mforms.App.get().get_resource_path(
                "mysql-logo-%i%i.png" %
                (version.majorNumber, version.minorNumber))
            if icon:
                self.icon.set_image(icon)
        self.resume_layout()
Exemplo n.º 8
0
    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 __init__(self, editor, schema):
        mforms.Box.__init__(self, False)
        self.set_managed()
        self.set_release_on_add()
        
        self.editor = editor
        self._schema = schema
        
        self.table = mforms.newTable()
        self.table.set_row_count(7)
        self.table.set_column_count(2)
        self.table.set_row_spacing(8)
        self.table.set_column_spacing(8)

        def make_title(t):
            l = mforms.newLabel(t)
            l.set_style(mforms.BoldStyle)
            return l

        self.panel_header_box = mforms.newBox(True)
        self.panel_header_box.set_padding(10)
        self.panel_header_box.add(make_panel_header("db.Schema.32x32.png", self.editor.connection.name, "%s" % (schema)), False, True)
        
        self.add(self.panel_header_box, False, True)

        self.table.add(make_title("Schema Details"), 0, 2, 0, 1, mforms.HFillFlag)

        self.table.add(mforms.newLabel("Default collation:"),              0, 1, 3, 4, mforms.HFillFlag)
        self.col_default_collation_name = mforms.newLabel("")
        self.col_default_collation_name.set_style(mforms.BoldStyle)
        self.table.add(self.col_default_collation_name,                    1, 2, 3, 4, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Default characterset:"),           0, 1, 4, 5, mforms.HFillFlag)
        self.col_default_character_set_name = mforms.newLabel("")
        self.col_default_character_set_name.set_style(mforms.BoldStyle)
        self.table.add(self.col_default_character_set_name,                1, 2, 4, 5, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Table count:"),                    0, 1, 5, 6, mforms.HFillFlag)
        self.table_count = mforms.newLabel("")
        self.table_count.set_style(mforms.BoldStyle)
        self.table.add(self.table_count,                                   1, 2, 5, 6, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Database size (rough estimate):"), 0, 1, 6, 7, mforms.HFillFlag)
        self.database_size = mforms.newLabel("")
        self.database_size.set_style(mforms.BoldStyle)
        self.table.add(self.database_size,                                 1, 2, 6, 7, mforms.HFillFlag|mforms.HExpandFlag)

        tbox = mforms.Box(False)
        tbox.set_spacing(15)
        tbox.set_padding(15)
        tbox.add(self.table, True, True)
        
        self.add(tbox, False, True)
Exemplo n.º 10
0
    def __init__(self, editor, schema):
        mforms.Box.__init__(self, False)
        self.set_managed()
        self.set_release_on_add()
        
        self.editor = editor
        self._schema = schema
        
        self.table = mforms.newTable()
        self.table.set_row_count(7)
        self.table.set_column_count(2)
        self.table.set_row_spacing(8)
        self.table.set_column_spacing(8)

        def make_title(t):
            l = mforms.newLabel(t)
            l.set_style(mforms.BoldStyle)
            return l

        self.panel_header_box = mforms.newBox(True)
        self.panel_header_box.set_padding(10)
        self.panel_header_box.add(make_panel_header("db.Schema.32x32.png", self.editor.connection.name, "%s" % (schema)), False, False)
        
        self.add(self.panel_header_box,False, False)

        self.table.add(make_title("Schema Details"), 0, 2, 0, 1, mforms.HFillFlag)

        self.table.add(mforms.newLabel("Default collation:"),              0, 1, 3, 4, mforms.HFillFlag)
        self.col_default_collation_name = mforms.newLabel("")
        self.col_default_collation_name.set_style(mforms.BoldStyle)
        self.table.add(self.col_default_collation_name,                    1, 2, 3, 4, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Default characterset:"),           0, 1, 4, 5, mforms.HFillFlag)
        self.col_default_character_set_name = mforms.newLabel("")
        self.col_default_character_set_name.set_style(mforms.BoldStyle)
        self.table.add(self.col_default_character_set_name,                1, 2, 4, 5, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Table count:"),                    0, 1, 5, 6, mforms.HFillFlag)
        self.table_count = mforms.newLabel("")
        self.table_count.set_style(mforms.BoldStyle)
        self.table.add(self.table_count,                                   1, 2, 5, 6, mforms.HFillFlag|mforms.HExpandFlag)
        
        self.table.add(mforms.newLabel("Database size (rough estimate):"), 0, 1, 6, 7, mforms.HFillFlag)
        self.database_size = mforms.newLabel("")
        self.database_size.set_style(mforms.BoldStyle)
        self.table.add(self.database_size,                                 1, 2, 6, 7, mforms.HFillFlag|mforms.HExpandFlag)

        tbox = mforms.Box(False)
        tbox.set_spacing(15)
        tbox.set_padding(15)
        tbox.add(self.table, True, True)
        
        self.add(tbox, False, False)
Exemplo n.º 11
0
    def __init__(self, conn):
        mforms.Form.__init__(self, None)
        self._conn = conn
        self.set_title("Password Expired")

        vbox = mforms.newBox(False)
        vbox.set_padding(12)

        box = mforms.newTable()
        box.set_row_count(4)
        box.set_column_count(2)
        box.set_column_spacing(8)
        box.set_row_spacing(12)
        vbox.add(box, True, True)

        user = conn.parameterValues["userName"]
        box.add(
            newLabel(
                "Password for MySQL account '%s' from %s is expired\nand must be changed before the account can be used.\n\nPlease pick a new password:"******"Mysql@", ""))), 0, 2, 0,
            1, 0)

        self.old_password = mforms.newTextEntry(mforms.PasswordEntry)
        box.add(newLabel("Old Password:"******"New Password:"******"Confirm:", True), 0, 1, 3, 4, mforms.HFillFlag)
        box.add(self.confirm, 1, 2, 3, 4,
                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, 240)
        self.center()
    def __init__(self):
        mforms.Box.__init__(self, False)
        self.set_managed()
        self.set_release_on_add()

        table = mforms.newTable()
        table.set_row_count(8)
        table.set_column_count(2)
        table.set_row_spacing(8)
        table.set_column_count(4)

        table.add(mforms.newLabel(""), 0, 1, 0, 1, mforms.HFillFlag)

        self.add(table, True, True)
    def update(self, ctrl_be):
        self.suspend_layout()
        self.connection_name.set_text(ctrl_be.server_profile.name)

        info = ctrl_be.server_variables
        status = ctrl_be.status_variables

        if self.info_table:
            self.vbox.remove(self.info_table)

        self.info_table = mforms.newTable()
        self.info_table.set_column_count(2)
        self.info_table.set_row_count(8)
        self.info_table.set_column_spacing(18)
        self.info_table.set_row_spacing(5)
        self.vbox.add(self.info_table, True, True)

        stradd(self.info_table, 0, "\nHost:", "\n"+info.get("hostname", "n/a"))
        stradd(self.info_table, 1, "Socket:", info.get("socket", "n/a"))
        stradd(self.info_table, 2, "Port:", info.get("port", "n/a"))
        stradd(self.info_table, 3, "Version:", "%s\n%s" % (info.get("version", "n/a"), info.get("version_comment", "")))
        stradd(self.info_table, 4, "Compiled For:", "%s   (%s)" % (info.get("version_compile_os", "n/a"), info.get("version_compile_machine", "n/a")))

        stradd(self.info_table, 5, "Configuration File:", ctrl_be.server_profile.config_file_path or "unknown")

        uptime = status.get("Uptime", None)
        if uptime:
            uptime = long(uptime)
            stradd(self.info_table, 6, "Running Since:", "%s (%s)" % (time.ctime(ctrl_be.status_variables_time-uptime), format_duration(uptime, True)))
        else:
            stradd(self.info_table, 6, "Running Since:", "n/a")

        box = mforms.newBox(True)
        refresh = mforms.newButton()
        refresh.set_text("Refresh")
        refresh.set_tooltip("Refresh server status information")
        refresh.add_clicked_callback(self.owner.refresh_status)
        box.add(refresh, False, False)
        self.info_table.add(box, 1, 2, 7, 8, 0)

        version = ctrl_be.target_version
        if version and info:
            icon = mforms.App.get().get_resource_path("mysql-logo-%i%i.png" % (version.majorNumber, version.minorNumber))
            if icon:
                self.icon.set_image(icon)
        self.resume_layout()
    def __init__(self, title, description):
        self._canceled = False
        mforms.Form.__init__(
            self, None, mforms.FormDialogFrame | mforms.FormResizable
            | mforms.FormMinimizable)
        self.set_title(title)

        content = mforms.newBox(False)
        self.set_content(content)
        content.set_padding(12)
        content.set_spacing(12)

        v_box = mforms.newBox(False)
        content.add(v_box, False, False)
        v_box.set_spacing(12)
        v_box.add(mforms.newLabel(description), False, False)

        table = mforms.newTable()
        table.set_padding(12)
        v_box.add(table, False, False)
        table.set_row_count(2)
        table.set_column_count(2)
        table.set_row_spacing(8)
        table.set_column_spacing(4)
        table.add(mforms.newLabel("Find:"), 0, 1, 0, 1)
        table.add(mforms.newLabel("Replace with:"), 0, 1, 1, 2)

        self.from_type_entry = mforms.newTextEntry()
        table.add(self.from_type_entry, 1, 2, 0, 1)

        self.to_type_entry = mforms.newTextEntry()
        table.add(self.to_type_entry, 1, 2, 1, 2)

        h_box = mforms.newBox(True)
        content.add_end(h_box, False, False)
        h_box.set_spacing(12)

        self.cancel_btn = mforms.newButton()
        self.cancel_btn.set_text("Cancel")
        h_box.add_end(self.cancel_btn, False, True)

        self.ok_btn = mforms.newButton()
        self.ok_btn.set_text("OK")
        h_box.add_end(self.ok_btn, False, True)
        self.set_size(600, 180)
Exemplo n.º 15
0
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, title, description):
        self._canceled = False
        mforms.Form.__init__(self, None, mforms.FormDialogFrame|mforms.FormResizable|mforms.FormMinimizable)
        self.set_title(title)

        content = mforms.newBox(False)
        self.set_content(content)
        content.set_padding(12)
        content.set_spacing(12)

        v_box = mforms.newBox(False)
        content.add(v_box, False, False)
        v_box.set_spacing(12)
        v_box.add(mforms.newLabel(description), False, False)

        table = mforms.newTable()
        table.set_padding(12)
        v_box.add(table, False, False)
        table.set_row_count(2)
        table.set_column_count(2)
        table.set_row_spacing(8)
        table.set_column_spacing(4)
        table.add(mforms.newLabel("Find:"), 0, 1, 0, 1)
        table.add(mforms.newLabel("Replace with:"), 0, 1, 1, 2)

        self.from_type_entry = mforms.newTextEntry()
        table.add(self.from_type_entry, 1, 2, 0, 1)

        self.to_type_entry = mforms.newTextEntry()
        table.add(self.to_type_entry, 1, 2, 1, 2)

        h_box = mforms.newBox(True)
        content.add_end(h_box, False, False)
        h_box.set_spacing(12)

        self.cancel_btn = mforms.newButton()
        self.cancel_btn.set_text("Cancel")
        h_box.add_end(self.cancel_btn, False, True)

        self.ok_btn = mforms.newButton()
        self.ok_btn.set_text("OK")
        h_box.add_end(self.ok_btn, False, True)
        self.set_size(600, 180)
Exemplo n.º 17
0
    def __init__(self, owner):
        WizardPage.__init__(self, owner, "Generate certificates and self-signed keys")

        self.ca_cert = os.path.join(self.main.results_path, "ca-cert.pem")
        self.server_cert = os.path.join(self.main.results_path, "server-cert.pem")
        self.server_key = os.path.join(self.main.results_path, "server-key.pem")
        self.client_cert = os.path.join(self.main.results_path, "client-cert.pem")
        self.client_key = os.path.join(self.main.results_path, "client-key.pem")

        self.table = mforms.newTable()
        self.table.set_padding(12)
        self.table.set_column_count(3)
        self.table.set_row_count(7)

        self.table.set_row_spacing(8)
        self.table.set_column_spacing(4)

        row, self.country_code = self.add_label_row(0, "Country:", "2 letter country code (eg, US)")
        row, self.state_name = self.add_label_row(row, "State or Province:", "Full state or province name")
        row, self.locality_name = self.add_label_row(row, "Locality:", "eg, city")
        row, self.org_name = self.add_label_row(row, "Organization:", "eg, company")
        row, self.org_unit = self.add_label_row(row, "Org. Unit:", "eg, section, department")
        row, self.email_address = self.add_label_row(row, "Email Address:", "")
        row, self.common_name = self.add_label_row(row, "Common:", "eg, put the FQDN of the server\nto allow server address validation")

        message = "Now you must specify the parameters to use in the certificates and self-signed key generation.\n"
        message += "This may include some data refering youself and/or the company you work for. All fields are optional."
        
        self.parameters_box = mforms.newBox(False)
        self.parameters_box.set_padding(20)
        self.parameters_box.set_spacing(20)

        self.parameters_label = mforms.newLabel(message)
        
        self.parameters_panel = mforms.newPanel(mforms.TitledBoxPanel)
        self.parameters_panel.set_title("Optional Parameters")
        self.parameters_panel.add(self.table)
        
        self.parameters_box.add(self.parameters_label, False, False)
        self.parameters_box.add(self.parameters_panel, False, False)

        self.default_label = mforms.newLabel("The wizard is ready to generate the files for you. Click 'Next >' to generate \nthe certificates and self-signed key files...")
Exemplo n.º 18
0
    def __init__(self, owner):
        WizardPage.__init__(self, owner, "Generate certificates and self-signed keys")

        self.ca_cert = os.path.join(self.main.results_path, "ca-cert.pem").replace('\\', '/')
        self.server_cert = os.path.join(self.main.results_path, "server-cert.pem").replace('\\', '/')
        self.server_key = os.path.join(self.main.results_path, "server-key.pem").replace('\\', '/')
        self.client_cert = os.path.join(self.main.results_path, "client-cert.pem").replace('\\', '/')
        self.client_key = os.path.join(self.main.results_path, "client-key.pem").replace('\\', '/')

        self.table = mforms.newTable()
        self.table.set_padding(12)
        self.table.set_column_count(3)
        self.table.set_row_count(7)

        self.table.set_row_spacing(8)
        self.table.set_column_spacing(4)

        row, self.country_code = self.add_label_row(0, "Country:", "2 letter country code (eg, US)")
        row, self.state_name = self.add_label_row(row, "State or Province:", "Full state or province name")
        row, self.locality_name = self.add_label_row(row, "Locality:", "eg, city")
        row, self.org_name = self.add_label_row(row, "Organization:", "eg, company")
        row, self.org_unit = self.add_label_row(row, "Org. Unit:", "eg, section, department")
        row, self.email_address = self.add_label_row(row, "Email Address:", "")
        row, self.common_name = self.add_label_row(row, "Common:", "eg, put the FQDN of the server\nto allow server address validation")

        message = "Now you must specify the parameters to use in the certificates and self-signed key generation.\n"
        message += "This may include some data refering to youself and/or the company you work for. All fields are optional."
        
        self.parameters_box = mforms.newBox(False)
        self.parameters_box.set_padding(20)
        self.parameters_box.set_spacing(20)

        self.parameters_label = mforms.newLabel(message)
        
        self.parameters_panel = mforms.newPanel(mforms.TitledBoxPanel)
        self.parameters_panel.set_title("Optional Parameters")
        self.parameters_panel.add(self.table)
        
        self.parameters_box.add(self.parameters_label, False, False)
        self.parameters_box.add(self.parameters_panel, False, False)

        self.default_label = mforms.newLabel("The wizard is ready to generate the files for you. Click 'Next >' to generate \nthe certificates and self-signed key files...")
Exemplo n.º 19
0
    def create_destination_tab(self):
        self._destination = newBox(False)
        self._destination.set_spacing(12)
        self._destination.set_padding(12)
        self._configuration.add_page(self._destination, "Options")

        table = mforms.newTable()

        table.set_row_count(7)
        table.set_column_count(2)
        table.set_row_spacing(8)
        table.set_column_spacing(4)

        add_table_field_label(table, 0, "Backup Storage Directory:")
        hbox = mforms.newBox(True)
        self._dest_directory  = newTextEntry()
        self._dest_directory.set_size(300,-1)
        hbox.add(self._dest_directory, False, False)
        self._dest_dir_button = newButton()
        self._dest_dir_button.set_text("Browse...")
        self._dest_dir_button.enable_internal_padding(False)
        self._dest_dir_button.add_clicked_callback(lambda: self.open_file_chooser(OpenDirectory, self._dest_directory))
        
        hbox.add(self._dest_dir_button, False, False)
        add_table_field_value(table, 0, hbox, mforms.HFillFlag)

        l = mforms.newLabel("Backups will be written to the specified directory in the target MySQL server.\nA new subdirectory is created for each backup, named with its timestamp.")
        l.set_style(mforms.SmallHelpTextStyle)
        add_table_field_value(table, 1, l)
        
        self._compress_backup = mforms.newCheckBox()
        self._compress_backup.set_text("Compress backup (non-incremental InnoDB backups only)")
        add_table_field_value(table, 3, self._compress_backup)
        
        self._apply_log = mforms.newCheckBox()
        self._apply_log.set_text("Apply log after backup (backup-and-apply-log)")
        add_table_field_value(table, 5, self._apply_log)
        l = mforms.newLabel("After a backup is done, an apply-log operation is needed before it can be recovered.\nThat may be done right after backup, before recovering it or at any other time.")
        l.set_style(mforms.SmallHelpTextStyle)
        add_table_field_value(table, 6, l)
        
        self._destination.add(table, False, False)
    def update(self, ctrl_be):
        self.suspend_layout()
        self.connection_name.set_text(ctrl_be.server_profile.name)

        info = ctrl_be.server_variables

        if self.info_table:
            self.vbox.remove(self.info_table)

        self.info_table = mforms.newTable()
        self.info_table.set_column_count(2)
        self.info_table.set_row_count(5)
        self.info_table.set_column_spacing(18)
        self.info_table.set_row_spacing(5)
        self.vbox.add(self.info_table, True, True)

        stradd(self.info_table, 0, "\nHost:",
               "\n" + info.get("hostname", "n/a"))
        stradd(self.info_table, 1, "Socket:", info.get("socket", "n/a"))
        stradd(self.info_table, 2, "Port:", info.get("port", "n/a"))
        stradd(
            self.info_table, 3, "Version:", "%s\n%s" %
            (info.get("version", "n/a"), info.get("version_comment", "")))
        stradd(
            self.info_table, 4, "Compiled For:",
            "%s (%s)" % (info.get("version_compile_os", "n/a"),
                         info.get("version_compile_machine", "n/a")))

        server_version = ctrl_be.get_server_version()
        if server_version and info:
            x, y = server_version[:2]
            icon = mforms.App.get().get_resource_path("mysql-logo-%i%i.png" %
                                                      (x, y))
            if icon:
                self.icon.set_image(icon)
        self.resume_layout()
Exemplo n.º 21
0
    def __init__(self, owner, context):
        mforms.Box.__init__(self, False)
        self._owner = owner
        self._context = context
        self._profile = None
        self._days   = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
        self._months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
        self._freqs =  ["Hour", "Day", "Week", "Month"]
        self._monthdays = []
        
        self.profile_saved_callback = None
        self.profile_delete_callback = None
        self.label_validation = None

        for index in range(31):
            suffix = "th"
            day = index+1
            if day in [1,21,31]:
                suffix = "st"
            elif day in [2,22]:
                suffix = "nd"
            elif day in [3,23]:
                suffix = "rd"
          
            self._monthdays.append(str(day) + suffix)
            

        table = mforms.newTable()
        table.set_padding(12)
        table.set_row_count(1)
        table.set_column_count(2)
        table.set_row_spacing(6)
        table.set_column_spacing(4)

        add_table_field_label(table, 0, "Profile Name:")
        self._name = newTextEntry()
        self._name.add_changed_callback(self.name_edited)
        self._name.set_size(200, -1)
        self._backup_type = newLabel("", True)
        hbox = newBox(True)
        hbox.set_spacing(12)
        hbox.set_padding(12)
        hbox.add(self._name, False, True)
        hbox.add(self._backup_type, False, True)
        table.add(hbox, 1, 2, 0, 1, mforms.HFillFlag)

        self.add(table, True, True)

        # Creates the configuration tabs
        self._configuration = newTabView(False)
        self.add(self._configuration, True, True)
        
        # enable back when supported self.create_contents_tab()
        self.create_destination_tab()
        self.create_schedule_tab()
        self.create_comments_tab()

        # Creates the buttons line at the bottom of the screen
        hbox = newBox(True)
        hbox.set_spacing(12)
        hbox.set_padding(12)
        self.add(hbox, False, True)

        self._cancel_button = mforms.newButton()
        self._cancel_button.set_text("Cancel")
        self._cancel_button.add_clicked_callback(self.cancel_changes)
        hbox.add_end(self._cancel_button, False, True)

        self._ok_button = mforms.newButton()
        self._ok_button.set_text("Save and Reschedule")
        self._ok_button.add_clicked_callback(self.save_changes)
        hbox.add_end(self._ok_button, False, True)

        self._del_job_button = mforms.newButton()
        self._del_job_button.set_text("Delete")
        self._del_job_button.add_clicked_callback(self.delete_clicked)
        hbox.add_end(self._del_job_button, False, True)
Exemplo n.º 22
0
    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()
Exemplo n.º 23
0
    def update_ui(self):
        if self.error_box:
            self.remove(self.error_box)
            self.error_box = None

        if self.tree:
            self.remove(self.tree)
            self.tree = None

        if self.bbox:
            self.remove(self.bbox)
            self.bbox = None

        if self.warning_box:
            self.remove(self.warning_box)
            self.warning_box = None

        self.set_padding(8)
        self.set_spacing(8)
        
        filter_box = self.create_filter_box()
        if filter_box:
            if filter_box.get_parent():
                self.remove(filter_box)
            self.add(filter_box, False, True)
        
        try:
            self.log_reader = self.BackendLogReaderClass(*self.args)
        except Exception as error:
            import traceback
            log_error("Exception creating log reader: %s\n%s\n" % (error, traceback.format_exc()))
            self._show_error("Error creating log reader: %s\n" % error)
            return

        if self.log_reader.partial_support:
            self.warning_box = newBox(True)
            self.warning_box.set_spacing(8)
            warning_label = newLabel(self.log_reader.partial_support)
            self.warning_box.add(warning_label, False, True)
            self.add(self.warning_box, False, True)

        self.tree = newTreeView(mforms.TreeFlatList)
        self.tree.set_selection_mode(mforms.TreeSelectMultiple)

        for colspec in self.log_reader.column_specs:
            self.tree.add_column(mforms.StringColumnType,
                                 colspec[0],  # column header
                                 colspec[1],  # column width
                                 False)
        self.tree.end_columns()

        self.add(self.tree, True, True)

        table = mforms.newTable()
        table.set_row_spacing(4)
        table.set_column_spacing(4)
        table.set_column_count(4)
        table.set_row_count(2)

        table.add(newLabel("Log File Location:"), 0, 1, 0, 1, mforms.HFillFlag)
        if self.log_reader.log_file:
            if self.log_reader.log_file.path == "stderr":
                self.query = """<QueryList><Query Id = "0" Path = "Application">
                                <Select Path = "Application">*[System[Provider[@Name = 'MySQL'] and TimeCreated[timediff(@SystemTime) &lt;= 604800000]]]</Select>
                                </Query></QueryList>"""
                grt.setEventlogCallback(self.printResults)
                label = newLabel("Windows Event viewer")
            else:
                label = newLabel(self.log_reader.log_file.path)
        else:
            label = newLabel("TABLE")
        label.set_style(mforms.BoldStyle)
        table.add(label, 1, 2, 0, 1, mforms.VFillFlag|mforms.HFillFlag|mforms.HExpandFlag)

        table.add(newLabel("Log File Size:"), 2, 3, 0, 1, mforms.VFillFlag|mforms.HFillFlag)
        self.size_label = newLabel("retrieving..." if self.log_reader.log_file else "-")
        self.size_label.set_style(mforms.BoldStyle)
        table.add(self.size_label, 3, 4, 0, 1, mforms.VFillFlag|mforms.HFillFlag|mforms.HExpandFlag)

        table.add(newLabel("Showing:"), 0, 1, 1, 2, mforms.VFillFlag|mforms.HFillFlag)
        self.range_label = newLabel("retrieving data...")
        self.range_label.set_style(mforms.BoldStyle)
        table.add(self.range_label, 1, 2, 1, 2, mforms.VFillFlag|mforms.HFillFlag)
        self.add(table, False, True)

        self.bbox = newBox(True)
        self.bbox.set_spacing(8)
        self.add_end(self.bbox, False, True)

        self._menu = mforms.newContextMenu()
        self._menu.add_item_with_title("Copy Row", self.copy_record, "Copy Record", "Copy Record")
        self._menu.add_item_with_title("Copy Details", self.copy_details, "Copy Details", "Copy Details")
        self.tree.set_context_menu(self._menu)

        self.bbox.add(newLabel(""), True, True)

        self.bof_button = newButton()
        self.bof_button.set_text("Oldest")
        self.bbox.add(self.bof_button, False, True)
        self.bof_button.add_clicked_callback(self.go_bof)

        self.back_button = newButton()
        self.back_button.set_text("< Previous Page")
        self.bbox.add(self.back_button, False, True)
        self.back_button.add_clicked_callback(self.go_back)

        self.next_button = newButton()
        self.next_button.set_text("Next Page >")
        self.bbox.add(self.next_button, False, True)
        self.next_button.add_clicked_callback(self.go_next)

        self.eof_button = newButton()
        self.eof_button.set_text("Most Recent")
        self.bbox.add(self.eof_button, False, True)
        self.eof_button.add_clicked_callback(self.go_eof)

        self.refresh_button = newButton()
        self.refresh_button.set_text("Refresh")
        self.bbox.add(self.refresh_button, False, True)
        self.refresh_button.add_clicked_callback(self.refresh)

        if self.log_reader.log_file and self.log_reader.log_file.path == "stderr":
            self.actual_position = 0
            grt.getEventLogEntry(0, self.query)
Exemplo n.º 24
0
    def create_preview_table(self, clean_up = False):
        
        def create_chkbox(row):
            chk =  mforms.newCheckBox()
            chk.set_active(True)
            chk.add_clicked_callback(lambda checkbox = chk, output = row: operator.setitem(output, 'active', True if checkbox.get_active() else False))
            return chk
        
        type_items = {'is_string':'text','is_bignumber':'bigint', "is_geometry":'geometry', 'is_number':'int', 'is_float':'double', 'is_bin':'binary', 'is_date_or_time': 'datetime', 'is_json':'json'}
        def create_select_type(row):
            def sel_changed(sel, output):
                selection = sel.get_string_value()
                for v in type_items:
                    if selection in type_items[v]:
                        if output['type'] == 'double' and type_items[v] != 'double':
                            self.show_ds_box(False)
                        
                        if output['type'] == 'datetime' and type_items[v] != 'datetime':
                            self.show_df_box(False)
                            
                        if type_items[v] == 'double':
                            self.show_ds_box(True)
                        if type_items[v] == 'datetime':
                            self.show_df_box(True)
                            
                        output['type'] = type_items[v]
                        
                        break  
                
            sel = mforms.newSelector()
            sel.set_size(120, -1)

            items = [type for type in type_items.values() if not ((type == "geometry" or type == "json") and self.input_file_type == "json" and not self.is_server_5_7) ]
            sel.add_items(items)
            if not self.is_server_5_7 and (row['type'] == "geometry" or row["type"] == "json") and self.input_file_type == "json":
                row['type'] = "text" # If it's server older than 5.7 we don't have support for geojson so we can't properly import this file, instead we fallback to text
                log_info("Column %s is of type GeoJso but server doesn't support this, importing as text instead." % row['name'])
                
            for i, v in enumerate(items):
                if row['type'] == v:
                    sel.set_selected(i)
                    break
            
            sel.add_changed_callback(lambda: sel_changed(sel, row))
            return sel
        
        if self.preview_table is not None:
            self.column_scroll.remove()
            self.table_preview_box.set_spacing(16)
            if self.treeview_preview is not None:
                self.table_preview_box.remove(self.treeview_preview)
                self.treeview_preview = None
            self.preview_table = None
            self.dest_column_table_col = []
            self.field_type_table_col = []
            
        def create_select_dest_col(row, cols):
            sel = mforms.newSelector()
            sel.set_size(120, -1)
            sel.add_items(cols)
            for i, c in enumerate(cols):
                if c == row['dest_col']:
                    sel.set_selected(cols.index(c))
                    break
            sel.add_changed_callback(lambda output = row: operator.setitem(output, 'dest_col', sel.get_string_value()))
            return sel

        self.preview_table = mforms.newTable()
        self.preview_table.suspend_layout()
        self.column_scroll.add(self.preview_table)

        self.preview_table.set_column_count(5)
        self.preview_table.set_row_count(len(self.active_module._columns) + 1)
        self.preview_table.set_row_spacing(8)
        self.preview_table.set_column_spacing(8)
        
        if len(self.active_module._columns) >= 3:
            self.column_caption.set_size(-1, 200)
        else:
            self.column_caption.set_size(-1, 100)
        
        self.checkbox_list = []

        def sell_all(cols, active):
            for checkbox in self.checkbox_list:
                checkbox.set_active(bool(active))
            for row in self.column_mapping:
                row['active'] = active
        
        def find_column(col_name, index):
            if col_name in self.dest_cols:
                return col_name
            else:
                return self.dest_cols[index] if i < len(self.dest_cols) else None
        
        chk = mforms.newCheckBox()
        chk.set_active(True)
        chk.add_clicked_callback(lambda checkbox = chk, columns = self.active_module._columns: sell_all(columns, checkbox.get_active()))
        
        self.preview_table.add(chk, 0, 1, 0, 1, mforms.HFillFlag)
        self.preview_table.add(mforms.newLabel("Source Column"), 1, 2, 0, 1, mforms.HFillFlag)
        if not self.main.destination_page.new_table_radio.get_active():
            self.preview_table.add(mforms.newLabel("Dest Column"), 2, 3, 0, 1, mforms.HFillFlag)
        else:
            self.preview_table.add(mforms.newLabel("Field Type"), 3, 4, 0, 1, mforms.HFillFlag)
        self.column_mapping = []
        for i, col in enumerate(self.active_module._columns):
            row = {'active': True, 'name': col['name'], 'type' : None, 'col_no': i, 'dest_col': find_column(col['name'], i)}
            for c in col:
                if c.startswith('is_') and col[c]:
                    row['type'] = type_items[c]
                    break
            chk_box = create_chkbox(row)
            self.checkbox_list.append(chk_box)
            self.preview_table.add(chk_box, 0, 1, i+1, i+2, mforms.HFillFlag)
            self.preview_table.add(mforms.newLabel(str(col['name'].encode('utf8'))), 1, 2, i+1, i+2, mforms.HFillFlag)
            if not self.main.destination_page.new_table_radio.get_active():
                self.preview_table.add(create_select_dest_col(row, self.dest_cols), 2, 3, i+1, i+2, mforms.HFillFlag)
            else:
                self.preview_table.add(create_select_type(row), 3, 4, i+1, i+2, mforms.HFillFlag)
            self.column_mapping.append(row)
            
        self.treeview_preview = newTreeView(mforms.TreeFlatList)
        for i, col in enumerate(self.active_module._columns):
            self.treeview_preview.add_column(mforms.StringColumnType, str(col['name'].encode('utf8')), 75, True)
        self.treeview_preview.end_columns()
        
        
        if len(self.active_module._columns):
            col_values = []
            val_len = 0
            for col in self.active_module._columns:
                val_len = len(col['value']) if len(col['value']) > val_len else val_len

            col_len = len(self.active_module._columns)
            for i in range(0, val_len):
                row = []
                for j in range(0, col_len):
                    
                    if len(self.active_module._columns[j]['value']) > i:
                        row.append(self.active_module._columns[j]['value'][i])
                    else:
                        row.append("")
                col_values.append(row)

            for row in col_values:
                node = self.treeview_preview.add_node()
                for i, col in enumerate(row):
                    if hasattr(col, 'encode'):
                        node.set_string(i, str(col.encode('utf8')))
                    else:
                        node.set_string(i, str(col))

        self.treeview_preview.set_allow_sorting(True)
        self.treeview_preview.set_size(200, 100)
        self.table_preview_box.add(self.treeview_preview, False, True)
        self.preview_table.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_panel.set_resize_mode(mforms.ResizeVertical)
            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(
                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(
                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:
                filter_container = mforms.newTable()
                filter_container.set_row_count(2)
                filter_container.set_column_count(3)
                filter_container.set_row_spacing(8)
                filter_container.set_column_spacing(8)

                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))
                filter_container.add(search_entry, 0, 1, 0, 1)

                available_list = mforms.newTreeNodeView(mforms.TreeFlatList)
                available_list.add_column(mforms.IconColumnType,
                                          'Available Objects', 100, False)
                available_list.end_columns()
                available_list.set_selection_mode(mforms.TreeSelectMultiple)
                available_list.set_allow_sorting(False)
                filter_container.add(available_list, 0, 1, 1, 2)

                control_box = mforms.newBox(False)
                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, 1, 2, 1, 2,
                                     mforms.VExpandFlag)

                selected_list = mforms.newTreeNodeView(mforms.TreeFlatList)
                selected_list.set_size(-1, 200)
                selected_list.add_column(mforms.IconColumnType,
                                         'Objects to Migrate', 100, 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, 2, 3, 1, 2)

                group_box.add(filter_container, True, True)

                filter_container.show(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_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, editor):
        mforms.Box.__init__(self, False)
        self.set_managed()
        self.set_release_on_add()

        self.set_padding(12)
        self.set_spacing(12)

        self.editor = editor

        # Upper Row
        table = mforms.newTable()
        table.set_row_count(2)
        table.set_column_count(2)
        table.set_row_spacing(4)
        table.set_column_spacing(8)
        self.add(table, False, True)

        def make_title(t):
            l = mforms.newLabel(t)
            l.set_style(mforms.BoldStyle)
            return l

        table.add(make_title("Indexes in Table"), 0, 1, 0, 1, mforms.HFillFlag)
        self.index_list = mforms.newTreeNodeView(mforms.TreeFlatList)
        self.index_list.add_column(mforms.IconStringColumnType, "Key", 140, False)
        self.index_list.add_column(mforms.StringColumnType, "Type", 80, False)
        self.index_list.add_column(mforms.StringColumnType, "Unique", 40, False)
        self.index_list.add_column(mforms.StringColumnType, "Columns", 200, False)
        self.index_list.end_columns()
        self.index_list.add_changed_callback(self.index_selected)
        self.index_list.set_size(400, -1)
        table.add(self.index_list, 0, 1, 1, 2, mforms.HFillFlag|mforms.VFillFlag)

        table.add(make_title("Index Details"), 1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag)
        self.info = mforms.newTable()
        table.add(self.info, 1, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag|mforms.VFillFlag)

        self.info.set_padding(8)
        self.info.set_row_count(9)
        self.info.set_column_count(2)
        self.info.set_row_spacing(4)
        self.info.set_column_spacing(4)

        self.info.add(mforms.newLabel("Key Name:"),        0, 1, 0, 1, mforms.HFillFlag)
        self.key_name = mforms.newLabel("")
        self.key_name.set_style(mforms.BoldStyle)
        self.info.add(self.key_name,                       1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Unique:"),           0, 1, 1, 2, mforms.HFillFlag)
        self.unique_values = mforms.newLabel("")
        self.unique_values.set_style(mforms.BoldStyle)
        self.info.add(self.unique_values,                  1, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Index Type:"),      0, 1, 2, 3, mforms.HFillFlag)
        self.index_type = mforms.newLabel("")
        self.index_type.set_style(mforms.BoldStyle)
        self.info.add(self.index_type,                     1, 2, 2, 3, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Packed:"),          0, 1, 3, 4, mforms.HFillFlag)
        self.packed = mforms.newLabel("")
        self.packed.set_style(mforms.BoldStyle)
        self.info.add(self.packed,                         1, 2, 3, 4, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Allows NULL:"),     0, 1, 4, 5, mforms.HFillFlag)
        self.allows_null = mforms.newLabel("")
        self.allows_null.set_style(mforms.BoldStyle)
        self.info.add(self.allows_null,                    1, 2, 4, 5, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Comment:"),         0, 1, 5, 6, mforms.HFillFlag)
        self.comment = mforms.newLabel("")
        self.comment.set_style(mforms.BoldStyle)
        self.info.add(self.comment,                        1, 2, 5, 6, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("User Comment:"),    0, 1, 6, 7, mforms.HFillFlag)
        self.user_comment = mforms.newLabel("")
        self.user_comment.set_style(mforms.BoldStyle)
        self.info.add(self.user_comment,                   1, 2, 6, 7, mforms.HFillFlag|mforms.HExpandFlag)
        self.info.add(mforms.newLabel("Cardinality:"),     0, 1, 7, 8, mforms.HFillFlag)
        self.cardinality = mforms.newLabel("")
        self.cardinality.set_style(mforms.BoldStyle)
        self.info.add(self.cardinality,                    1, 2, 7, 8, mforms.HFillFlag|mforms.HExpandFlag)
        self.index_columns = mforms.newTreeNodeView(mforms.TreeFlatList)
        self.index_columns.add_column(mforms.StringColumnType, "Column", 150, False)
        self.index_columns.add_column(mforms.StringColumnType, "Sub part", 50, False)
        self.index_columns.add_column(mforms.StringColumnType, "Collation", 100, False)
        self.index_columns.end_columns()
        self.index_columns.set_size(-1, 70)
        self.info.add(self.index_columns,                  0, 2, 8, 9, mforms.HFillFlag|mforms.HExpandFlag|mforms.VFillFlag)

        # Lower Row
        table = mforms.newTable()
        table.set_row_count(2)
        table.set_column_count(2)
        table.set_row_spacing(4)
        table.set_column_spacing(8)
        self.add(table, True, True)

        table.add(make_title("Table Columns"), 0, 1, 0, 1, mforms.HFillFlag|mforms.HExpandFlag)

        self.drop_index = mforms.newButton()
        self.drop_index.set_text("Drop Index")
        self.drop_index.set_enabled(False)
        self.drop_index.add_clicked_callback(self.do_drop_index)
        table.add(self.drop_index, 1, 2, 0, 1, mforms.HFillFlag)

        self.column_list = mforms.newTreeNodeView(mforms.TreeFlatList)
        self.column_list.add_column(mforms.IconStringColumnType, "Column", 150, False)
        self.column_list.add_column(mforms.StringColumnType, "Type", 150, False)
        self.column_list.add_column(mforms.StringColumnType, "Nullable", 50, False)
        self.column_list.add_column(mforms.StringColumnType, "Indexes", 300, False)
        self.column_list.end_columns()
        self.column_list.set_selection_mode(mforms.TreeSelectMultiple)
        table.add(self.column_list, 0, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag|mforms.VFillFlag|mforms.VExpandFlag)

        hbox = mforms.newBox(True)
        self.create_index = mforms.newButton()
        self.create_index.set_text("Create Index for Selected Columns...")
        self.create_index.add_clicked_callback(self.do_create_index)
        hbox.add_end(self.create_index, False, True)
        self.add(hbox, False, True)
 def make_info_table(self, info, params):
     info_table = mforms.newTable()
     info_table.set_column_spacing(8)
     info_table.set_row_spacing(6)
     info_table.set_column_count(2)
     return self.setup_info_table(info_table, info, params)
    def __init__(self, owner, editor, schema, table, columns):
        mforms.Form.__init__(self, mforms.Form.main_form(), mforms.FormNormal)

        self._owner = owner
        self._editor = editor
        self._schema = schema
        self._table = table
        self._columns = columns

        self.set_title("Create Index for Table %s.%s" % (schema, table))

        content = mforms.newBox(False)
        self.set_content(content)
        content.set_padding(20)
        content.set_spacing(12)

        table = mforms.newTable()
        table.set_row_count(7)
        table.set_column_count(2)
        table.set_row_spacing(8)
        table.set_column_spacing(8)
        content.add(table, False, True)

        table.add(mforms.newLabel("Index Name:", True), 0, 1, 0, 1, mforms.HFillFlag)
        hbox = mforms.newBox(True)
        hbox.set_spacing(12)
        self.name = mforms.newTextEntry()
        hbox.add(self.name, True, True)
        self.kind = mforms.newSelector()
        self.kind.add_items(["Non-Unique", "Unique", "FullText", "Spatial"])
        hbox.add(self.kind, False, True)
        table.add(hbox, 1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag)

        table.add(mforms.newLabel("Type:", True), 0, 1, 1, 2, mforms.HFillFlag)
        self.type = mforms.newSelector()
        self.type.add_items(["BTREE", "HASH"])
        table.add(self.type, 1, 2, 1, 2, mforms.HFillFlag)

        l = mforms.newLabel("Columns:")
        l.set_text_align(mforms.TopRight)
        table.add(l, 0, 1, 2, 3, mforms.HFillFlag|mforms.VFillFlag)
        self.columns = mforms.newTreeNodeView(mforms.TreeFlatList)
        self.columns.add_column(mforms.StringColumnType, "Column", 200, False)
        self.columns.add_column(mforms.StringColumnType, "Length", 60, True)
        #        self.columns.add_column(mforms.CheckColumnType, "Order", 50, False) # ignored by server
        self.columns.end_columns()
        self.columns.set_size(-1, 80)
        tbl = mforms.newTable()
        tbl.set_row_count(3)
        tbl.set_column_count(2)
        tbl.set_row_spacing(2)
        tbl.set_column_spacing(4)
        tbl.add(self.columns, 0, 1, 0, 3, mforms.HFillFlag|mforms.VFillFlag|mforms.HExpandFlag)
        self.move_up = mforms.newButton()
        self.move_up.set_text("\xe2\x96\xb2")
        self.move_up.add_clicked_callback(self.move_row_up)
        self.move_up.enable_internal_padding(False)
        self.move_down = mforms.newButton()
        self.move_down.set_text("\xe2\x96\xbc")
        self.move_down.add_clicked_callback(self.move_row_down)
        self.move_down.enable_internal_padding(False)
        tbl.add(self.move_up, 1, 2, 0, 1, mforms.HFillFlag)
        tbl.add(self.move_down, 1, 2, 1, 2, mforms.HFillFlag)
        tbl.add(mforms.newLabel(""), 1, 2, 2, 3, mforms.HFillFlag|mforms.VExpandFlag)
        table.add(tbl, 1, 2, 2, 3, mforms.HFillFlag)

        l = mforms.newLabel("Comments:")
        l.set_text_align(mforms.TopRight)
        table.add(l, 0, 1, 3, 4, mforms.HFillFlag|mforms.VFillFlag)
        self.comments = mforms.newTextBox(0)
        self.comments.set_size(-1, 60)
        if self._editor.serverVersion.majorNumber > 5 or (self._editor.serverVersion.majorNumber == 5 and self._editor.serverVersion.minorNumber >= 5):
            pass
        else:
            self.comments.set_enabled(False)
        table.add(self.comments, 1, 2, 3, 4, mforms.HFillFlag|mforms.VFillFlag)

        online_ddl_ok = self._editor.serverVersion.majorNumber > 5 or (self._editor.serverVersion.majorNumber == 5 and self._editor.serverVersion.minorNumber >= 6)

        if online_ddl_ok:
            l = mforms.newLabel("\nCreate/Online Options")
        else:
            l = mforms.newLabel("\nCreate/Online Options (requires MySQL 5.6+)")
            l.set_enabled(False)
        l.set_style(mforms.BoldStyle)
        table.add(l, 1, 2, 4, 5, mforms.HFillFlag)
        table.add(mforms.newLabel("Algorithm:", True), 0, 1, 5, 6, mforms.HFillFlag)
        self.algorithm = mforms.newSelector()
        self.algorithm.add_items(["Default", "Copy", "InPlace"])
        self.algorithm.set_enabled(online_ddl_ok)
        table.add(self.algorithm, 1, 2, 5, 6, mforms.HFillFlag)

        table.add(mforms.newLabel("Locking:", True), 0, 1, 6, 7, mforms.HFillFlag)
        self.lock = mforms.newSelector()
        self.lock.add_items(["Default (allow as much concurrency as possible)", "Exclusive (totally block access to table)", "Shared (allow queries but not DML)", "None (allow queries and DML)"])
        self.lock.set_enabled(online_ddl_ok)
        table.add(self.lock, 1, 2, 6, 7, mforms.HFillFlag)

        bbox = mforms.newBox(True)
        bbox.set_spacing(12)
        self.ok = mforms.newButton()
        self.ok.set_text("Create")

        self.cancel = mforms.newButton()
        self.cancel.set_text("Cancel")

        mforms.Utilities.add_end_ok_cancel_buttons(bbox, self.ok, self.cancel)
        content.add_end(bbox, False, True)

        self.set_size(550, -1)
        self.center()
Exemplo n.º 30
0
    def create_preview_table(self, clean_up=False):
        def create_chkbox(row):
            chk = mforms.newCheckBox()
            chk.set_active(True)
            chk.add_clicked_callback(
                lambda checkbox=chk, output=row: operator.setitem(
                    output, 'active', True
                    if checkbox.get_active() else False))
            return chk

        type_items = {
            'is_string': 'text',
            'is_number': 'int',
            'is_float': 'double',
            'is_bin': 'binary',
            'is_date_or_time': 'datetime'
        }

        def create_select_type(row):
            def sel_changed(sel, output):
                selection = sel.get_string_value()
                for v in type_items:
                    if selection in type_items[v]:
                        if output['type'] == 'double' and type_items[
                                v] != 'double':
                            self.show_ds_box(False)

                        if output['type'] == 'datetime' and type_items[
                                v] != 'datetime':
                            self.show_df_box(False)

                        if type_items[v] == 'double':
                            self.show_ds_box(True)
                        if type_items[v] == 'datetime':
                            self.show_df_box(True)

                        output['type'] = type_items[v]

                        break

            sel = mforms.newSelector()
            sel.set_size(120, -1)

            sel.add_items(type_items.values())
            for i, v in enumerate(type_items.values()):
                if row['type'] in v:
                    sel.set_selected(i)
                    break

            sel.add_changed_callback(lambda: sel_changed(sel, row))
            return sel

        if self.preview_table is not None:
            self.column_scroll.remove()
            self.table_preview_box.set_spacing(16)
            if self.treeview_preview is not None:
                self.table_preview_box.remove(self.treeview_preview)
                self.treeview_preview = None
            self.preview_table = None
            self.dest_column_table_col = []
            self.field_type_table_col = []

        def create_select_dest_col(row, cols):
            sel = mforms.newSelector()
            sel.set_size(120, -1)
            sel.add_items(cols)
            for i, c in enumerate(cols):
                if c == row['dest_col']:
                    sel.set_selected(i)
                    break
            sel.add_changed_callback(lambda output=row: operator.setitem(
                output, 'dest_col', sel.get_string_value()))
            return sel

        self.preview_table = mforms.newTable()
        self.preview_table.suspend_layout()
        self.column_scroll.add(self.preview_table)

        self.preview_table.set_column_count(5)
        self.preview_table.set_row_count(len(self.active_module._columns) + 1)
        self.preview_table.set_row_spacing(8)
        self.preview_table.set_column_spacing(8)

        if len(self.active_module._columns) >= 3:
            self.column_caption.set_size(-1, 200)
        else:
            self.column_caption.set_size(-1, 100)

        self.checkbox_list = []

        def sell_all(cols, active):
            for checkbox in self.checkbox_list:
                checkbox.set_active(active)
            for row in self.column_mapping:
                row['active'] = active

        chk = mforms.newCheckBox()
        chk.set_active(True)
        chk.add_clicked_callback(
            lambda checkbox=chk, columns=self.active_module._columns: sell_all(
                columns, checkbox.get_active()))

        self.preview_table.add(chk, 0, 1, 0, 1, mforms.HFillFlag)
        self.preview_table.add(mforms.newLabel("Source Column"), 1, 2, 0, 1,
                               mforms.HFillFlag)
        if not self.main.destination_page.new_table_radio.get_active():
            self.preview_table.add(mforms.newLabel("Dest Column"), 2, 3, 0, 1,
                                   mforms.HFillFlag)
        else:
            self.preview_table.add(mforms.newLabel("Field Type"), 3, 4, 0, 1,
                                   mforms.HFillFlag)
        self.column_mapping = []
        for i, col in enumerate(self.active_module._columns):
            row = {
                'active': True,
                'name': col['name'],
                'type': None,
                'col_no': i,
                'dest_col':
                self.dest_cols[i] if i < len(self.dest_cols) else None
            }
            for c in col:
                if c.startswith('is_') and col[c]:
                    row['type'] = type_items[c]
                    break
            chk_box = create_chkbox(row)
            self.checkbox_list.append(chk_box)
            self.preview_table.add(chk_box, 0, 1, i + 1, i + 2,
                                   mforms.HFillFlag)
            self.preview_table.add(mforms.newLabel(str(col['name'])), 1, 2,
                                   i + 1, i + 2, mforms.HFillFlag)
            if not self.main.destination_page.new_table_radio.get_active():
                self.preview_table.add(
                    create_select_dest_col(row, self.dest_cols), 2, 3, i + 1,
                    i + 2, mforms.HFillFlag)
            else:
                self.preview_table.add(create_select_type(row), 3, 4, i + 1,
                                       i + 2, mforms.HFillFlag)
            self.column_mapping.append(row)

        self.treeview_preview = newTreeNodeView(mforms.TreeFlatList)
        for i, col in enumerate(self.active_module._columns):
            self.treeview_preview.add_column(mforms.StringColumnType,
                                             str(col['name']), 75, True)
        self.treeview_preview.end_columns()

        if len(self.active_module._columns):
            col_values = []
            val_len = 0
            for col in self.active_module._columns:
                val_len = len(
                    col['value']) if len(col['value']) > val_len else val_len

            col_len = len(self.active_module._columns)
            for i in range(0, val_len):
                row = []
                for j in range(0, col_len):

                    if len(self.active_module._columns[j]['value']) > i:
                        row.append(self.active_module._columns[j]['value'][i])
                    else:
                        row.append("")
                col_values.append(row)

            for row in col_values:
                node = self.treeview_preview.add_node()
                for i, col in enumerate(row):
                    node.set_string(i, str(col))

        self.treeview_preview.set_allow_sorting(True)
        self.treeview_preview.set_size(200, 100)
        self.table_preview_box.add(self.treeview_preview, False, True)
        self.preview_table.resume_layout()
Exemplo n.º 31
0
    def create_page(self, page_number):
      self.loading = True
      if page_number < 0 or page_number == 0:
        self.loading = False
        return

      if page_number not in self.pages:
        print "Unknown page number ", page_number
        self.loading = False
        return

      # page is a stored page data stored in self.pages in create_ui
      page = self.pages[page_number]
      if page.created == True:
        self.loading = False
        return

      page_content = page.page_content

      box = newBox(False)
      box.set_spacing(8)
      box.suspend_layout()

      # Actual option values from config file parsed by cfg_be, in form of list of tuples (<name>, <value>)
      options = self.cfg_be.get_options(self.section_ctrl.get_string_value())
      opts_map = dict(options)

      for group in page_content['groups']:
        controls = group['controls']

        number_of_controls = len(controls)

        if number_of_controls == 0:
          continue

        table = newTable()
        table.set_row_spacing(10)
        table.set_column_spacing(20)
        table.set_padding(5)
        table.suspend_layout()
        table.set_homogeneous(False)

        panel = newPanel(TitledBoxPanel)
        panel.add(table)
        panel.set_title(group['caption'])
        box.add(panel, False, True)

        table.set_row_count(number_of_controls)
        table.set_column_count(3)

        table_row = -1 # Counter to address table rows, as we may skip some control_idx.

        for control_idx in range(0, number_of_controls):
          ctrl_def = controls[control_idx]

          table_row += 1

          name = ctrl_def['name']
          # Handle aliases like server_id == server-id. We have only one form in 
          # opts.opts, and that form comes from documentaion team's xml file.
          # However if user config file contains alias, we substitute the alias 
          # instead of official option name to use for this WBA session. From now
          # on all operation with the option are done through alias.
          names = self.cfg_be.option_alt_names(name) #(name, name.replace("-","_"), name.replace("_","-"))
          right_name = filter(lambda x: x in opts_map, names)
          if len(right_name) > 0:
            right_name = right_name[0]
            caption = ctrl_def.get('caption')
            if caption and name in caption:
              ctrl_def['caption'] = caption.replace(name, right_name)
            name = right_name
            ctrl_def['name'] = name

          ctrl_tupple = self.place_control(ctrl_def, table, table_row)

          label = newLabel(ctrl_def['description'])
          label.set_size(500, -1)
          label.set_wrap_text(True)
          label.set_style(SmallHelpTextStyle)
          table.add(label, 2, 3, table_row, table_row + 1, HFillFlag | VFillFlag)

          ctrl     = ctrl_tupple[1]
          ctrl_def = ctrl_tupple[2]

          #load default value into control
          if ctrl is not None and ctrl_def is not None:
            ctrl[0].set_active(False)
            self.enabled_checkbox_click(name, False)
            if ctrl_def.has_key('default'):
              default = ctrl_def['default']
              if default is not None:
                self.set_string_value_to_control(ctrl_tupple, str(default))
            else:
              self.set_string_value_to_control(ctrl_tupple, "")

          #load control with values from config
          if name in opts_map:
            value = opts_map[name]
            self.enabled_checkbox_click(name, True)
            self.set_string_value_to_control(ctrl_tupple, value)

        # Remove empty rows
        table.set_row_count(table_row+1)#number_of_controls - (number_of_controls - table_row))
        table.resume_layout()

      page.panel.add(box)
      page.created = True
      box.resume_layout()
      self.loading = False
Exemplo n.º 32
0
    def create_page(self, page_number):
        self.loading = True
        if page_number < 0 or page_number == 0:
            self.loading = False
            return

        if page_number not in self.pages:
            print "Unknown page number ", page_number
            self.loading = False
            return

        # page is a stored page data stored in self.pages in create_ui
        page = self.pages[page_number]
        if page.created == True:
            self.loading = False
            return

        page_content = page.page_content

        box = newBox(False)
        box.set_spacing(8)
        box.suspend_layout()

        # Actual option values from config file parsed by cfg_be, in form of list of tuples (<name>, <value>)
        options = self.cfg_be.get_options(self.section_ctrl.get_string_value())
        opts_map = dict(options)

        for group in page_content['groups']:
            controls = group['controls']

            number_of_controls = len(controls)

            if number_of_controls == 0:
                continue

            table = newTable()
            table.set_row_spacing(10)
            table.set_column_spacing(20)
            table.set_padding(5)
            table.suspend_layout()
            table.set_homogeneous(False)

            panel = newPanel(TitledBoxPanel)
            panel.add(table)
            panel.set_title(group['caption'])
            box.add(panel, False, True)

            table.set_row_count(number_of_controls)
            table.set_column_count(3)

            table_row = -1  # Counter to address table rows, as we may skip some control_idx.

            for control_idx in range(0, number_of_controls):
                ctrl_def = controls[control_idx]

                table_row += 1

                name = ctrl_def['name']
                # Handle aliases like server_id == server-id. We have only one form in
                # opts.opts, and that form comes from documentaion team's xml file.
                # However if user config file contains alias, we substitute the alias
                # instead of official option name to use for this WBA session. From now
                # on all operation with the option are done through alias.
                names = self.cfg_be.option_alt_names(
                    name
                )  #(name, name.replace("-","_"), name.replace("_","-"))
                right_name = filter(lambda x: x in opts_map, names)
                if len(right_name) > 0:
                    right_name = right_name[0]
                    caption = ctrl_def.get('caption')
                    if caption and name in caption:
                        ctrl_def['caption'] = caption.replace(name, right_name)
                    name = right_name
                    ctrl_def['name'] = name

                ctrl_tupple = self.place_control(ctrl_def, table, table_row)

                label = newLabel(ctrl_def['description'])
                label.set_size(500, -1)
                label.set_wrap_text(True)
                label.set_style(SmallHelpTextStyle)
                table.add(label, 2, 3, table_row, table_row + 1,
                          HFillFlag | VFillFlag)

                ctrl = ctrl_tupple[1]
                ctrl_def = ctrl_tupple[2]

                #load default value into control
                if ctrl is not None and ctrl_def is not None:
                    ctrl[0].set_active(False)
                    self.enabled_checkbox_click(name, False)
                    if ctrl_def.has_key('default'):
                        default = ctrl_def['default']
                        if default is not None:
                            self.set_string_value_to_control(
                                ctrl_tupple, str(default))
                    else:
                        self.set_string_value_to_control(ctrl_tupple, "")

                #load control with values from config
                if name in opts_map:
                    value = opts_map[name]
                    self.enabled_checkbox_click(name, True)
                    self.set_string_value_to_control(ctrl_tupple, value)

            # Remove empty rows
            table.set_row_count(
                table_row +
                1)  #number_of_controls - (number_of_controls - table_row))
            table.resume_layout()

        page.panel.add(box)
        page.created = True
        box.resume_layout()
        self.loading = False
    def __init__(self):
        mforms.Form.__init__(
            self, None, mforms.FormDialogFrame | mforms.FormResizable
            | mforms.FormMinimizable)

        self.set_title("Data Type Mapping for Generic Migration")

        content = mforms.newBox(False)
        self.set_content(content)
        content.set_padding(12)
        content.set_spacing(12)

        hbox = mforms.newBox(True)
        content.add(hbox, True, True)
        hbox.set_spacing(12)

        self._type_list = mforms.newTreeView(
            mforms.TreeFlatList)  #|mforms.TreeAllowReorderRows)
        self._type_list.set_size(200, -1)
        self._type_list.add_column(mforms.StringColumnType, "Type", 100, False)
        self._type_list.add_column(mforms.StringColumnType, "Target Type", 100,
                                   False)
        self._type_list.end_columns()
        self._type_list.add_changed_callback(self.selection_changed)
        hbox.add(self._type_list, False, True)

        detail_box = mforms.newBox(False)
        self.detail_box = detail_box
        hbox.add(detail_box, True, True)
        detail_box.set_spacing(12)

        ##

        spanel = mforms.newPanel(mforms.TitledBoxPanel)
        spanel.set_title("Source Data Type")

        stable = mforms.newTable()
        stable.set_padding(12)
        spanel.add(stable)
        stable.set_row_count(5)
        stable.set_column_count(2)
        stable.set_row_spacing(8)
        stable.set_column_spacing(4)

        stable.add(mforms.newLabel("Type Name:", True), 0, 1, 0, 1,
                   mforms.HFillFlag)
        self._stype_entry = mforms.newTextEntry()
        self._stype_entry.add_changed_callback(self.save_changes)
        stable.add(self._stype_entry, 1, 2, 0, 1,
                   mforms.HFillFlag | mforms.HExpandFlag)

        #self._stype_user_check = mforms.newCheckBox()
        #self._stype_user_check.set_text("Is user datatype")
        #stable.add(self._stype_user_check, 1, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag)

        stable.add(mforms.newLabel("Type Category:", True), 0, 1, 2, 3,
                   mforms.HFillFlag)
        self._sgroup_selector = mforms.newSelector()
        stable.add(self._sgroup_selector, 1, 2, 2, 3,
                   mforms.HFillFlag | mforms.HExpandFlag)
        self._sgroup_selector.add_changed_callback(self.source_group_selected)

        stable.add(mforms.newLabel("Min. Length:", True), 0, 1, 3, 4,
                   mforms.HFillFlag)
        self._sminlen_entry = mforms.newTextEntry()
        self._sminlen_entry.add_changed_callback(self.save_changes)
        stable.add(self._sminlen_entry, 1, 2, 3, 4,
                   mforms.HFillFlag | mforms.HExpandFlag)
        stable.add(mforms.newLabel("Max. Length:", True), 0, 1, 4, 5,
                   mforms.HFillFlag)
        self._smaxlen_entry = mforms.newTextEntry()
        self._smaxlen_entry.add_changed_callback(self.save_changes)
        stable.add(self._smaxlen_entry, 1, 2, 4, 5,
                   mforms.HFillFlag | mforms.HExpandFlag)

        detail_box.add(spanel, False, True)

        ##

        tpanel = mforms.newPanel(mforms.TitledBoxPanel)
        tpanel.set_title("Target MySQL Data Type")

        ttable = mforms.newTable()
        ttable.set_padding(12)
        tpanel.add(ttable)
        ttable.set_row_count(4)
        ttable.set_column_count(2)
        ttable.set_row_spacing(8)
        ttable.set_column_spacing(4)

        ttable.add(mforms.newLabel("Target Type:", True), 0, 1, 0, 1,
                   mforms.HFillFlag)
        self._ttype_selector = mforms.newSelector()
        self._ttype_selector.add_changed_callback(self.save_changes)
        ttable.add(self._ttype_selector, 1, 2, 0, 1,
                   mforms.HFillFlag | mforms.HExpandFlag)

        def add_check_entry_row(table, row, label, name):
            check = mforms.newCheckBox()
            check.set_text(label)
            table.add(check, 0, 1, row, row + 1, mforms.HFillFlag)
            entry = mforms.newTextEntry()
            entry.add_changed_callback(self.save_changes)
            table.add(entry, 1, 2, row, row + 1,
                      mforms.HFillFlag | mforms.HExpandFlag)
            setattr(self, name + "_check", check)
            setattr(self, name + "_entry", entry)
            entry.set_enabled(False)

            def callback(entry, check):
                if not check.get_active():
                    entry.set_value("-2")
                entry.set_enabled(check.get_active())
                self.save_changes()

            check.add_clicked_callback(lambda: callback(entry, check))

        add_check_entry_row(ttable, 1, "Override Length:", "_target_length")
        add_check_entry_row(ttable, 2, "Override Precision:",
                            "_target_precision")
        add_check_entry_row(ttable, 3, "Override Scale:", "_target_scale")

        detail_box.add(tpanel, False, True)

        ##

        bbox = mforms.newBox(True)

        self._add_button = mforms.newButton()
        self._add_button.set_text("Add")
        bbox.add(self._add_button, False, True)
        self._add_button.add_clicked_callback(self.add_clicked)
        self._del_button = mforms.newButton()
        self._del_button.set_text("Delete")
        self._del_button.add_clicked_callback(self.del_clicked)
        bbox.add(self._del_button, False, True)

        self._ok_button = mforms.newButton()
        self._ok_button.set_text("OK")
        self._ok_button.add_clicked_callback(self.ok_clicked)
        self._cancel_button = mforms.newButton()
        self._cancel_button.set_text("Cancel")
        self._ok_button.add_clicked_callback(self.cancel_clicked)
        mforms.Utilities.add_end_ok_cancel_buttons(bbox, self._ok_button,
                                                   self._cancel_button)
        content.add_end(bbox, False, True)
        bbox.set_spacing(12)
        self._del_button.set_enabled(False)

        self.set_size(700, 500)
 def make_info_table(self, info, params):
     info_table = mforms.newTable()
     info_table.set_column_spacing(8)
     info_table.set_row_spacing(6)
     info_table.set_column_count(2)
     return self.setup_info_table(info_table, info, params)
Exemplo n.º 35
0
    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")
Exemplo n.º 36
0
    def __init__(self, secman, user=""):
        mforms.Form.__init__(self, None,
                             mforms.FormResizable | mforms.FormMinimizable)

        self.set_title("New Schema Privilege Definition")

        self.secman = secman

        box = newBox(False)
        box.set_padding(12)
        box.set_spacing(8)
        self.set_content(box)

        label = newLabel()
        label.set_text(
            "Select the Host and the Schema for which the user '%s'\nwill have the privileges you want to define."
            % user)
        box.add(label, False, True)

        panel = newPanel(mforms.TitledBoxPanel)
        panel.set_title("Host")
        box.add(panel, False, True)
        table = newTable()
        panel.add(table)
        table.set_padding(8)
        table.set_row_count(3)
        table.set_column_count(3)
        table.set_row_spacing(8)

        self.host1 = newRadioButton(mforms.RadioButton.new_id())
        self.host1.set_active(True)
        self.host1.add_clicked_callback(self.host_radio_changed)
        self.host1.set_text("Any Host (%)")
        table.add(self.host1, 0, 1, 0, 1, mforms.HFillFlag)

        self.host2 = newRadioButton(self.host1.group_id())
        self.host2.set_text("Hosts matching pattern or name:")
        self.host2.add_clicked_callback(self.host_radio_changed)
        table.add(self.host2, 0, 1, 1, 2, mforms.HFillFlag)

        self.host2entry = newTextEntry()
        table.add(self.host2entry, 1, 2, 1, 2,
                  mforms.HFillFlag | mforms.HExpandFlag)

        self.host3 = newRadioButton(self.host1.group_id())
        self.host3.set_text("Selected host:")
        self.host3.add_clicked_callback(self.host_radio_changed)
        table.add(self.host3, 0, 1, 2, 3, mforms.HFillFlag)

        self.host3sel = newSelector()
        table.add(self.host3sel, 1, 2, 2, 3,
                  mforms.HFillFlag | mforms.HExpandFlag)

        hosts = [h for u, h in secman.account_names if u == user]
        self.host3sel.add_items(hosts)

        panel = newPanel(mforms.TitledBoxPanel)
        panel.set_title("Schema")
        box.add(panel, True, True)
        table = newTable()
        panel.add(table)
        table.set_padding(8)
        table.set_row_count(3)
        table.set_column_count(3)
        table.set_row_spacing(8)

        self.schema1 = newRadioButton(mforms.RadioButton.new_id())
        self.schema1.set_active(True)
        self.schema1.add_clicked_callback(self.schema_radio_changed)
        self.schema1.set_text("Any Schema (%)")
        table.add(self.schema1, 0, 1, 0, 1, mforms.HFillFlag)

        self.schema2 = newRadioButton(self.schema1.group_id())
        self.schema2.add_clicked_callback(self.schema_radio_changed)
        self.schema2.set_text("Schemas matching pattern or name:")
        table.add(self.schema2, 0, 1, 1, 2, mforms.HFillFlag)

        self.schema2entry = newTextEntry()
        table.add(self.schema2entry, 1, 2, 1, 2,
                  mforms.HFillFlag | mforms.HExpandFlag)

        self.schema3 = newRadioButton(self.schema1.group_id())
        self.schema3.add_clicked_callback(self.schema_radio_changed)
        self.schema3.set_text("Selected schema:")
        table.add(self.schema3, 0, 1, 2, 3, mforms.HFillFlag)

        self.schema3sel = newListBox(False)
        table.add(
            self.schema3sel, 1, 2, 2, 3, mforms.HFillFlag | mforms.HExpandFlag
            | mforms.VFillFlag | mforms.VExpandFlag)
        self.schema3sel.add_items(self.secman.schema_names)

        bbox = newBox(True)
        box.add(bbox, False, True)

        bbox.set_spacing(8)

        self.ok = newButton()
        self.ok.set_text("OK")
        bbox.add_end(self.ok, False, True)

        self.cancel = newButton()
        self.cancel.set_text("Cancel")
        bbox.add_end(self.cancel, False, True)

        self.set_size(450, 500)

        self.host_radio_changed()
        self.schema_radio_changed()

        self.center()
Exemplo n.º 37
0
    def __init__(self, editor):
        mforms.Form.__init__(self, mforms.Form.main_form(),
                             mforms.FormDialogFrame)

        self.editor = editor
        box = mforms.Box(False)
        box.set_padding(12)
        box.set_spacing(8)

        box.add(
            mforms.newLabel(
                "Preview the first lines of the script below and click [Run] to start executing.\nNote: the preview below may display non-ASCII characters incorrectly, even if the MySQL server can treat them correctly."
            ), False, True)
        self.file_info = mforms.newLabel("")
        box.add(self.file_info, False, True)
        self.text = mforms.newCodeEditor(None)
        self.text.set_language(mforms.LanguageMySQL)

        box.add(self.text, True, True)

        table = mforms.newTable()
        table.set_padding(20)
        table.set_row_count(2)
        table.set_column_count(3)
        table.set_row_spacing(8)
        table.set_column_spacing(4)
        table.add(mforms.newLabel("Default Schema Name:"), 0, 1, 0, 1, 0)
        self.schema = mforms.newSelector(mforms.SelectorCombobox)
        table.add(self.schema, 1, 2, 0, 1,
                  mforms.HFillFlag | mforms.HExpandFlag)

        help = mforms.newLabel(
            "Schema to be used unless explicitly specified in the script.\nLeave blank if the script already specified it,\npick a schema from the drop down or type a name to\ncreate a new one."
        )
        help.set_style(mforms.SmallHelpTextStyle)
        table.add(help, 2, 3, 0, 1, mforms.HFillFlag)

        table.add(mforms.newLabel("Default Character Set:"), 0, 1, 1, 2, 0)
        self.charset = mforms.newSelector()
        self.charset.add_changed_callback(self.update_preview)
        l = [""]
        for ch in grt.root.wb.rdbmsMgmt.rdbms[0].characterSets:
            l.append(ch.name)
        self.charset.add_items(sorted(l))
        table.add(self.charset, 1, 2, 1, 2,
                  mforms.HFillFlag | mforms.HExpandFlag)

        help = mforms.newLabel(
            "Default character set to use when executing the script,\nunless specified in the script."
        )
        help.set_style(mforms.SmallHelpTextStyle)
        table.add(help, 2, 3, 1, 2, mforms.HFillFlag)

        box.add(table, False, True)

        self.ok = mforms.newButton()
        self.ok.set_text("Run")

        self.cancel = mforms.newButton()
        self.cancel.set_text("Cancel")

        hbox = mforms.Box(True)
        hbox.set_spacing(8)
        mforms.Utilities.add_end_ok_cancel_buttons(hbox, self.ok, self.cancel)
        box.add_end(hbox, False, True)

        self.set_content(box)
    def __init__(self):
        mforms.Form.__init__(self, None, mforms.FormDialogFrame|mforms.FormResizable|mforms.FormMinimizable)
        
        self.set_title("Data Type Mapping for Generic Migration")
        
        content = mforms.newBox(False)
        self.set_content(content)
        content.set_padding(12)
        content.set_spacing(12)
        
        hbox = mforms.newBox(True)
        content.add(hbox, True, True)
        hbox.set_spacing(12)
        
        self._type_list = mforms.newTreeNodeView(mforms.TreeFlatList)#|mforms.TreeAllowReorderRows)
        self._type_list.set_size(200, -1)
        self._type_list.add_column(mforms.StringColumnType, "Type", 100, False)
        self._type_list.add_column(mforms.StringColumnType, "Target Type", 100, False)
        self._type_list.end_columns()
        self._type_list.add_changed_callback(self.selection_changed)
        hbox.add(self._type_list, False, True)

        detail_box = mforms.newBox(False)
        self.detail_box = detail_box
        hbox.add(detail_box, True, True)
        detail_box.set_spacing(12)
        
        ##
        
        spanel = mforms.newPanel(mforms.TitledBoxPanel)
        spanel.set_title("Source Data Type")
        
        stable = mforms.newTable()
        stable.set_padding(12)
        spanel.add(stable)
        stable.set_row_count(5)
        stable.set_column_count(2)
        stable.set_row_spacing(8)
        stable.set_column_spacing(4)

        stable.add(mforms.newLabel("Type Name:", True), 0, 1, 0, 1, mforms.HFillFlag)
        self._stype_entry = mforms.newTextEntry()
        self._stype_entry.add_changed_callback(self.save_changes)
        stable.add(self._stype_entry, 1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag) 

        #self._stype_user_check = mforms.newCheckBox()
        #self._stype_user_check.set_text("Is user datatype")
        #stable.add(self._stype_user_check, 1, 2, 1, 2, mforms.HFillFlag|mforms.HExpandFlag) 
        
        stable.add(mforms.newLabel("Type Category:", True), 0, 1, 2, 3, mforms.HFillFlag)
        self._sgroup_selector = mforms.newSelector()
        stable.add(self._sgroup_selector, 1, 2, 2, 3, mforms.HFillFlag|mforms.HExpandFlag) 
        self._sgroup_selector.add_changed_callback(self.source_group_selected)

        stable.add(mforms.newLabel("Min. Length:", True), 0, 1, 3, 4, mforms.HFillFlag)
        self._sminlen_entry = mforms.newTextEntry()
        self._sminlen_entry.add_changed_callback(self.save_changes)
        stable.add(self._sminlen_entry, 1, 2, 3, 4, mforms.HFillFlag|mforms.HExpandFlag) 
        stable.add(mforms.newLabel("Max. Length:", True), 0, 1, 4, 5, mforms.HFillFlag)
        self._smaxlen_entry = mforms.newTextEntry()
        self._smaxlen_entry.add_changed_callback(self.save_changes)
        stable.add(self._smaxlen_entry, 1, 2, 4, 5, mforms.HFillFlag|mforms.HExpandFlag) 

        detail_box.add(spanel, False, True)
        
        ##
        
        tpanel = mforms.newPanel(mforms.TitledBoxPanel)
        tpanel.set_title("Target MySQL Data Type")
        
        ttable = mforms.newTable()
        ttable.set_padding(12)
        tpanel.add(ttable)
        ttable.set_row_count(4)
        ttable.set_column_count(2)
        ttable.set_row_spacing(8)
        ttable.set_column_spacing(4)

        ttable.add(mforms.newLabel("Target Type:", True), 0, 1, 0, 1, mforms.HFillFlag)
        self._ttype_selector = mforms.newSelector()
        self._ttype_selector.add_changed_callback(self.save_changes)
        ttable.add(self._ttype_selector, 1, 2, 0, 1, mforms.HFillFlag|mforms.HExpandFlag) 
        
        def add_check_entry_row(table, row, label, name):
            check = mforms.newCheckBox()
            check.set_text(label)
            table.add(check, 0, 1, row, row+1, mforms.HFillFlag)
            entry = mforms.newTextEntry()
            entry.add_changed_callback(self.save_changes)
            table.add(entry, 1, 2, row, row+1, mforms.HFillFlag|mforms.HExpandFlag) 
            setattr(self, name+"_check", check)
            setattr(self, name+"_entry", entry)
            entry.set_enabled(False)
            def callback(entry, check):
                if not check.get_active():
                    entry.set_value("-2")
                entry.set_enabled(check.get_active())
                self.save_changes()
            check.add_clicked_callback(lambda: callback(entry, check))

        add_check_entry_row(ttable, 1, "Override Length:", "_target_length")
        add_check_entry_row(ttable, 2, "Override Precision:", "_target_precision")
        add_check_entry_row(ttable, 3, "Override Scale:", "_target_scale")

        detail_box.add(tpanel, False, True)
        
        ##
        
        bbox = mforms.newBox(True)
        
        self._add_button = mforms.newButton()
        self._add_button.set_text("Add")
        bbox.add(self._add_button, False, True)
        self._add_button.add_clicked_callback(self.add_clicked)
        self._del_button = mforms.newButton()
        self._del_button.set_text("Delete")
        self._del_button.add_clicked_callback(self.del_clicked)
        bbox.add(self._del_button, False, True)

        self._ok_button = mforms.newButton()
        self._ok_button.set_text("OK")
        self._ok_button.add_clicked_callback(self.ok_clicked)
        self._cancel_button = mforms.newButton()
        self._cancel_button.set_text("Cancel")
        self._ok_button.add_clicked_callback(self.cancel_clicked)
        mforms.Utilities.add_end_ok_cancel_buttons(bbox, self._ok_button, self._cancel_button)
        content.add_end(bbox, False, True)
        bbox.set_spacing(12)
        self._del_button.set_enabled(False)

        self.set_size(700, 500)