Class: Myform::MyForm

Inherits:
Gtk::Notebook
  • Object
show all
Includes:
Conf, GtkAttributes, ManqodCommon, Observable
Defined in:
lib/FormHolder/Form.rb

Constant Summary

Constants included from ManqodCommon

ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Conf

#get_conf, #load_conf, #save_conf, #set_conf

Methods included from GtkAttributes

#default_attribute, #gtk_attribute, #gtk_attribute_of_object, #gtkobjectid, #gtkobjecttype, #set_gtk_attribute

Methods included from ManqodCommon

#add_where, #admin_cache, #admin_rows, #backtrace_to_debug, #changed_ids_of_base, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #reconnect_manqod_db, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick

Methods included from Eprint

#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception

Constructor Details

#initialize(caller, form_id, runmode) ⇒ MyForm

Returns a new instance of MyForm.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/FormHolder/Form.rb', line 13

def initialize(caller,form_id,runmode)
@caller=caller
@table=nil
@parentselected=nil
@new_parentselected=nil
@querySQL=""
@runmode=runmode
@additional_on_update=""
@additional_on_insert=""
@batch=nil
@batch_support=false
set_id(form_id)
@items=Array.new
@tips=Gtk::Tooltips.new.enable
@tmp=Hash.new
@built=false
@multiselector=nil
super()
@tabs.sort{|a,b| a[1]['minX'].to_f <=> b[1]['minX'].to_f}.each{|t|
	tab=t[0]
	@tabs[tab]["widget"]=Gtk::Table.new(0,0,false)
	@tabs[tab]["widget"].set_border_width(0)
	@tabs[tab]["widget"].set_resize_mode(Gtk::ResizeMode::PARENT)
	@tabs[tab]["widget"].resize(1+ @tabs[tab]['maxY'].to_i-@tabs[tab]['minY'].to_i,1+ @tabs[tab]['maxX'].to_i-@tabs[tab]['minX'].to_i)
		
	append_page(@tabs[tab]["widget"],Gtk::Label.new(@tabs[tab]["title"]))
}

set_show_tabs(@tabs.size>1)
set_show_border(@tabs.size>1)
set_tab_pos(case gtk_attribute("tab-position")
	when "BOTTOM" then Gtk::PositionType::BOTTOM
	when "RIGHT" then Gtk::PositionType::RIGHT
	when "LEFT" then Gtk::PositionType::LEFT
	else Gtk::PositionType::TOP
end
)
set_enable_popup(false)
set_scrollable(true)

signal_connect('destroy'){|me| set_conf(get_id,0,"page",page)}

@is_embedded=nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



251
252
253
# File 'lib/FormHolder/Form.rb', line 251

def method_missing(sym,*args)
	findItem(sym.to_s)
end

Instance Attribute Details

#additional_on_insertObject

Returns the value of attribute additional_on_insert.



66
67
68
# File 'lib/FormHolder/Form.rb', line 66

def additional_on_insert
  @additional_on_insert
end

#additional_on_updateObject

Returns the value of attribute additional_on_update.



66
67
68
# File 'lib/FormHolder/Form.rb', line 66

def additional_on_update
  @additional_on_update
end

#agObject

Returns the value of attribute ag.



64
65
66
# File 'lib/FormHolder/Form.rb', line 64

def ag
  @ag
end

#batchObject

Returns the value of attribute batch.



58
59
60
# File 'lib/FormHolder/Form.rb', line 58

def batch
  @batch
end

#idObject

Returns the value of attribute id.



58
59
60
# File 'lib/FormHolder/Form.rb', line 58

def id
  @id
end

#is_embeddedObject

Returns the value of attribute is_embedded.



66
67
68
# File 'lib/FormHolder/Form.rb', line 66

def is_embedded
  @is_embedded
end

#moditemObject

Returns the value of attribute moditem.



61
62
63
# File 'lib/FormHolder/Form.rb', line 61

def moditem
  @moditem
end

#new_parentselectedObject

Returns the value of attribute new_parentselected.



63
64
65
# File 'lib/FormHolder/Form.rb', line 63

def new_parentselected
  @new_parentselected
end

#parentselectedObject

Returns the value of attribute parentselected.



62
63
64
# File 'lib/FormHolder/Form.rb', line 62

def parentselected
  @parentselected
end

#querySQLObject

Returns the value of attribute querySQL.



60
61
62
# File 'lib/FormHolder/Form.rb', line 60

def querySQL
  @querySQL
end

#runmodeObject

Returns the value of attribute runmode.



59
60
61
# File 'lib/FormHolder/Form.rb', line 59

def runmode
  @runmode
end

#tableObject (readonly)

Returns the value of attribute table.



65
66
67
# File 'lib/FormHolder/Form.rb', line 65

def table
  @table
end

#titleObject

Returns the value of attribute title.



58
59
60
# File 'lib/FormHolder/Form.rb', line 58

def title
  @title
end

#tmpObject (readonly)

Returns the value of attribute tmp.



65
66
67
# File 'lib/FormHolder/Form.rb', line 65

def tmp
  @tmp
end

Instance Method Details

#adminObject



86
87
88
89
90
91
92
# File 'lib/FormHolder/Form.rb', line 86

def admin
	if wysiwygf?
		ManqodDB.instance.manqod_db
		else
	ManqodDB.instance.manqod_db.admin
end
end

#admin_qrow(sql, with_table = false) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/FormHolder/Form.rb', line 176

def admin_qrow(sql,with_table=false)
	if wysiwygf?
	begin
			ManqodDB.instance.manqod_db.qrow(sql,with_table)
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
		else
	begin
			ManqodDB.instance.manqod_db.admin.qrow(sql,with_table)
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
	end
end

#apply_changes(caller) ⇒ Object

update



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/FormHolder/Form.rb', line 372

def apply_changes(caller)
	s="";
	#check if required items are filled
	@items.each { |item| if item.editable && item.required && (item.text==nil || (item.text!=nil && (item.text.length==0 || (item.text=="-1" && ['gtk_const_combo','gtk_combo','gtk_combo_wn','gtk_list'].include?(item.type))))) then s=s+item.description+"?\n";end}
	if s.length >0
		#there were some unfilled but required form items
		warner=Gtk::MessageDialog.new(get_ancestor(Gtk::Window),Gtk::Dialog::DESTROY_WITH_PARENT,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::BUTTONS_OK,s)
		warner.set_image(Gtk::Image.new(Gtk::Stock::FIND_AND_REPLACE,Gtk::IconSize::DIALOG))
		warner.show_all.run
		warner.destroy
		return -1
	else
		run_events(get_id,'form-OnApply-beforeSQL')
		#/event OnApply
		if @runmode
			items_to_update=0
			isql=""
			#build the query
			if @multiselector && @multiselector.toggled_ids.size > 0
				sql="insert into #{@table} (#{@multiselector.item['data']},"
				@items.each { |item|
					sql="#{sql}#{item.data}," if item.text && (item.include_in_query_building || (item.include_in_query_building.nil? && item.editable?)) && !item.multiselector?
				}
				sql=sql[0 .. sql.rindex(',')-1] unless sql.rindex(',').nil? #strip last ,
				autoadd_child_key=(parentM.class.name == "MyEditableList" && parentM.list_model.key_child && !(sql.index(" #{parentM.list_model.key_child} ")))
				#adding child_key/parent_key
				if autoadd_child_key
					begin
						sql="#{sql}, #{parentM.list_model.key_child}"
					rescue =>err
						eerror("can't auto-add child_key: #{parentM.list_model.key_child} => #{err}","form")
					end
				end

				sql="#{sql}) values "
				
				@multiselector.toggled_ids.each{|tid|
					isql="(#{tid},"
					@items.each { |item|
						isql="#{isql} '#{escape_string(item.text)}'," if item.text && (item.include_in_query_building || (item.include_in_query_building.nil? && item.editable?)) && !item.multiselector?
					}
					isql=isql[0 .. isql.rindex(',')-1] unless isql.rindex(',').nil? #strip last ,
					if autoadd_child_key
						begin
							isql="#{isql}, '#{parentM.list_model.parentM.iter_at_cursor[parentM.list_model.column_of_parent_key]}'" if parentM.list_model.key_child.index(".")==nil || parentM.list_model.key_child.index("#{@table}.")
						rescue => err
							eerror("can't auto-add child_key: #{parentM.list_model.key_child} => #{err}","form")
						end
					end
					isql="#{isql})"
					sql="#{sql} #{isql},"
				}
				sql=sql[0 .. sql.rindex(',')-1] unless sql.rindex(',').nil? #strip last ,
			else
				@items.each { |item|
					if item.text && (item.include_in_query_building || (item.include_in_query_building.nil? && item.editable?))
						isql="#{isql} #{item.data} = '#{escape_string(item.text)}' ,"
						items_to_update+=1
					end
				}
			end
			if (items_to_update != 0) or (@runmode=='remove')
				isql=isql[0 .. isql.rindex(',')-1] if !isql.rindex(',').nil?
				case @runmode
					when 'add','copy'
						sql="insert into #{@table} set #{isql}";
						sql=sql+", "+eeval("\"#{@additional_on_insert}\"") if @additional_on_insert.length>0
						#auto-adding child_key
						if parentM.class.name == "MyEditableList" 
							#adding child_key/parent_key
							if parentM.list_model.key_child  # and ck=parentM.list_model.key_child[parentM.list_model.key_child.rindex(".")+1 .. parentM.list_model.key_child.length]
								unless sql.index(" #{parentM.list_model.key_child} ")
									begin
										sql="#{sql}, #{parentM.list_model.key_child} ='#{parentM.list_model.parentM.iter_at_cursor[parentM.list_model.column_of_parent_key]}'" if parentM.list_model.key_child.index(".")==nil || parentM.list_model.key_child.index("#{@table}.")
									rescue =>err
										eerror("can't auto-add child_key: #{parentM.list_model.key_child} => #{err}","form")
									end
								end
							end
							#adding child_key2/parent_key2
							if parentM.list_model.key_child2 # and ck=parentM.list_model.key_child2[parentM.list_model.key_child2.rindex(".")+1 .. parentM.list_model.key_child2.length]
								unless sql.index(" #{parentM.list_model.key_child2} ")
									begin
										sql="#{sql}, #{parentM.list_model.key_child2} ='#{parentM.list_model.parentM.iter_at_cursor[parentM.list_model.column_of_parent_key2]}'"  if parentM.list_model.key_child2.index(".")==nil || parentM.list_model.key_child2.index("#{@table}.")
									rescue =>err
										eerror("can't auto-add child_key2: #{err}","form")
									end
								end
							end
						end

					when 'modify'
						sql="update `#{@table}` set #{isql}";
						sql="#{sql}, "+eeval("\"#{@additional_on_update}\"") if @additional_on_update.length>0;
						sql="#{sql} where #{@list_key} #{batch? ? "in (#{batch.join(",")})": "= '#{@parentselected}'"}"
					when 'remove'
						sql="delete from `#{@table}` where #{@list_key}='#{@parentselected}'"
				end
			end

			einfo(sql,"form")
			ret=if sql && query(sql) then 
				-1 #error unless nil?
			else
				if @runmode == 'modify' then 
					@new_parentselected=@parentselected
				else 
					@new_parentselected=qrow("select #{@list_key} from #{table} order by #{@list_key} desc limit 1")[@list_key]
				end
			end

			run_events(get_id,'form-OnApply-afterSQL')
			@parentselected=new_parentselected
			ret=@parentselected if ret.nil?

			if @multiselector && @multiselector.toggled_ids.size>0
				new_ids=Array.new
				rows("select #{@list_key} from #{table} order by #{@list_key} desc limit #{@multiselector.toggled_ids.size}").each{|newid| new_ids.push(newid[@list_key].to_i)}
				changed_ids_of_base(table,new_ids)
				else
				if batch?
					batch.each{|b| changed_ids_of_base(table,b.to_i)}
					else
					changed_ids_of_base(table,@parentselected.to_i)
				end
			end
			changed
			notify_observers(self)

			return ret.to_i
		end
	end
end

#attach(wg) ⇒ Object



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/FormHolder/Form.rb', line 510

def attach(wg)
	yshrink=wg.gtk_attribute('vertical-shrink') == 'true'
	yfill=yexpand=['gtk_timestamp','gtk_calendar','gtk_const_radio','gtk_field_list','gtk_multiline','gtk_source','gtk_list','gtk_editable_list','filesave','fileload','qbuilder'].include?(wg.item['gtktype'])
	yfill=wg.gtk_attribute('vertical-fill') == 'true' if wg.gtk_attribute('vertical-fill')
	yexpand=wg.gtk_attribute('vertical-expand') == 'true' if wg.gtk_attribute('vertical-expand')
	yopts=(yfill ? Gtk::FILL : 0)|(yexpand ? Gtk::EXPAND : 0)|(yshrink ? Gtk::SHRINK : 0)
	xexpand=(wg.gtk_attribute('horizontal-expand')||'true') == 'true'
	xfill=(wg.gtk_attribute('horizontal-fill')||'true') == 'true'
	xshrink=(wg.gtk_attribute('horizontal-shrink')||'false') == 'true'
	xopts=(xfill ? Gtk::AttachOptions::FILL : 0)|(xexpand ? Gtk::AttachOptions::EXPAND : 0)|(xshrink ? Gtk::AttachOptions::SHRINK : 0)
	wg.item['x']='0' if wg.item['x'].to_i<0
	wg.item['y']='0' if wg.item['y'].to_i<0
	wg.item['xspan']='1' if wg.item['xspan'].to_i<1
	wg.item['yspan']='1' if wg.item['yspan'].to_i<1
	@tabs[wg.item["tab"]]["widget"].attach(wg.widget,wg.item['x'].to_i,wg.item['x'].to_i+wg.item['xspan'].to_i,wg.item['y'].to_i,wg.item['y'].to_i+wg.item['yspan'].to_i,xopts,yopts)
end

#batch?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/FormHolder/Form.rb', line 212

def batch?
	batch_support? && batch.class == Array
end

#batch_support?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'lib/FormHolder/Form.rb', line 208

def batch_support?
	@batch_support
end

#cacheObject



102
103
104
105
106
107
108
# File 'lib/FormHolder/Form.rb', line 102

def cache
if wysiwygf?
	ManqodDB.instance.ccache
	else
	ManqodDB.instance.cache
end
end

#clientObject



94
95
96
97
98
99
100
# File 'lib/FormHolder/Form.rb', line 94

def client
	if wysiwygf?
		ManqodDB.instance.manqod_db.client
		else
	ManqodDB.instance.manqod_db
end
end

#embedd?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
# File 'lib/FormHolder/Form.rb', line 71

def embedd?
	if @moditem && @moditem['on_embed'].length >0 
		eeval(@moditem['on_embed'],self)
		else 
		true
	end
end

#findItem(data) ⇒ Object



244
245
246
247
248
249
# File 'lib/FormHolder/Form.rb', line 244

def findItem(data)
ret=nil
@items.each{ |item| ret=item if item.data == data or item.data == "#{@table}.#{data}"}
warn("form item: #{data} not found","tried [#{data}], [#{@table}.#{data}]","form",ERROR) if ret.nil?
ret
end

#form_holderObject



82
83
84
# File 'lib/FormHolder/Form.rb', line 82

def form_holder
	@caller
end

#get_idObject



216
217
218
# File 'lib/FormHolder/Form.rb', line 216

def get_id
@form_id
end

#itemsObject



241
242
243
# File 'lib/FormHolder/Form.rb', line 241

def items
@items
end

#itemValue(data) ⇒ Object Also known as: item_value



255
256
257
258
259
260
261
# File 'lib/FormHolder/Form.rb', line 255

def itemValue(data)
item=findItem(data)
ret=""
ret=item.text if item and item.text
edebug("itemValue: #{data.inspect} : #{item.inspect} text:#{item.text unless item.nil?} return: #{ret}","form")
ret
end

#parentMObject



238
239
240
# File 'lib/FormHolder/Form.rb', line 238

def parentM
  @caller.parentM
end

#qrow(sql, with_table = false) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/FormHolder/Form.rb', line 160

def qrow(sql,with_table=false)
	if wysiwygf?
	begin
			ManqodDB.instance.manqod_db.client.qrow(sql,with_table)
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
		else
	begin
			ManqodDB.instance.manqod_db.qrow(sql,with_table)
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
	end
end

#query(sql) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/FormHolder/Form.rb', line 140

def query(sql)
	if wysiwygf?
		begin
			ret=ManqodDB.instance.manqod_db.client.query(sql)
			tell_exception("Database Error","Duplicate entry","sql","error") if ret == -1
		ret
			rescue =>err
			retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
		end
		else
		begin
			ret=ManqodDB.instance.manqod_db.query(sql) 
			tell_exception("Database Error","Duplicate entry","sql","error") if ret == -1
		ret
			rescue =>err 
			retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
		end
end
end

#reattach(wg) ⇒ Object



506
507
508
509
# File 'lib/FormHolder/Form.rb', line 506

def reattach(wg)
	@tabs[wg.item["tab"]]["widget"].remove(wg.widget)
	attach(wg)
end

#rows(sql) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/FormHolder/Form.rb', line 192

def rows(sql)
	if wysiwygf?
 	begin
			ManqodDB.instance.manqod_db.client.rows(sql){|row| yield row}
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
		else
 	begin
			ManqodDB.instance.manqod_db.rows(sql){|row| yield row}
			rescue =>err
		retry if tell_exception("error in server connection",backtrace_to_debug(err),"server","error",false,true,"#{err}")
	end
end
end

#set_ag(ag) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/FormHolder/Form.rb', line 110

def set_ag(ag)
@ag=ag
ag.connect(Gdk::Keyval::GDK_KEY_space, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE){
	focused=@caller.holder.focus.parent
	if focused && ["MySourceView"].include?(focused.class.name)
		ret=focused.test_content
		if ret
			tell_exception("query is ok","fields: #{ret.num_fields}\n rows: #{ret.num_rows}","sql","normal",false)
		end
	end
}
ag.connect(Gdk::Keyval::GDK_KEY_f, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE){
	unless @caller.holder.focus.nil?
		if (focused=@caller.holder.focus.parent) && ["MyRendererMultiline","MySourceView"].include?(focused.class.name) then 
			focused.run_search(self)
		end
		if (focused=@caller.holder.focus.parent) && ["MyRendererComboWithNew","MyRendererCombo","MyRendererConstCombo","FieldCombo"].include?(focused.class.name) then
			focused.model.filterer.run(self)
		end
		if (focused=@caller.holder.focus.parent.parent) && ["MyRendererList","FieldList"].include?(focused.class.name) then 
			focused.model.filterer.run(self)
		end
	end
}
end

#set_id(form_id) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/FormHolder/Form.rb', line 219

def set_id(form_id)
@form_id=form_id
begin
	@moditem=cache.get("#{get_id}moditem")
	moditem_attributes=cache.get("#{get_id}attributes")
	@querySQL=moditem_attributes[:querySQL]
	@table=moditem_attributes[:table]
	@tabs=moditem_attributes[:tabs]
	@title=@moditem['display']
	@batch_support=moditem_attributes[:batch]
rescue => err
	retry if warn("can't load form: id=[#{@form_id}]",err,nil,"error",nil,true,backtrace_to_debug(err))
end
self
end

#set_multiselector(widget) ⇒ Object



136
137
138
# File 'lib/FormHolder/Form.rb', line 136

def set_multiselector(widget)
	@multiselector=widget
end

#set_runmode(runmode) ⇒ Object



234
235
236
237
# File 'lib/FormHolder/Form.rb', line 234

def set_runmode(runmode)
@runmode=runmode
self
end

#to_sObject



264
265
266
# File 'lib/FormHolder/Form.rb', line 264

def to_s
	"Form id:#{get_id}(#{@title}[#{runmode}#{@multiselector ? "|multiselector":""}:#{@parentselected}])"
end

#update(notifier, pid = @parentselected, rm = @runmode) ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/FormHolder/Form.rb', line 268

def update(notifier, pid=@parentselected,rm=@runmode)
	einfo("notification from #{notifier} for [#{pid}]")
@items.each{|i| i.unset_default} if @runmode!=rm && @built
	@runmode=rm
	@parentselected=pid
case notifier.class.name 
	when 'MyEditableList'
#				@parentselected=notifier.get_cursor_id
		@list_key=parentM.list_model.list_key
		if  ['add','modify'].include?(runmode)
			@runmode='add'
			@runmode='modify' if @parentselected and @parentselected.to_i>=0
		end
	when 'MyButton'
		@list_key="id" #FIXME
#				@runmode=notifier.function
#				@parentselected=notifier.parentselected
 	when 'MyRendererComboWithNew','MyRendererList', 'MyRendererButton'
		@list_key="id" #FIXME
#				@parentselected=notifier.text
	when 'MyTouchWindow'
		@runmode='add'
	when 'NilClass'
		#we just run, currently known to call MyForm.update(nil) is from the Touchscreen stuff, kinda reinitialize
	when 'BarMenuItem', 'ButtonMenuItem'
#				@runmode='dry'
##				set_id(notifier.target)
	else
		edebug("unknown routing: "+notifier.class.name,"form","warning")
end


unless @built
	edebug("building","form")
	if @runmode then
		@items.each{ |item| remove(item)} #destroy previous items
		if @caller.holder.class.name=='Gtk::Dialog'
			@caller.holder.title=@title
			pw=@caller.get_ancestor(MyWindow)
			if pw.class.name=="MyWindow"
				@caller.holder.set_icon(pw.mymenu.last.image.pixbuf)
				else
				@caller.holder.set_icon(pw.icon)
			end
		end
		@additional_on_update=String.new(@moditem['additional_on_update'])
		@additional_on_insert=String.new(@moditem['additional_on_insert'])

	
		@items.clear
		i=cache.get("#{get_id}items")
		i.each{|itemp|
			item=MyInputHolder.new(itemp,self)
			@tips.set_tip(item.eventbox,itemp['hint'],'extra hint')
			attach(item)
			@items << item
		}
	
		#setting observers, dependency tree built from itemVaule()-s in the SQLs
		@items.each{|item|
			q=String.new(item.querySQL)
			while first=q.index("itemValue(")
				var_first=first+"itemValue(".length
				q=q[var_first .. q.length]
				last=q.index(")")-1
				dep=q[0 .. last].gsub("'","")
				if driverItem=findItem(dep)
					edebug(item.data+" depends on "+driverItem.data,"form","info")
					driverItem.add_observer(item)
				end
				q=q[last .. q.length]
			end
		}
	end
end

 #if modify or copy than we load the default items' data
 case @runmode
	when 'modify','copy','info' then 
		itemdata=qrow(eeval("\"#{@querySQL}\""),true)
 end
 @items.each{|i| 
 	default_data=nil
	if itemdata then 
		default_data=itemdata[i.data] if itemdata.has_key?(i.data)
		default_data=itemdata["#{@table}.#{i.data}"] if itemdata.has_key?("#{@table}.#{i.data}")
	else
		case i.type
			when 'gtk_combo','gtk_combo_wn','gtk_const_combo' then default_data="-1"
			else default_data=""
		end
	end
	i.item["initial"]=default_data
}

run_events(get_id,'form-OnUpdate')

@items.each{|i| i.update(self,i.default_set? ? i.default : i.initial )}
@built=true

show_all
set_page(get_conf(get_id,0,"page").to_i) if get_conf(get_id,0,"page")
end

#wysiwygf?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/FormHolder/Form.rb', line 78

def wysiwygf?
	form_holder.runmode == "wysiwygf"
end