class RField
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
field[R]
table[R]
Public Class Methods
new(table,field=nil)
click to toggle source
Calls superclass method
# File lib/RelationBuilder/RTable/RField.rb, line 6 def initialize(table,field=nil) @table=table super("",false) remove(child) @label=Gtk::Label.new set_child(@index_holder=Gtk::Table.new(5,1)) @index_holder.attach(@label,0,1,0,1) @index_holder.attach(@primary_img=Gtk::Image.new(@table.parentM.img_primary.scale(10,10)).set_no_show_all(true),1,2,0,1,Gtk::SHRINK) @index_holder.attach(@unique_img=Gtk::Image.new(@table.parentM.img_unique.scale(10,10)).set_no_show_all(true),2,3,0,1,Gtk::SHRINK) @index_holder.attach(@index_img=Gtk::Image.new(@table.parentM.img_index.scale(10,10)).set_no_show_all(true),3,4,0,1,Gtk::SHRINK) set_field(field) signal_connect("toggled"){|me,ev| @table.parentM.changed(self)} signal_connect('button-press-event'){|me,ev| if ev.button == 3 @table.parentM.set_focused_item(@table) menu=Gtk::Menu.new menu.signal_connect("deactivate",self){|menu,table| @table.parentM.set_focused_item(nil)} menu.append(pr=Gtk::ImageMenuItem.new("`#{field_name}` properties").set_image(Gtk::Image.new(Gtk::Stock::PROPERTIES,Gtk::IconSize::MENU))) pr.signal_connect("activate"){|me| @table.alter_field(@field)} if @table.parentM.rel_ed_status == :start menu.append(re=Gtk::ImageMenuItem.new("finish add relation here `#{field_name}`").set_image(Gtk::Image.new(Gtk::Stock::CONNECT,Gtk::IconSize::MENU))) re.signal_connect("activate"){|me| @table.parentM.rel_edit(self,:finish)} menu.append(rc=Gtk::ImageMenuItem.new("cancel relation").set_image(Gtk::Image.new(Gtk::Stock::CANCEL,Gtk::IconSize::MENU))) rc.signal_connect("activate"){|me| @table.parentM.rel_edit(self,:cancel)} else menu.append(re=Gtk::ImageMenuItem.new("start add relation here `#{field_name}`").set_image(Gtk::Image.new(Gtk::Stock::CONNECT,Gtk::IconSize::MENU))) re.signal_connect("activate"){|me| @table.parentM.rel_edit(self,:start)} end menu.append(rf=Gtk::ImageMenuItem.new("remove field `#{field_name}`").set_image(Gtk::Image.new(Gtk::Stock::REMOVE,Gtk::IconSize::MENU))) rf.signal_connect("activate"){|me| @table.remove_field(field_name)} menu.append(afa=Gtk::ImageMenuItem.new("append field after `#{field_name}`").set_image(Gtk::Image.new(Gtk::Stock::ADD,Gtk::IconSize::MENU))) afa.signal_connect("activate"){|me| @table.alter_field(nil,field_name)} menu.show_all menu.popup(nil,nil,ev.button,ev.time) true else false end } end
Public Instance Methods
field_name()
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 79 def field_name @field["Field"] || "undefined" end
inspect()
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 89 def inspect "RField:#{field_name} of #{table}" end
set_field(field)
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 48 def set_field(field) @field=field @label.set_label(field["Field"]) unless field["Field"] == @label.label if f=@field["Type"].index("(") @field["Size"]=field["Type"][f+1 .. field["Type"].index(")") -1] @field["Type"]=field["Type"][0 .. f-1] end #set style set_style(@table.parentM.field_style[@field["Type"]]) if @table.parentM.field_style.has_key?(@field["Type"]) && style != @table.parentM.field_style[@field["Type"]] #remove old images #@index_holder.children.each{|ch| @index_holder.remove(ch)} #re-add label #@index_holder.attach(@label,0,1,0,2) #show images show_primary=false show_unique=false show_index=false @table.indexes.each{|index| if index["field"]==@field["Field"] show_primary=(index["name"]=="PRIMARY") show_unique=(index["unique"] == true) show_index=(index["unique"] == false) end } @primary_img.set_visible(show_primary) if @primary_img.visible? != show_primary @unique_img.set_visible(show_unique) if @unique_img.visible? != show_unique @index_img.set_visible(show_index) if @index_img.visible? != show_index show_all end
table_name()
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 82 def table_name @table.table end
table_width()
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 85 def table_width @table.widget.allocation.width end
to_s()
click to toggle source
# File lib/RelationBuilder/RTable/RField.rb, line 92 def to_s inspect end