arcadia 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +122 -0
- data/arcadia.rb +748 -0
- data/base/a-contracts.rb +253 -0
- data/base/a-ext.rb +360 -0
- data/base/a-libs.rb +852 -0
- data/base/a-utils.rb +780 -0
- data/conf/arcadia.conf +198 -0
- data/conf/arcadia.init.rb +13 -0
- data/conf/arcadia.res.rb +1211 -0
- data/ext/ae-debug/ae-debug.conf +7 -0
- data/ext/ae-debug/ae-debug.rb +582 -0
- data/ext/ae-debug/debug1.57.rb +998 -0
- data/ext/ae-editor/ae-editor.conf +92 -0
- data/ext/ae-editor/ae-editor.rb +1744 -0
- data/ext/ae-event-log/ae-event-log.conf +5 -0
- data/ext/ae-event-log/ae-event-log.rb +44 -0
- data/ext/ae-file-history/ae-file-history.conf +17 -0
- data/ext/ae-file-history/ae-file-history.rb +280 -0
- data/ext/ae-inspector/ae-inspector.conf +7 -0
- data/ext/ae-inspector/ae-inspector.rb +1519 -0
- data/ext/ae-output-event/ae-output-event.conf +15 -0
- data/ext/ae-output/ae-output.conf +14 -0
- data/ext/ae-output/ae-output.rb +162 -0
- data/ext/ae-palette/ae-palette.conf +7 -0
- data/ext/ae-palette/ae-palette.rb +319 -0
- data/ext/ae-shell/ae-shell.conf +11 -0
- data/ext/ae-shell/ae-shell.rb +54 -0
- data/lib/tk/al-tk.rb +3078 -0
- data/lib/tk/al-tk.res.rb +217 -0
- data/lib/tk/al-tkarcadia.rb +26 -0
- data/lib/tk/al-tkcustom.rb +70 -0
- data/lib/tkext/al-bwidget.rb +194 -0
- data/lib/tkext/al-iwidgets.rb +25 -0
- data/lib/tkext/al-tile.rb +173 -0
- data/lib/tkext/al-tktable.rb +48 -0
- metadata +90 -0
data/base/a-libs.rb
ADDED
@@ -0,0 +1,852 @@
|
|
1
|
+
#
|
2
|
+
# a-libs.rb - Arcadia Ruby ide
|
3
|
+
# by Antonio Galeone <antonio-galeone@rubyforge.org>
|
4
|
+
#
|
5
|
+
|
6
|
+
class ArcadiaLib
|
7
|
+
attr_reader :arcadia_lib_params
|
8
|
+
attr_reader :classes
|
9
|
+
|
10
|
+
def initialize(_arcadia, _arcadia_lib_params)
|
11
|
+
@arcadia = _arcadia
|
12
|
+
@arcadia_lib_params = _arcadia_lib_params
|
13
|
+
@classes = Array.new
|
14
|
+
@requires = Array.new
|
15
|
+
@require4class = Hash.new
|
16
|
+
register_classes
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_class(arcadia_class=nil, _is_top=false)
|
20
|
+
_self = self
|
21
|
+
if arcadia_class
|
22
|
+
class << arcadia_class
|
23
|
+
def library=(lib)
|
24
|
+
@library = lib
|
25
|
+
end
|
26
|
+
def library
|
27
|
+
@library
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
arcadia_class.library = self
|
32
|
+
if _is_top
|
33
|
+
class << arcadia_class
|
34
|
+
def is_top
|
35
|
+
true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
class << arcadia_class
|
40
|
+
def is_top
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@classes << arcadia_class
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
protected :add_class
|
50
|
+
def register_classes
|
51
|
+
end
|
52
|
+
protected :register_classes
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
class ArcadiaLibs
|
58
|
+
attr_reader :arcadia
|
59
|
+
ArcadiaLibParams = Struct.new( "ArcadiaLibParams",
|
60
|
+
:name,
|
61
|
+
:source,
|
62
|
+
:require,
|
63
|
+
:classLib
|
64
|
+
)
|
65
|
+
|
66
|
+
def initialize(_arcadia)
|
67
|
+
@arcadia = _arcadia
|
68
|
+
@@libs = Array.new
|
69
|
+
end
|
70
|
+
|
71
|
+
def list
|
72
|
+
@@libs
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_lib(arcadia_lib_params=nil)
|
76
|
+
if arcadia_lib_params
|
77
|
+
@@libs << arcadia_lib_params.classLib.new(@arcadia,arcadia_lib_params)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def ArcadiaLibs.check_dictionary
|
82
|
+
if !defined?(@@wrappers_for_classes)
|
83
|
+
@@wrappers_for_classes = Hash.new
|
84
|
+
@@libs.each{|_lib|
|
85
|
+
_lib.classes.each{|_class|
|
86
|
+
@@wrappers_for_classes[_class.class_wrapped]=_class
|
87
|
+
}
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def ArcadiaLibs.wrapper_class(_class)
|
93
|
+
check_dictionary
|
94
|
+
return @@wrappers_for_classes[_class]
|
95
|
+
end
|
96
|
+
|
97
|
+
def ArcadiaLibs.copy_wrapper_of_class_to_class(_of_class, _to_class)
|
98
|
+
check_dictionary
|
99
|
+
@@wrappers_for_classes[_to_class] = @@wrappers_for_classes[_of_class]
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
class PropType
|
105
|
+
def initialize
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class StringType < PropType
|
110
|
+
def initialize
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class NumberType < PropType
|
115
|
+
def initialize
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class ProcType < PropType
|
120
|
+
def initialize(_proc)
|
121
|
+
@p = _proc
|
122
|
+
end
|
123
|
+
def procReturn
|
124
|
+
@p.call
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class EnumType < PropType
|
129
|
+
attr_reader :values
|
130
|
+
def initialize(*args)
|
131
|
+
if args.class == Array
|
132
|
+
@values = *args
|
133
|
+
else
|
134
|
+
@values = [*args]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
class EnumProcType < EnumType
|
140
|
+
def initialize(_proc, *args)
|
141
|
+
@p = _proc
|
142
|
+
super(*args)
|
143
|
+
end
|
144
|
+
def procReturn
|
145
|
+
@p.call
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class ObjEnumProcType < EnumProcType
|
150
|
+
attr_reader :it
|
151
|
+
def initialize(_obj, _proc, *args)
|
152
|
+
@it = me
|
153
|
+
super(_proc, *args)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
class AGSniffer
|
158
|
+
attr_reader :sons
|
159
|
+
def initialize(_obj)
|
160
|
+
@obj = _obj
|
161
|
+
@sons = Array.new
|
162
|
+
find_sons
|
163
|
+
end
|
164
|
+
def find_sons
|
165
|
+
|
166
|
+
end
|
167
|
+
def has_sons?
|
168
|
+
@sons.length > 0
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class AGRenderer
|
173
|
+
#INDENT_UNIT = "\t"
|
174
|
+
INDENT_UNIT = "\s"*2
|
175
|
+
def initialize(_agobj=nil)
|
176
|
+
if _agobj
|
177
|
+
@agobj = _agobj
|
178
|
+
else
|
179
|
+
exit
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def class_code(_ind=0, _args=nil)
|
184
|
+
args = render_on_create_properties(_args)
|
185
|
+
return class_begin(_ind, args), class_hinner_begin(_ind+1), class_hinner_end(_ind+1), class_end(_ind)
|
186
|
+
end
|
187
|
+
|
188
|
+
def class_begin(_ind=0, _args=nil)
|
189
|
+
code = INDENT_UNIT*_ind,'class ', @agobj.getInstanceClass, ' < ', @agobj.getObjClass
|
190
|
+
code_attr=''
|
191
|
+
code_hinner_class=''
|
192
|
+
@agobj.sons.each {|value|
|
193
|
+
if (value.sons.length > 0)
|
194
|
+
code_hinner_class = code_hinner_class,"\n", value.renderer.class_code(_ind+1)
|
195
|
+
end
|
196
|
+
code_attr = code_attr,"\n",INDENT_UNIT*(_ind+1),'attr_reader :', value.i_name
|
197
|
+
}
|
198
|
+
code = code,code_attr if (code_attr.length >0)
|
199
|
+
code = code,code_hinner_class,"\n" if (code_hinner_class.length >0)
|
200
|
+
code = code,"\n", INDENT_UNIT*(_ind+1),"def initialize(parent=nil, *args)\n"
|
201
|
+
if _args
|
202
|
+
code = code, INDENT_UNIT*(_ind+2),"super(parent, "+_args+")\n"
|
203
|
+
else
|
204
|
+
code = code, INDENT_UNIT*(_ind+2),"super(parent, *args)\n"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def class_hinner_begin(_ind=0)
|
209
|
+
return render_family(_ind+1,'property','default')
|
210
|
+
end
|
211
|
+
|
212
|
+
def class_hinner_end(_ind=0)
|
213
|
+
code = ''
|
214
|
+
@agobj.sons.each {|value|
|
215
|
+
if (value.sons.length > 0)
|
216
|
+
code = code, value.renderer.obj_begin(_ind+1),"\n"
|
217
|
+
else
|
218
|
+
code = code, value.renderer.obj_code(_ind+1),"\n"
|
219
|
+
end
|
220
|
+
}
|
221
|
+
return code.to_s
|
222
|
+
end
|
223
|
+
|
224
|
+
def class_end(_ind=0)
|
225
|
+
code = code, "\n", INDENT_UNIT*(_ind+1),"end\n",INDENT_UNIT*(_ind),"end"
|
226
|
+
return code.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
def obj_code(_ind=0)
|
230
|
+
return obj_begin(_ind), "{ ",obj_hinner_begin(_ind+1), obj_hinner_end(_ind+1), obj_end(_ind),"}"
|
231
|
+
end
|
232
|
+
|
233
|
+
def obj_begin(_ind=0)
|
234
|
+
_s_ind = INDENT_UNIT*_ind
|
235
|
+
if _s_ind == nil
|
236
|
+
_s_ind = ''
|
237
|
+
end
|
238
|
+
if @agobj.sons.length > 0
|
239
|
+
_class = @agobj.getInstanceClass
|
240
|
+
else
|
241
|
+
_class = @agobj.class.class_wrapped.to_s
|
242
|
+
end
|
243
|
+
return "\n",_s_ind+'@'+@agobj.i_name+' = '+_class+'.new(self)'
|
244
|
+
end
|
245
|
+
|
246
|
+
def obj_hinner_begin(_ind=0)
|
247
|
+
return class_hinner_begin(_ind)
|
248
|
+
end
|
249
|
+
|
250
|
+
def obj_hinner_end(_ind=0)
|
251
|
+
code = ''
|
252
|
+
_s_attr_reader = ''
|
253
|
+
_s_ind = INDENT_UNIT*_ind
|
254
|
+
_s_attr_reader = ''
|
255
|
+
@agobj.sons.each{|son|
|
256
|
+
code = code , "\n", son.renderer.obj_code(_ind)
|
257
|
+
_s_attr_reader = _s_attr_reader, "\n", _s_ind,INDENT_UNIT*2 ,':',son.i_name
|
258
|
+
}
|
259
|
+
if code.length > 0 then
|
260
|
+
code = code , "\n",_s_ind,"class << self"
|
261
|
+
code = code , "\n",_s_ind," attr_reader",_s_attr_reader
|
262
|
+
code = code , "\n",_s_ind,"end"
|
263
|
+
end
|
264
|
+
return code
|
265
|
+
end
|
266
|
+
|
267
|
+
def obj_end(_ind=0)
|
268
|
+
_s_ind = INDENT_UNIT*_ind
|
269
|
+
if _s_ind == nil
|
270
|
+
_s_ind = ''
|
271
|
+
end
|
272
|
+
_s_ind
|
273
|
+
end
|
274
|
+
|
275
|
+
def render_on_create_properties(_args = nil)
|
276
|
+
ret = nil
|
277
|
+
if _args
|
278
|
+
ret = ''
|
279
|
+
_args.each{|k,v|
|
280
|
+
if ret.strip.length > 0
|
281
|
+
ret = ret + ', '
|
282
|
+
end
|
283
|
+
ret = ret + "'"+k+"' => '"+v+"'"
|
284
|
+
}
|
285
|
+
end
|
286
|
+
aprop = @agobj.props_kinds['property']['on-create']
|
287
|
+
if aprop
|
288
|
+
ret = '' if ret == nil
|
289
|
+
aprop.each{|name|
|
290
|
+
next if _args && _args.has_key?(name)
|
291
|
+
prop = @agobj.props['property'][name]
|
292
|
+
_val = render_value(prop, 'property')
|
293
|
+
if _val == nil
|
294
|
+
next
|
295
|
+
end
|
296
|
+
if ret.strip.length > 0
|
297
|
+
ret = ret +', '
|
298
|
+
end
|
299
|
+
#Tk.messageBox('message'=>_val.to_s)
|
300
|
+
if (prop['def'] == '')||(prop['def'] == nil) #significa che possiamo inserire nel blocco come chiave,valore
|
301
|
+
ret = ret + "'"+ prop['name'] +"' => "+ _val.to_s
|
302
|
+
elsif (prop['def'] != nil)&&(prop['def'] != 'nodef')
|
303
|
+
ret = ret + prop['def'].call(_val.to_s)
|
304
|
+
end
|
305
|
+
}
|
306
|
+
end
|
307
|
+
ret = nil if ret != nil && ret.strip.length == 0
|
308
|
+
return ret
|
309
|
+
end
|
310
|
+
|
311
|
+
def render_value(_prop, _family)
|
312
|
+
#Tk.messageBox('message'=>_prop['name'])
|
313
|
+
return nil if _prop == nil
|
314
|
+
_val = _prop['get'].call
|
315
|
+
|
316
|
+
if @agobj.defaults_values[@agobj.class][_family][_prop['name']]==_val
|
317
|
+
return nil
|
318
|
+
end
|
319
|
+
|
320
|
+
_prop['def_string'] != nil && !_prop['def_string'] ? is_string = false: is_string = true
|
321
|
+
|
322
|
+
if _val.kind_of?(String) && is_string
|
323
|
+
_val = "'",_val,"'"
|
324
|
+
elsif _val != nil
|
325
|
+
_val = _val.to_s
|
326
|
+
end
|
327
|
+
#Tk.messageBox('message'=>_val)
|
328
|
+
return _val
|
329
|
+
end
|
330
|
+
|
331
|
+
def render_value_default(_prop, _family)
|
332
|
+
return nil if _prop == nil
|
333
|
+
_val = _prop['value']
|
334
|
+
_prop['def_string'] != nil && !_prop['def_string'] ? is_string = false: is_string = true
|
335
|
+
if _val.kind_of?(String) && is_string
|
336
|
+
_val = "'",_val,"'"
|
337
|
+
elsif _val != nil
|
338
|
+
_val = _val.to_s
|
339
|
+
end
|
340
|
+
return _val
|
341
|
+
end
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
def render_family(_ind=0, _family='', _kind=nil, _default=false)
|
346
|
+
if @agobj.props[_family] == nil
|
347
|
+
return ''
|
348
|
+
end
|
349
|
+
_s_block = ''
|
350
|
+
_s_ind = INDENT_UNIT*_ind
|
351
|
+
|
352
|
+
render_group = @agobj.props_def[_family] != nil
|
353
|
+
if render_group
|
354
|
+
@agobj.props_def[_family]['sep'] != nil ? render_group_sep = @agobj.props_def[_family]['sep']:render_group_sep = ''
|
355
|
+
@agobj.props_def[_family]['default'] != nil ? render_group_default = @agobj.props_def[_family]['default']:render_group_default = proc{|nome,x| "'#{nome}' #{x}"}
|
356
|
+
end
|
357
|
+
if _kind == nil
|
358
|
+
properties_list = Array.new
|
359
|
+
@agobj.props_kinds[_family].each_value{|p|
|
360
|
+
properties_list.concat(p)
|
361
|
+
}
|
362
|
+
else
|
363
|
+
properties_list = @agobj.props_kinds[_family][_kind]
|
364
|
+
end
|
365
|
+
properties_list.each{|name|
|
366
|
+
value = @agobj.props[_family][name]
|
367
|
+
if _default
|
368
|
+
_val = render_value_default(value, _family)
|
369
|
+
else
|
370
|
+
_val = render_value(value, _family)
|
371
|
+
end
|
372
|
+
if _val == nil
|
373
|
+
next
|
374
|
+
end
|
375
|
+
|
376
|
+
if render_group
|
377
|
+
if _s_block.length > 0
|
378
|
+
_s_block = _s_block, render_group_sep
|
379
|
+
end
|
380
|
+
_s_block = _s_block,"\n",_s_ind, INDENT_UNIT
|
381
|
+
if (value['def'] == '')||(value['def'] == nil) #significa che possiamo inserire nel blocco come chiave,valore
|
382
|
+
_s_block = _s_block, render_group_default.call(value['name'] , _val)
|
383
|
+
elsif (value['def'] != nil)&&(value['def'] != 'nodef')
|
384
|
+
_s_block = _s_block, value['def'].call(_val)
|
385
|
+
end
|
386
|
+
else
|
387
|
+
if (value['def'] == '')||(value['def'] == nil) #significa che possiamo inserire nel blocco come chiave,valore
|
388
|
+
_s_block = _s_block, "\n",_s_ind , value['name'] ,INDENT_UNIT , _val
|
389
|
+
elsif (value['def'] != nil)&&(value['def'] != 'nodef')
|
390
|
+
_s_block = _s_block , "\n", _s_ind ,value['def'].call(_val)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
}
|
394
|
+
|
395
|
+
if render_group
|
396
|
+
_ss_block = "\n",_s_ind
|
397
|
+
if @agobj.props_def[_family]['path'] != nil
|
398
|
+
_ss_block = _ss_block, @agobj.props_def[_family]['path']
|
399
|
+
end
|
400
|
+
_ss_block = _ss_block, @agobj.props_def[_family]['before'], _s_block, "\n",_s_ind, @agobj.props_def[_family]['after']
|
401
|
+
else
|
402
|
+
_ss_block = _s_block
|
403
|
+
end
|
404
|
+
#p _ss_block.to_s
|
405
|
+
return _ss_block
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
class AG
|
410
|
+
attr_reader :props, :props_def, :i_name, :i_ag, :ag_parent, :obj_class, :obj
|
411
|
+
attr_reader :sons, :renderer
|
412
|
+
attr_reader :sniffer
|
413
|
+
attr_reader :persistent
|
414
|
+
#attr_reader :props_seq
|
415
|
+
attr_reader :props_kinds
|
416
|
+
attr_writer :props, :i_name, :i_ag
|
417
|
+
|
418
|
+
def initialize(_ag_parent = nil, _object = nil)
|
419
|
+
@ag_parent = _ag_parent
|
420
|
+
if _object == nil
|
421
|
+
new_object
|
422
|
+
else
|
423
|
+
passed_object(_object)
|
424
|
+
end
|
425
|
+
|
426
|
+
@obj_class = self.class.near_class_wrapped(@obj)
|
427
|
+
@sons = Array.new
|
428
|
+
@renderer=self.class.class_renderer.new(self)
|
429
|
+
@sniffer=self.class.class_sniffer.new(@obj)
|
430
|
+
yield(self) if block_given?
|
431
|
+
if !defined?(@i_name)
|
432
|
+
@i_name = self.class.class_wrapped.to_s.gsub('::','_') + new_id
|
433
|
+
@i_name = @i_name.sub(/^./) { $&.downcase}
|
434
|
+
end
|
435
|
+
@i_ag = 'ag' + @i_name
|
436
|
+
@props = Hash.new
|
437
|
+
@props_def = Hash.new
|
438
|
+
@props_kinds = Hash.new
|
439
|
+
@persistent = Hash.new
|
440
|
+
@requires = Hash.new
|
441
|
+
properties
|
442
|
+
defaults(_object != nil )
|
443
|
+
if _object != nil
|
444
|
+
retrive_values
|
445
|
+
else
|
446
|
+
start_properties
|
447
|
+
end
|
448
|
+
self.register
|
449
|
+
end
|
450
|
+
|
451
|
+
def add_require(_require)
|
452
|
+
if @requires[_require] == nil
|
453
|
+
@requires[_require] = 1
|
454
|
+
else
|
455
|
+
@requires[_require] += 1
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
def del_require(_require)
|
460
|
+
@requires[_require] -= 1
|
461
|
+
if @requires[_require] == 0
|
462
|
+
@requires[_require] = nil
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
def select
|
467
|
+
_tobj = InspectorContract::TInspectorObj.new(self)
|
468
|
+
_tobj.wrapper = self
|
469
|
+
InspectorContract.instance.select(_tobj)
|
470
|
+
self
|
471
|
+
end
|
472
|
+
|
473
|
+
|
474
|
+
def activate
|
475
|
+
@@active = self
|
476
|
+
end
|
477
|
+
|
478
|
+
|
479
|
+
def build_sons
|
480
|
+
iv = @obj.instance_variables
|
481
|
+
if iv.length > 0
|
482
|
+
cod = " class << @obj"+"\n"
|
483
|
+
iv.each{|i|
|
484
|
+
i.delete!('@')
|
485
|
+
cod = cod + " attr_reader :"+i+"\n"
|
486
|
+
}
|
487
|
+
cod = cod +"end\n"
|
488
|
+
eval(cod)
|
489
|
+
end
|
490
|
+
iv_obj = Hash.new
|
491
|
+
iv.each{|i|
|
492
|
+
iv_obj[i] = eval("@obj."+i)
|
493
|
+
}
|
494
|
+
i_name = nil
|
495
|
+
self.sniffer.sons.each{|obj_son|
|
496
|
+
clazz = self.class.near_class_wrapper(obj_son)
|
497
|
+
if clazz != nil
|
498
|
+
iv_obj.each{|key, value|
|
499
|
+
if value == obj_son
|
500
|
+
i_name=key
|
501
|
+
end
|
502
|
+
}
|
503
|
+
if i_name == nil
|
504
|
+
clazz.new(self,obj_son)
|
505
|
+
else
|
506
|
+
clazz.new(self,obj_son){|_self| _self.i_name = i_name}
|
507
|
+
end
|
508
|
+
end
|
509
|
+
}
|
510
|
+
end
|
511
|
+
|
512
|
+
def register(_agobj=self)
|
513
|
+
@sons << _agobj if _agobj!=self && _agobj.ag_parent == self
|
514
|
+
if @ag_parent
|
515
|
+
return @ag_parent.register(_agobj)
|
516
|
+
else
|
517
|
+
WrapperContract.instance.wrapper_created(WrapperContract::TWrapperObj.new(self,'wrapper'=>_agobj))
|
518
|
+
#
|
519
|
+
# _tobj = InspectorActionContract::TInspectorActionObj.new(self)
|
520
|
+
# _tobj.wrapper = _agobj
|
521
|
+
# InspectorActionContract.instance.register(_tobj)
|
522
|
+
end
|
523
|
+
end
|
524
|
+
|
525
|
+
def has_sons
|
526
|
+
return (self.sons.length > 0)
|
527
|
+
end
|
528
|
+
|
529
|
+
def new_id
|
530
|
+
if !defined?(@@ag_id)
|
531
|
+
@@ag_id = Hash.new
|
532
|
+
end
|
533
|
+
if (@@ag_id[self.class]==nil)
|
534
|
+
@@ag_id[self.class] = 1
|
535
|
+
else
|
536
|
+
@@ag_id[self.class] = @@ag_id[self.class] + 1
|
537
|
+
end
|
538
|
+
return @@ag_id[self.class].to_s
|
539
|
+
end
|
540
|
+
|
541
|
+
def defaults_values
|
542
|
+
@@defaults_values
|
543
|
+
end
|
544
|
+
|
545
|
+
def defaults(_new=false)
|
546
|
+
if !defined?(@@defaults_values)
|
547
|
+
@@defaults_values = Hash.new
|
548
|
+
end
|
549
|
+
if (!defined?(@@defaults_values[self.class]))||(@@defaults_values[self.class] == nil)
|
550
|
+
@@defaults_values[self.class] = Hash.new
|
551
|
+
if _new
|
552
|
+
_obj = @obj_class.new
|
553
|
+
fill_defaults_value_from_agobj(_obj)
|
554
|
+
else
|
555
|
+
fill_defaults_value_from_agobj
|
556
|
+
end
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
def fill_defaults_value_from_agobj(_obj=nil)
|
561
|
+
#return if _obj == nil
|
562
|
+
_obj_save = @obj
|
563
|
+
if _obj
|
564
|
+
@obj = _obj
|
565
|
+
end
|
566
|
+
begin
|
567
|
+
@props.each{|_key,_family|
|
568
|
+
#Tk.messageBox('message'=>_key)
|
569
|
+
if @@defaults_values[self.class][_key] == nil
|
570
|
+
@@defaults_values[self.class][_key] = Hash.new
|
571
|
+
end
|
572
|
+
_family.each_value{|value|
|
573
|
+
if (value['name'] != nil) && @@defaults_values[self.class][_key][value['name']] == nil
|
574
|
+
if (value['default'] != nil)
|
575
|
+
@@defaults_values[self.class][_key][value['name']] = value['default']
|
576
|
+
elsif (value['get'] != nil)
|
577
|
+
@@defaults_values[self.class][_key][value['name']] = value['get'].call
|
578
|
+
end
|
579
|
+
end
|
580
|
+
}
|
581
|
+
}
|
582
|
+
ensure
|
583
|
+
if _obj
|
584
|
+
@obj = _obj_save
|
585
|
+
_obj.destroy
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
end
|
590
|
+
|
591
|
+
|
592
|
+
def delete
|
593
|
+
_tobj = InspectorContract::TInspectorObj.new(self)
|
594
|
+
_tobj.wrapper = self
|
595
|
+
InspectorContract.instance.delete_wrapper(_tobj)
|
596
|
+
end
|
597
|
+
|
598
|
+
def AG.class_wrapped
|
599
|
+
nil
|
600
|
+
end
|
601
|
+
|
602
|
+
def AG.class_renderer
|
603
|
+
AGRenderer
|
604
|
+
end
|
605
|
+
|
606
|
+
def AG.class_sniffer
|
607
|
+
AGSniffer
|
608
|
+
end
|
609
|
+
|
610
|
+
def AG.active
|
611
|
+
@@active
|
612
|
+
end
|
613
|
+
|
614
|
+
|
615
|
+
def getFileName
|
616
|
+
__FILE__
|
617
|
+
end
|
618
|
+
|
619
|
+
def AG.publish_property(_name, args = nil)
|
620
|
+
# class_eval(%Q[
|
621
|
+
# def #{_name}
|
622
|
+
# @#{_name}
|
623
|
+
# #{args('get').call}
|
624
|
+
# end
|
625
|
+
#
|
626
|
+
# def #{_name}=(value)
|
627
|
+
# @#{_name} = value
|
628
|
+
# #{args('set').call(value)}
|
629
|
+
# end
|
630
|
+
# ])
|
631
|
+
|
632
|
+
end
|
633
|
+
|
634
|
+
|
635
|
+
def new_object
|
636
|
+
if self.class.class_wrapped
|
637
|
+
@obj = self.class.class_wrapped.new
|
638
|
+
end
|
639
|
+
end
|
640
|
+
|
641
|
+
def AG.near_class_wrapped(_obj)
|
642
|
+
clazz = _obj.class
|
643
|
+
while (ArcadiaLibs.wrapper_class(clazz) == nil)&&(clazz!=nil)
|
644
|
+
clazz = clazz.superclass
|
645
|
+
end
|
646
|
+
return clazz
|
647
|
+
end
|
648
|
+
|
649
|
+
def AG.near_class_wrapper(_obj)
|
650
|
+
ArcadiaLibs.wrapper_class(self.near_class_wrapped(_obj))
|
651
|
+
end
|
652
|
+
|
653
|
+
|
654
|
+
def passed_object(_obj)
|
655
|
+
@obj = _obj
|
656
|
+
end
|
657
|
+
|
658
|
+
def start_properties
|
659
|
+
@props.each_value{|family|
|
660
|
+
family.each_value{|value|
|
661
|
+
if value['start'] != nil
|
662
|
+
value['set'].call(value['start'])
|
663
|
+
end
|
664
|
+
}
|
665
|
+
}
|
666
|
+
end
|
667
|
+
|
668
|
+
def retrive_values
|
669
|
+
@props.each_value{|family|
|
670
|
+
family.each_value{|prop|
|
671
|
+
prop['value'] = prop['get'].call
|
672
|
+
}
|
673
|
+
}
|
674
|
+
end
|
675
|
+
|
676
|
+
def getViewClassName
|
677
|
+
return 'V',@i_name
|
678
|
+
end
|
679
|
+
|
680
|
+
def getControlClassName
|
681
|
+
return @i_name.capitalize
|
682
|
+
end
|
683
|
+
|
684
|
+
def getInstanceClass
|
685
|
+
return @i_name.capitalize
|
686
|
+
#return 'C',@i_name
|
687
|
+
end
|
688
|
+
|
689
|
+
def get_path_i_name
|
690
|
+
_return = @i_name
|
691
|
+
_agstart = self
|
692
|
+
while _agstart.ag_parent != nil
|
693
|
+
_return = _agstart.ag_parent.i_name,'.',_return
|
694
|
+
_agstart = _agstart.ag_parent
|
695
|
+
end
|
696
|
+
return _return
|
697
|
+
end
|
698
|
+
|
699
|
+
def get_implementation_new(_variable = false)
|
700
|
+
if (ag_parent == nil)|| _variable
|
701
|
+
result = '@',@i_name,' = ', getInstanceClass ,'.new(', '@',@ag_parent.i_name, ")\n"
|
702
|
+
end
|
703
|
+
result = result, self.class, '.new(', '@',@ag_parent.i_ag,", @",get_path_i_name,")"
|
704
|
+
end
|
705
|
+
|
706
|
+
def get_implementation_block
|
707
|
+
result = result, " @i_name = '", @i_name, "'\n"
|
708
|
+
result = result, " @i_ag = '", @i_ag, "'\n"
|
709
|
+
result = result, " @obj_class = '", getObjClass, "'\n"
|
710
|
+
end
|
711
|
+
|
712
|
+
def get_implementation_code
|
713
|
+
result = result, get_implementation_new, "{\n"
|
714
|
+
result = result, get_implementation_block
|
715
|
+
@requires.each_key do |key|
|
716
|
+
result = result," @object_inspector.addRequire('#{key}')\n"
|
717
|
+
end
|
718
|
+
|
719
|
+
result = result,"}"
|
720
|
+
end
|
721
|
+
|
722
|
+
|
723
|
+
def getObjClass
|
724
|
+
if defined? @obj_class
|
725
|
+
return @obj_class
|
726
|
+
else
|
727
|
+
return @obj.class
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
def publish_def(_family, args = nil)
|
732
|
+
@props_def[_family]=args
|
733
|
+
end
|
734
|
+
|
735
|
+
# def AG.publish_def(_family, args = nil)
|
736
|
+
# @@props_def = Hash.new if !defined?(@@props_def)
|
737
|
+
# @@props_def[_family]=args
|
738
|
+
# end
|
739
|
+
|
740
|
+
|
741
|
+
def publish(_family, args = nil)
|
742
|
+
if @props[_family] == nil
|
743
|
+
@props[_family] = Hash.new
|
744
|
+
end
|
745
|
+
@props[_family][args['name']]=args
|
746
|
+
args['kind'] != nil ? kind = args['kind']:kind = 'default'
|
747
|
+
if @props_kinds[_family] == nil
|
748
|
+
@props_kinds[_family] = Hash.new
|
749
|
+
end
|
750
|
+
if @props_kinds[_family][kind] == nil
|
751
|
+
@props_kinds[_family][kind] = Array.new
|
752
|
+
end
|
753
|
+
@props_kinds[_family][kind] << args['name']
|
754
|
+
end
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
# def AG.publish(_family, args = nil)
|
760
|
+
# @@props = Hash.new if !defined?(@@props)
|
761
|
+
# if @@props[_family] == nil
|
762
|
+
# @@props[_family] = Hash.new
|
763
|
+
# end
|
764
|
+
# @@props[_family][args['name']]=args
|
765
|
+
# args['kind'] != nil ? kind = args['kind']:kind = 'default'
|
766
|
+
# @@props_kinds = Hash.new if !defined?(@props_kinds)
|
767
|
+
# if @@props_kinds[_family] == nil
|
768
|
+
# @@props_kinds[_family] = Hash.new
|
769
|
+
# end
|
770
|
+
# if @@props_kinds[_family][kind] == nil
|
771
|
+
# @@props_kinds[_family][kind] = Array.new
|
772
|
+
# end
|
773
|
+
# @@props_kinds[_family][kind] << args['name']
|
774
|
+
# end
|
775
|
+
|
776
|
+
|
777
|
+
def publish_mod(_family, args = nil)
|
778
|
+
args.each do |key, value|
|
779
|
+
@props[_family][args['name']]["#{key}"] = value
|
780
|
+
end
|
781
|
+
end
|
782
|
+
|
783
|
+
# def AG.publish_mod(_family, args = nil)
|
784
|
+
# args.each do |key, value|
|
785
|
+
# @@props[_family][args['name']]["#{key}"] = value if !defined?(@@props)
|
786
|
+
# end
|
787
|
+
# end
|
788
|
+
|
789
|
+
|
790
|
+
def publish_del(_family, _name=nil)
|
791
|
+
if _name == nil
|
792
|
+
@props.delete(_family)
|
793
|
+
else
|
794
|
+
@props[_family].delete(_name)
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
798
|
+
# def AG.publish_del(_family, _name=nil)
|
799
|
+
# if _name == nil
|
800
|
+
# @@props.delete(_family)
|
801
|
+
# else
|
802
|
+
# @@props[_family].delete(_name)
|
803
|
+
# end
|
804
|
+
# end
|
805
|
+
|
806
|
+
def properties
|
807
|
+
publish( 'property',
|
808
|
+
'name' => 'name',
|
809
|
+
'get'=> proc{@i_name},
|
810
|
+
'set'=> proc{|n| self.i_name = n},
|
811
|
+
'def'=> 'nodef'
|
812
|
+
)
|
813
|
+
end
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
# def delete
|
818
|
+
# @obj.destroy
|
819
|
+
# end
|
820
|
+
|
821
|
+
# def setp(_family, _name, _value)
|
822
|
+
# @props[_family][_name]['set'].call(_value)
|
823
|
+
# tobj = InspectorActionContract::TInspectorActionObj.new(self)
|
824
|
+
# tobj.wrapper = self
|
825
|
+
# tobj.property_family = _family
|
826
|
+
# tobj.property_name = _name
|
827
|
+
# tobj.property_value = _value
|
828
|
+
# InspectorActionContract.instance.update_property(tobj)
|
829
|
+
# end
|
830
|
+
|
831
|
+
def update_property(_sender, _family,_name,_value)
|
832
|
+
old_value = @props[_family][_name]['get'].call(_value)
|
833
|
+
if old_value != _value
|
834
|
+
@props[_family][_name]['set'].call(_value)
|
835
|
+
end
|
836
|
+
WrapperContract.instance.property_updated(
|
837
|
+
WrapperContract::TWrapperObj.new(self,
|
838
|
+
'wrapper'=>self,
|
839
|
+
'property_name'=> _name,
|
840
|
+
'property_family'=>_family,
|
841
|
+
'property_old_value'=>old_value,
|
842
|
+
'property_new_value'=>_value
|
843
|
+
)
|
844
|
+
)
|
845
|
+
end
|
846
|
+
|
847
|
+
# def updatep(_family, prop, value, _call_from_inspector=false)
|
848
|
+
# @props[_family][prop]['set'].call(value)
|
849
|
+
# end
|
850
|
+
|
851
|
+
end
|
852
|
+
|