manqod 1.1532.0 → 1.1556.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,10 +17,10 @@ class ManqodRPC
17
17
  @manqod_server=DRb::DRbObject.new(nil,server_uri)
18
18
  end
19
19
  def unregister_client
20
- manqod_server.unregister_client(self)
20
+ manqod_server.unregister_client(ManqodRPC.instance.to_s)
21
21
  end
22
22
  def register_client
23
- manqod_server.register_client(self,ManqodDB.instance.manqod_db.name.to_s)
23
+ manqod_server.register_client(ManqodRPC.instance.to_s,self,ManqodDB.instance.manqod_db.name.to_s)
24
24
  end
25
25
  def nick
26
26
  Nick.instance.get_nick
@@ -23,7 +23,7 @@ class PrintItem
23
23
  end
24
24
  attr_reader :type, :x, :y, :txt, :font, :width, :height, :page, :cr, :text_alignment
25
25
  attr_reader :column_width, :draw_header_cell_borders, :column_pos, :fill_header_background, :header_line_width, :row_underline
26
- attr_reader :cell_line_width, :sum_line_width, :list, :next_iter
26
+ attr_reader :cell_line_width, :sum_line_width, :list, :next_iter, :print_with_gantt
27
27
 
28
28
  def draw(cr_to_draw_to)
29
29
  @cr=cr_to_draw_to
@@ -104,6 +104,7 @@ class PrintItem
104
104
  @sum_line_width=list.gtk_attribute("sum_line_width").to_f || 0.6
105
105
  @print_title=list.gtk_attribute("print_title")=="true"
106
106
  @row_underline=(list.gtk_attribute("row_underline") || 0.0).to_f
107
+ @print_with_gantt=(list.gtk_attribute("print_with_gantt") || "false") == "true"
107
108
 
108
109
  @layouts=Array.new
109
110
  @current_height=y
@@ -179,7 +180,7 @@ class PrintItem
179
180
  edebug("breaking list #{list} to the next page","printing","info")
180
181
  break
181
182
  end
182
- il.y=@current_height
183
+ il.set_y(@current_height)
183
184
  @current_height+=il.row_height+@row_spacing
184
185
  @layouts.push(il)
185
186
  @sums.each_key{|key| @sums[key]=@sums[key]+iter[key].to_f}
@@ -9,6 +9,7 @@ class RelationBuilder < Gtk::ScrolledWindow
9
9
  @img_unique=Gdk::Pixdata.deserialize([71, 100, 107, 80, 0, 0, 1, 216, 2, 1, 0, 2, 0, 0, 0, 64, 0, 0, 0, 16, 0, 0, 0, 16, 145, 0, 0, 0, 0, 142, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 1, 102, 102, 102, 255, 136, 153, 153, 204, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 1, 102, 102, 102, 255, 136, 153, 153, 204, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 142, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 136, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 3, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 130, 204, 0, 0, 255, 131, 255, 255, 255, 255, 130, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 132, 255, 255, 255, 255, 130, 204, 0, 0, 255, 131, 255, 255, 255, 255, 130, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 3, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 130, 204, 0, 0, 255, 131, 255, 255, 255, 255, 130, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 132, 255, 255, 255, 255, 130, 204, 0, 0, 255, 131, 255, 255, 255, 255, 130, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 3, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 130, 204, 0, 0, 255, 131, 255, 255, 255, 255, 130, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 132, 255, 255, 255, 255, 135, 204, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 6, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 133, 204, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 136, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 142, 102, 102, 102, 255, 145, 0, 0, 0, 0]).to_pixbuf(true)
10
10
  @img_index=Gdk::Pixdata.deserialize([71, 100, 107, 80, 0, 0, 2, 106, 2, 1, 0, 2, 0, 0, 0, 64, 0, 0, 0, 16, 0, 0, 0, 16, 145, 0, 0, 0, 0, 142, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 1, 102, 102, 102, 255, 132, 153, 153, 204, 255, 5, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 153, 255, 255, 204, 51, 255, 0, 0, 0, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 4, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 153, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 130, 0, 0, 0, 0, 135, 102, 102, 102, 255, 4, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 153, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 255, 255, 255, 255, 3, 128, 128, 128, 255, 255, 255, 153, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 9, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 128, 128, 128, 255, 255, 255, 255, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 3, 102, 102, 102, 255, 128, 128, 128, 255, 255, 255, 255, 255, 133, 255, 204, 51, 255, 130, 0, 0, 0, 255, 130, 0, 0, 0, 0, 5, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 132, 0, 0, 0, 255, 2, 255, 255, 255, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 255, 255, 255, 255, 3, 128, 128, 128, 255, 255, 255, 255, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 2, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 9, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 128, 128, 128, 255, 255, 255, 255, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 255, 255, 255, 255, 1, 255, 204, 51, 255, 130, 0, 0, 0, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 7, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 255, 204, 51, 255, 130, 0, 0, 0, 255, 132, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 2, 102, 102, 102, 255, 255, 255, 255, 255, 130, 0, 0, 0, 255, 133, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 142, 102, 102, 102, 255, 145, 0, 0, 0, 0]).to_pixbuf(true)
11
11
  @img_primary=Gdk::Pixdata.deserialize([71, 100, 107, 80, 0, 0, 2, 190, 2, 1, 0, 2, 0, 0, 0, 64, 0, 0, 0, 16, 0, 0, 0, 16, 145, 0, 0, 0, 0, 135, 102, 102, 102, 255, 133, 0, 0, 0, 255, 130, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 10, 102, 102, 102, 255, 153, 153, 204, 255, 0, 0, 0, 255, 230, 184, 0, 255, 234, 187, 0, 255, 240, 192, 0, 255, 245, 196, 0, 255, 250, 200, 0, 255, 0, 0, 0, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 153, 153, 204, 255, 7, 102, 102, 102, 255, 0, 0, 0, 255, 232, 186, 0, 255, 234, 187, 0, 255, 238, 190, 0, 255, 0, 0, 0, 255, 249, 199, 0, 255, 130, 254, 203, 0, 255, 1, 0, 0, 0, 255, 130, 0, 0, 0, 0, 133, 102, 102, 102, 255, 3, 0, 0, 0, 255, 236, 189, 0, 255, 238, 190, 0, 255, 131, 244, 195, 0, 255, 3, 252, 202, 0, 255, 249, 199, 0, 255, 0, 0, 0, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 10, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 251, 201, 0, 255, 253, 202, 0, 255, 245, 196, 0, 255, 239, 191, 0, 255, 234, 187, 0, 255, 0, 0, 0, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 5, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 130, 255, 255, 255, 255, 7, 0, 0, 0, 255, 250, 200, 0, 255, 243, 194, 0, 255, 236, 189, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 3, 0, 0, 0, 255, 241, 193, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 6, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 130, 0, 0, 0, 255, 3, 249, 199, 0, 255, 242, 194, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 3, 0, 0, 0, 255, 243, 194, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 6, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 130, 0, 0, 0, 255, 3, 250, 200, 0, 255, 245, 196, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 3, 0, 0, 0, 255, 247, 198, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 6, 102, 102, 102, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 102, 102, 102, 255, 255, 255, 255, 255, 130, 0, 0, 0, 255, 3, 252, 202, 0, 255, 248, 198, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 1, 102, 102, 102, 255, 131, 255, 255, 255, 255, 3, 0, 0, 0, 255, 249, 199, 0, 255, 0, 0, 0, 255, 130, 255, 255, 255, 255, 1, 102, 102, 102, 255, 130, 0, 0, 0, 0, 137, 102, 102, 102, 255, 1, 0, 0, 0, 255, 132, 102, 102, 102, 255, 145, 0, 0, 0, 0]).to_pixbuf(true)
12
+
12
13
  @field_style={
13
14
  'tinyint'=>Gtk::Style.new.set_bg(Gtk::STATE_NORMAL,0x4000,0x5700,0xdd00),
14
15
  'int'=>Gtk::Style.new.set_bg(Gtk::STATE_NORMAL,0x4000,0xa500,0xdd00),
@@ -34,7 +35,7 @@ class RelationBuilder < Gtk::ScrolledWindow
34
35
  super()
35
36
  @base_object=nil
36
37
  @rel_ed=Array.new
37
- @relations=Array.new
38
+ @relations=Hash.new
38
39
  @tables=Hash.new
39
40
  @holder=Gtk::VBox.new
40
41
  @widget=Gtk::Fixed.new
@@ -61,11 +62,7 @@ class RelationBuilder < Gtk::ScrolledWindow
61
62
  dialog.show_all
62
63
  if dialog.run == Gtk::Dialog::ResponseType::OK
63
64
  client.query("CREATE TABLE `#{table_name.text}` (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE = MYISAM")
64
- query("insert into tables set name='#{table_name.text}'")
65
- if trow=qrow("select * from tables where name='#{table_name.text}'")
66
- @tables[trow["name"]]=RTable.new(self,trow["name"],trow["id"],@widget.pointer[0],@widget.pointer[1]).show_me
67
- @widget.show_all
68
- end
65
+ add_existing_table(table_name.text)
69
66
  end
70
67
  dialog.destroy
71
68
 
@@ -129,7 +126,7 @@ class RelationBuilder < Gtk::ScrolledWindow
129
126
 
130
127
  def table_by_id(table_id)
131
128
  found=nil
132
- @tables.each{|table_name,tableo|
129
+ @tables.each_pair{|table_name,tableo|
133
130
  if tableo.table_id.to_i == table_id.to_i
134
131
  found=tableo
135
132
  break
@@ -137,16 +134,6 @@ class RelationBuilder < Gtk::ScrolledWindow
137
134
  }
138
135
  found
139
136
  end
140
- def relation_by_id(rel_id)
141
- found=nil
142
- @relations.each{|rel|
143
- if rel.relation_id.to_i == rel_id.to_i
144
- found=rel
145
- break
146
- end
147
- }
148
- found
149
- end
150
137
 
151
138
  def update(notifier=nil)
152
139
  reload
@@ -158,13 +145,21 @@ class RelationBuilder < Gtk::ScrolledWindow
158
145
  @search_window=SearchWindow.new(self) unless @search_window
159
146
  @rq_window=RunQuery.new(self) unless @rq_window
160
147
 
161
- rows("select * from tables"){|row|
162
- @tables[row["name"]]=RTable.new(self,row["name"],row["id"],row["rbx"].to_f,row["rby"].to_f)
148
+ ctables=cache.get("tables")
149
+ crelations=cache.get("relations")
150
+ ctables.each_pair{|table_name,table|
151
+ if @tables.has_key?(table_name)
152
+ @tables[table_name].update(table)
153
+ else
154
+ @tables[table_name]=RTable.new(self,table)
155
+ end
163
156
  }
164
- rows("select * from relations"){|row|
165
- r1=tables[row["src_table"]].fields[row["src_field"]] if tables.has_key?(row["src_table"])
166
- r2=tables[row["dst_table"]].fields[row["dst_field"]] if tables.has_key?(row["dst_table"])
167
- @relations.push(r=Relation.new(self,r1,r2,row['rel_name'],row["rel_type"],row["id"],row["rbx"].to_f,row["rby"].to_f,row['rel_custom']))
157
+ crelations.each_pair{|rel_id,rel|
158
+ if @relations.has_key?(rel_id)
159
+ @relations[rel_id].reload(rel)
160
+ else
161
+ @relations[rel_id]=Relation.new(self,rel)
162
+ end
168
163
  }
169
164
  review_all
170
165
  end
@@ -173,21 +168,18 @@ class RelationBuilder < Gtk::ScrolledWindow
173
168
  if @show_only_query
174
169
  #show only related to query
175
170
  @tables.each_value{|table| table.set_visibility(false)}
176
- @relations.each{|rel| rel.set_visibility(rel.active?)}
177
- @relations.each{|rel|
171
+ @relations.each_value{|rel| rel.set_visibility(rel.active?)}
172
+ @relations.each_value{|rel|
178
173
  if rel.active?
179
174
  rel.rfield1.table.show_neighbours
180
175
  rel.rfield2.table.show_neighbours
181
176
  end
182
177
  }
183
178
  @base_object.show_neighbours if @base_object
184
- # @relations.each{|rel|
185
- # rel.set_visibility(rel.rfield1.table.shown? && rel.rfield2.table.shown?)
186
- # }
187
179
  else
188
180
  #show all
189
181
  @tables.each_value{|table| table.set_visibility(true)}
190
- @relations.each{|rel| rel.set_visibility(true)}
182
+ @relations.each_value{|rel| rel.set_visibility(true)}
191
183
  end
192
184
  clear
193
185
  end
@@ -235,7 +227,7 @@ class RelationBuilder < Gtk::ScrolledWindow
235
227
 
236
228
  def draw_relations
237
229
  cr=@widget.window.create_cairo_context
238
- @relations.each{|rel|
230
+ @relations.each_value{|rel|
239
231
  next unless rel.visible? && rel.handle.realized?
240
232
  begin
241
233
  x1=rel.rfield1.table.widget.translate_coordinates(@widget,0,0)[0]
@@ -399,8 +391,8 @@ class RelationBuilder < Gtk::ScrolledWindow
399
391
  case status
400
392
  when :start
401
393
  x1,y1=rfield.translate_coordinates(@widget,0,0)
402
- @rel_in_ed=Relation.new(self,rfield,nil,"",nil,nil,x1-30,y1-30)
403
- @relations.push(@rel_in_ed)
394
+ @rel_in_ed=Relation.new(self,{"src_table" => rfield.table_name, "src_field" => rfield.field_name, "rbx" => x1-30, "rby" => y1-30})
395
+ @relations[0]=@rel_in_ed
404
396
  @rel_in_ed.show_me
405
397
  when :finish
406
398
  @rel_in_ed.set_rfield2(rfield)
@@ -413,7 +405,7 @@ class RelationBuilder < Gtk::ScrolledWindow
413
405
 
414
406
  def find_relation(rfield1,rfield2)
415
407
  rel=nil
416
- @relations.each{|r|
408
+ @relations.each_value{|r|
417
409
  if [r.rfield1,r.rfield2] == [rfield1,rfield2] or [r.rfield1,r.rfield2] == [rfield2,rfield1]
418
410
  rel=r
419
411
  end
@@ -423,9 +415,9 @@ class RelationBuilder < Gtk::ScrolledWindow
423
415
 
424
416
  def remove_table(table,from_sql=false)
425
417
  @tables[table].fields.each{|field,field_wg|
426
- @relations.each{|rel|
418
+ @relations.each_value{|rel|
427
419
  if rel.rfield1 == field_wg or rel.rfield2 == field_wg
428
- edebug("removing #{rel}","relation-builder","debug")
420
+ edebug("removing #{rel}","relation-builder")
429
421
  rel.remove
430
422
  end
431
423
  }
@@ -434,19 +426,22 @@ class RelationBuilder < Gtk::ScrolledWindow
434
426
  client.query("drop table `#{table}`") if from_sql
435
427
  @tables[table].widget.destroy
436
428
  @tables.delete(table)
429
+ reload_server_rb(true)
437
430
  changed(@tables[table])
438
431
  end
439
432
  def add_existing_table(table_name)
440
433
  unless @tables.has_key?(table_name)
441
- query("insert into tables set name='#{table_name}'")
442
- if trow=qrow("select * from tables where name='#{table_name}'")
443
- @tables[trow["name"]]=RTable.new(self,trow["name"],trow["id"],@widget.pointer[0],@widget.pointer[1])
444
- @tables[trow["name"]].show_me
445
- @widget.show_all
446
- changed(@tables[trow["name"]])
447
- end
434
+ query("insert into tables (name,rbx,rby) values('#{table_name}','#{@widget.pointer[0]}','#{@widget.pointer[1]}')")
435
+ reload_server_rb(true)
448
436
  end
449
437
  end
438
+
439
+ def reload_server_rb(reload_me_too=true)
440
+ Thread.new{
441
+ ManqodDB.instance.manqod_db.relation_builder.update if ManqodDB.instance.manqod_db.relation_builder
442
+ reload if reload_me_too
443
+ }
444
+ end
450
445
 
451
446
  def build_query
452
447
  sql=@query_id
@@ -457,7 +452,7 @@ class RelationBuilder < Gtk::ScrolledWindow
457
452
  @base_object.center_on_me
458
453
  end
459
454
  def changed(notifier=nil)
460
- edebug("#{notifier} changed, notifying observers","relation-builder","debug")
455
+ edebug("#{notifier} changed, notifying observers","relation-builder")
461
456
  super()
462
457
  notify_observers(self,notifier)
463
458
  end
@@ -4,11 +4,8 @@
4
4
 
5
5
  class RTable < Gtk::EventBox
6
6
  include ManqodCommon
7
- def initialize(parentM,table=nil,table_id = nil,x=0,y=0)
7
+ def initialize(parentM,td)
8
8
  @parentM=parentM
9
- @table_id=if table_id then table_id.to_i else nil end
10
- @x=x
11
- @y=y
12
9
  @shown=false
13
10
  super()
14
11
  visible_window=false
@@ -21,8 +18,7 @@ class RTable < Gtk::EventBox
21
18
  @widget.add(Gtk::VButtonBox.new)
22
19
  @widget.set_label_xalign(0.5)
23
20
  @fields=Hash.new
24
- @indexes=Array.new
25
- set_table(table)
21
+ update(td)
26
22
 
27
23
  signal_connect('button-press-event'){|me,ev|
28
24
  parentM.set_focused_item(self)
@@ -90,9 +86,7 @@ class RTable < Gtk::EventBox
90
86
  def set_table(table)
91
87
  @table=table
92
88
  @label.set_label(table)
93
- if !table.nil?
94
- @is_view=false
95
- client_fields("show create table `#{table}`"){|f| @is_view=true if f["name"].include?("View")}
89
+ unless table.nil?
96
90
  if is_view?
97
91
  @frame_button.set_image(Gtk::Image.new(Gtk::Stock::ABOUT,Gtk::IconSize::MENU))
98
92
  @widget.set_shadow_type(Gtk::ShadowType::IN).modify_bg(Gtk::StateType::NORMAL,Gdk::Color.parse('#E0D130'))
@@ -104,13 +98,25 @@ class RTable < Gtk::EventBox
104
98
  end
105
99
  end
106
100
 
101
+ def update(td)
102
+ @table_id=(td["id"] ? td["id"].to_i : nil)
103
+ @x=td["rbx"]
104
+ @y=td["rby"]
105
+ @fields_data=td["fields"]
106
+ @indexes=td["indexes"]
107
+ @is_view=td["view"]
108
+ set_table(td["name"])
109
+ end
110
+
107
111
  def reload
112
+ =begin
108
113
  @indexes.clear
109
114
  client_rows("show indexes from #{table}"){|index|
110
115
  @indexes.push({"name"=>index["Key_name"],"unique"=>index["Non_unique"]=="0", "field"=>index["Column_name"]})
111
116
  }
117
+ =end
112
118
  i=0
113
- client_rows("show fields from #{table}"){|field|
119
+ @fields_data.each_pair{|field_name,field|
114
120
  if @fields.has_key?(field["Field"])
115
121
  @fields[field["Field"]].set_field(field)
116
122
  else
@@ -132,7 +138,7 @@ class RTable < Gtk::EventBox
132
138
  client_query("rename table `#{@table}` to `#{new_table}`")
133
139
  @table=new_table
134
140
  @fields.each{|field,field_wg|
135
- parentM.relations.each{|rel|
141
+ parentM.relations.each_value{|rel|
136
142
  if rel.rfield1 == field_wg or rel.rfield2 == field_wg
137
143
  rel.save
138
144
  end
@@ -141,10 +147,12 @@ class RTable < Gtk::EventBox
141
147
 
142
148
  save_me
143
149
  set_table(new_table)
150
+ parentM.reload_server_rb
144
151
  end
145
152
 
146
153
  def save_me
147
154
  query("update tables set rbx='#{x}', rby='#{y}', name='#{@table}' where id='#{table_id}'")
155
+ @parentM.reload_server_rb
148
156
  end
149
157
 
150
158
  def show_me
@@ -173,7 +181,7 @@ class RTable < Gtk::EventBox
173
181
 
174
182
  def show_neighbours
175
183
  show_me
176
- @parentM.relations.each{|rel|
184
+ @parentM.relations.each_value{|rel|
177
185
  if rel.rfield1.table == self || rel.rfield2.table == self
178
186
  rel.rfield1.table.show_me
179
187
  rel.rfield2.table.show_me
@@ -186,7 +194,7 @@ class RTable < Gtk::EventBox
186
194
  dialog=Gtk::MessageDialog.new(nil,Gtk::Dialog::Flags::MODAL,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::ButtonsType::YES_NO,"remove field `#{field}`?")
187
195
  dialog.show_all
188
196
  if dialog.run == Gtk::Dialog::ResponseType::YES
189
- parentM.relations.each{|rel|
197
+ parentM.relations.each_value{|rel|
190
198
  if rel.rfield1 == @fields[field] or rel.rfield2 == @fields[field]
191
199
  edebug("removing #{rel}","relation-builder","debug")
192
200
  rel.remove
@@ -197,7 +205,7 @@ class RTable < Gtk::EventBox
197
205
  @fields[field].destroy
198
206
  @fields.delete(field)
199
207
  parentM.clear
200
- # reload
208
+ parentM.reload_server_rb
201
209
  end
202
210
  dialog.destroy
203
211
  end
@@ -267,7 +275,7 @@ class RTable < Gtk::EventBox
267
275
  rescue =>err
268
276
  retry if tell_exception("error altering the table",backtrace_to_debug(err),"server","error",false,true,err)
269
277
  end
270
- reload
278
+ parentM.reload_server_rb
271
279
  end
272
280
  dialog.destroy
273
281
  end
@@ -8,7 +8,11 @@ class RField < Gtk::ToggleButton
8
8
  super("",false)
9
9
  remove(child)
10
10
  @label=Gtk::Label.new
11
- set_child(@index_holder=Gtk::Table.new(5,2))
11
+ set_child(@index_holder=Gtk::Table.new(5,1))
12
+ @index_holder.attach(@label,0,1,0,1)
13
+ @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)
14
+ @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)
15
+ @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)
12
16
  set_field(field)
13
17
  signal_connect("toggled"){|me,ev| @table.parentM.changed(self)}
14
18
  signal_connect('button-press-event'){|me,ev|
@@ -43,31 +47,32 @@ class RField < Gtk::ToggleButton
43
47
 
44
48
  def set_field(field)
45
49
  @field=field
46
- @label.set_label(field["Field"])
50
+ @label.set_label(field["Field"]) unless field["Field"] == @label.label
47
51
  if f=@field["Type"].index("(")
48
52
  @field["Size"]=field["Type"][f+1 .. field["Type"].index(")") -1]
49
53
  @field["Type"]=field["Type"][0 .. f-1]
50
54
  end
51
55
 
52
56
  #set style
53
- set_style(@table.parentM.field_style[@field["Type"]]) if @table.parentM.field_style.has_key?(@field["Type"])
57
+ set_style(@table.parentM.field_style[@field["Type"]]) if @table.parentM.field_style.has_key?(@field["Type"]) && style != @table.parentM.field_style[@field["Type"]]
54
58
  #remove old images
55
- @index_holder.children.each{|ch| @index_holder.remove(ch)}
56
- #read label
57
- @index_holder.attach(@label,0,1,0,2)
58
- #add images
59
+ #@index_holder.children.each{|ch| @index_holder.remove(ch)}
60
+ #re-add label
61
+ #@index_holder.attach(@label,0,1,0,2)
62
+ #show images
63
+ show_primary=false
64
+ show_unique=false
65
+ show_index=false
59
66
  @table.indexes.each{|index|
60
- n=@index_holder.children.size-1
61
67
  if index["field"]==@field["Field"]
62
- @index_holder.attach(Gtk::Image.new(if index["name"]=="PRIMARY"
63
- then @table.parentM.img_primary.scale(10,10)
64
- else if index["unique"]
65
- then @table.parentM.img_unique.scale(10,10)
66
- else @table.parentM.img_index.scale(10,10)
67
- end
68
- end),1+n/2,1+n/2+1,n%2,n%2+1,Gtk::SHRINK)
68
+ show_primary=(index["name"]=="PRIMARY")
69
+ show_unique=(index["unique"] == true)
70
+ show_index=(index["unique"] == false)
69
71
  end
70
72
  }
73
+ @primary_img.set_visible(show_primary) if @primary_img.visible? != show_primary
74
+ @unique_img.set_visible(show_unique) if @unique_img.visible? != show_unique
75
+ @index_img.set_visible(show_index) if @index_img.visible? != show_index
71
76
  show_all
72
77
  end
73
78
 
@@ -5,20 +5,10 @@
5
5
  class Relation
6
6
  include ManqodCommon
7
7
 
8
- def initialize(parentM,rfield1,rfield2,rel_name="",rel_type="o",relation_id=nil,xi=0,yi=0,rel_custom="")
8
+ def initialize(parentM,rel_data)
9
9
  super()
10
- @rfield1=rfield1
11
- @rfield2=rfield2
12
10
  @parentM=parentM
13
- @rel_type=rel_type
14
- @rel_name=rel_name
15
- @rel_custom=rel_custom
16
- @relation_id=if relation_id then relation_id.to_i else nil;end
17
- @handle=RelationHandle.new(self,xi,yi)
18
- # if coo=rfield1.translate_coordinates(parentM.widget,0,0) and coo2=rfield2.translate_coordinates(parentM.widget,0,0)
19
- # @handle.move_me(x || 0,y || 0)
20
- # end
21
- # parentM.widget.show_all
11
+ reload(rel_data)
22
12
  @shown=false
23
13
  end
24
14
  attr_reader :rfield1, :rfield2, :parentM, :rel_type, :handle, :relation_id, :rel_name, :rel_custom
@@ -29,6 +19,20 @@ class Relation
29
19
  def y
30
20
  @handle.y
31
21
  end
22
+
23
+ def reload(rel)
24
+ @rfield1=parentM.tables[rel["src_table"]].fields[rel["src_field"]] if parentM.tables.has_key?(rel["src_table"])
25
+ @rfield2=parentM.tables[rel["dst_table"]].fields[rel["dst_field"]] if parentM.tables.has_key?(rel["dst_table"])
26
+ @rel_type=rel["rel_type"]
27
+ @rel_name=rel['rel_name']
28
+ @rel_custom=rel['rel_custom']
29
+ @relation_id=if rel["id"] then rel["id"].to_i else nil;end
30
+ if @handle then
31
+ @handle.move_me(rel["rbx"].to_f,rel["rby"].to_f)
32
+ else
33
+ @handle=RelationHandle.new(self,rel["rbx"].to_f,rel["rby"].to_f)
34
+ end
35
+ end
32
36
 
33
37
  def show_me
34
38
  parentM.widget.put(@handle,@handle.x,@handle.y) unless @shown
@@ -69,13 +73,14 @@ class Relation
69
73
  query("insert into relations set rel_type='#{@rel_type}'")
70
74
  @relation_id=qrow("select id from `relations` order by id desc limit 1")["id"]
71
75
  parentM.clear
72
- edebug("#{self} inserted","relation-builder","info")
76
+ einfo("inserted","relation-builder")
73
77
  end
74
78
  if rfield1.nil? or rfield2.nil?
75
- edebug("id:#{@relation_id} has a lost table","relation-builder","warning")
76
- else
79
+ ewarn("id:#{@relation_id} has a lost table","relation-builder")
80
+ else
77
81
  query("update relations set src_table = '#{@rfield1.table.table}', dst_table = '#{@rfield2.table.table}', src_field='#{@rfield1.field["Field"]}', dst_field='#{@rfield2.field["Field"]}', rel_type='#{@rel_type}', rbx='#{@handle.x}', rby='#{@handle.y}', rel_name='#{@rel_name}', rel_custom='#{@rel_custom}' where id='#{@relation_id}'")
78
- edebug("updated","relation-builder","info")
82
+ einfo("updated","relation-builder")
83
+ parentM.reload_server_rb
79
84
  end
80
85
  end
81
86
 
@@ -87,7 +92,8 @@ class Relation
87
92
  query("delete from relations where id='#{@relation_id}'") if !@relation_id.nil?
88
93
  parentM.relations.delete(self)
89
94
  parentM.clear
90
- @handle.destroy
95
+ @handle.destroy unless @handle.destroyed?
96
+ @parentM.reload_server_rb
91
97
  end
92
98
 
93
99
  def edit
@@ -149,7 +155,7 @@ class Relation
149
155
  end
150
156
 
151
157
  def visible?
152
- @handle.visible?
158
+ @handle && !@handle.destroyed? && @handle.visible?
153
159
  end
154
160
 
155
161
  def inspect