class ConnectionProperties
this file is part of manqod-server-console manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Public Class Methods
new(parent_window,cn,manqod_server)
click to toggle source
Calls superclass method
# File lib/ConnectionProperties.rb, line 6 def initialize(parent_window,cn,manqod_server) @manqod_server=manqod_server @cn=cn conn=@manqod_server.conn(@cn) super("Connection Properties",parent_window,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]) dh=Gtk::Table.new(2,1) dh.attach2("Conenction: ",Gtk::Label.new(@cn)) @name=dh.attach2("Visible connection name: ",Gtk::Entry.new.set_text(conn["name"])) @uri=dh.attach2("URI:",Gtk::Entry.new.set_text(conn["uri"])) @cache_host=dh.attach2("Memcache host:",Gtk::Entry.new.set_text(conn["cache_host"])) @sql_host=dh.attach2("SQL host:",Gtk::Entry.new.set_text(conn["sql_host"])) @sql_user=dh.attach2("SQL user:",Gtk::Entry.new.set_text(conn["sql_user"])) @sql_password=dh.attach2("SQL password:",Gtk::Entry.new.set_text(conn["sql_password"])) @sql_db=dh.attach2("SQL database:",Gtk::Entry.new.set_text(conn["sql_db"])) dh.attach2("SQL database functions:",Gtk::HButtonBox.new. pack_start(check_db=Gtk::Button.new("check")). pack_start(pstruct_db=Gtk::Button.new("populate\nstructure"))). pack_start(pmanqod_db=Gtk::Button.new("pupulate\nmanqod")) @admin_uri=dh.attach2("Admin URI:",Gtk::Entry.new.set_text(conn["admin_uri"])) @client_uri=dh.attach2("Client URI:",Gtk::Entry.new.set_text(conn["client_uri"])) @auto_load=dh.attach2("Auto load on startup:",Gtk::CheckButton.new.set_active(conn["auto_load"])) @auto_load_order=dh.attach2("Auto load order:",Gtk::Entry.new.set_text(conn["auto_load_order"])) @client_default=dh.attach2("Default for clients:",Gtk::CheckButton.new.set_active(conn["client_default"])) vbox.pack_start(dh) #check and create database and permission check_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.check_sql_db(cn) Gtk::warn("Mysql connection is OK") rescue =>err begin Gtk::warn("checking #{cn.inspect} failed",err,ERROR) dialog=Gtk::Dialog.new("Crate database and permissions",self,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]) holder=Gtk::Table.new(2,1) su=holder.attach2("Super User Username",Gtk::Entry.new.set_text("root")) sup=holder.attach2("Super User Password",Gtk::Entry.new.set_visibility(false)) dialog.vbox.pack_start(holder) dialog.show_all if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT @manqod_server.create_sql_db_and_perms(cn,su.text,sup.text) Gtk::warn("Mysql database and permissions created.\nCheck again.") end rescue =>err2 Gtk::warn("SU on #{@cn.inspect} failed",err2,ERROR) ensure dialog.destroy end end } #populate manqod db pmanqod_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.populate_manqod_db(cn) Gtk::warn("Population of #{cn} was succesful") rescue =>err Gtk::warn("Population of #{cn.inspect} failed",err,ERROR) end } #populate manqod db structure pstruct_db.signal_connect("clicked",@cn){|me,cn| begin save_conn @manqod_server.populate_manqod_db(cn,true) Gtk::warn("Structure population of #{cn} was succesful") rescue =>err Gtk::warn("Structure population of #{cn.inspect} failed",err,ERROR) end } end
Public Instance Methods
run()
click to toggle source
Calls superclass method
# File lib/ConnectionProperties.rb, line 84 def run show_all ret=super() if ret==Gtk::Dialog::RESPONSE_ACCEPT save_conn end ret=@name.text destroy ret end
save_conn()
click to toggle source
# File lib/ConnectionProperties.rb, line 94 def save_conn begin @manqod_server.set_conn_variables(@cn,{"name" => @name.text, "uri" => @uri.text, "cache_host" => @cache_host.text, "sql_host" => @sql_host.text, "sql_user" => @sql_user.text, "sql_password" => @sql_password.text, "sql_db" => @sql_db.text, "admin_uri" => @admin_uri.text, "client_uri" => @client_uri.text, "auto_load" => @auto_load.active?, "auto_load_order" => @auto_load_order.text, "client_default" => @client_default.active?} ) rescue => err retry if Gtk::warn("restoring #{@cn.inspect} failed",err,ERROR,true) end end