Class: ArcadiaExtPlus
Instance Attribute Summary collapse
Attributes inherited from ArcadiaExt
#arcadia, #name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ArcadiaExt
#add_to_conf_property, #array_conf, #conf, #conf_array, #conf_default, #del_from_conf_property, #destroy_frame, #exec, #float_frame, #frame_def_visible?, #frame_domain, #frame_domain_default, #frame_raised?, #frame_title, #frame_visible?, #hide_frame, #hinner_dialog, #hinner_splitted_dialog, #hinner_splitted_dialog_titled, #maximize, #maximized?, #resize, #restore_default_conf
Constructor Details
#initialize(_arcadia, _name = nil) ⇒ ArcadiaExtPlus
Returns a new instance of ArcadiaExtPlus.
430
431
432
433
434
435
436
437
438
439
440
|
# File 'lib/a-commons.rb', line 430
def initialize(_arcadia, _name=nil)
@@instances = {} if !defined?(@@instances)
@@main_instance = {} if !defined?(@@main_instance)
@@active_instance = {} if !defined?(@@active_instance)
@@instances[self.class] = [] if @@instances[self.class] == nil
@@instances[self.class] << self
@@main_instance[self.class] = self if @@main_instance[self.class] == nil
Arcadia.attach_listener(self, ActivateInstanceEvent)
super(_arcadia, _name)
@@active_instance[self.class] = self if @@active_instance[self.class] == nil
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
428
429
430
|
# File 'lib/a-commons.rb', line 428
def index
@index
end
|
Class Method Details
.instances(_class) ⇒ Object
468
469
470
|
# File 'lib/a-commons.rb', line 468
def ArcadiaExtPlus.instances(_class)
@@instances[_class]
end
|
Instance Method Details
#activate(_obj = self, _raise_event = true) ⇒ Object
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
# File 'lib/a-commons.rb', line 484
def activate(_obj=self, _raise_event=true)
return if @@active_instance[_obj.class] == _obj
@@active_instance[_obj.class] = _obj _obj.frame.root.shift_on if _obj.frame_visible?
instances.each{|i|
i.frame.root.shift_off if i != _obj && i.frame != nil && i.frame.root != _obj.frame.root && i.frame_raised?
}
ActivateInstanceEvent.new(Arcadia.instance, 'name'=>_obj.name).go! if _raise_event
end
|
#activate_main ⇒ Object
499
500
501
|
# File 'lib/a-commons.rb', line 499
def activate_main
activate(@@main_instance[self.class])
end
|
#active? ⇒ Boolean
503
504
505
|
# File 'lib/a-commons.rb', line 503
def active?
@@active_instance[self.class] == self
end
|
#active_instance ⇒ Object
472
473
474
|
# File 'lib/a-commons.rb', line 472
def active_instance
@@active_instance[self.class]
end
|
#clean_instance ⇒ Object
def on_before_layout_raising_frame(_event)
if _event.extension_name == @name
activate
end
end
#clone(_name, _dom = nil) ⇒ Object
#deduplicate ⇒ Object
601
602
603
604
605
606
607
608
609
610
611
|
# File 'lib/a-commons.rb', line 601
def deduplicate
can_exit=true
if @confirm_on_exit && (Arcadia.dialog(self, 'type'=>'yes_no',
'msg'=>Arcadia.text('main.d.confirm_delete_ext_instance.msg', [@name]),
'title' => Arcadia.text('main.d.confirm_delete_ext_instance.title', [@name]),
'level' => 'question')=='yes')
exit_query_event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=>true))
can_exit = exit_query_event.can_exit
end
clean_instance if can_exit
end
|
#duplicate(_name = nil, _dom = nil, _confirm_on_exit = true) ⇒ Object
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
# File 'lib/a-commons.rb', line 535
def duplicate(_name=nil, _dom=nil, _confirm_on_exit=true)
_name = new_name if _name.nil?
@confirm_on_exit = _confirm_on_exit
Arcadia.conf_group_copy(@@main_instance[self.class].name, _name)
if !_dom.nil?
doms = Application.conf_array("#{_name}.frames")
doms[0] = _dom
Application.array_conf("#{_name}.frames", doms)
end
instance = clone(_name, _dom)
Arcadia.process_event(InitializeEvent.new(Arcadia.instance), [instance])
main_instance.add_to_conf_property("clones", _name)
instance
end
|
#exist_name?(_name) ⇒ Boolean
526
527
528
529
530
531
532
533
|
# File 'lib/a-commons.rb', line 526
def exist_name?(_name)
exist = false
instances.each{|i|
exist = exist || i.name == _name
break if exist
}
exist
end
|
#frame(_n = 0, create_if_not_exist = true) ⇒ Object
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
|
# File 'lib/a-commons.rb', line 442
def frame(_n=0,create_if_not_exist=true)
fr = super(_n, create_if_not_exist)
if fr != nil && !@frame_initialize && fr.domain != nil && fr.domain != ArcadiaLayout::HIDDEN_DOMAIN
@frame_initialize = true
fr.hinner_frame.bind_append("Enter", proc{activate})
if main_instance?
else
fr.root.add_state_button(
self.name,
'Destroy',
proc{deduplicate},
MINUS_EX_GIF,
'left')
activate(self, false)
end
end
fr
end
|
#instance_index ⇒ Object
511
512
513
|
# File 'lib/a-commons.rb', line 511
def instance_index
instances.index(self)
end
|
#instances ⇒ Object
507
508
509
|
# File 'lib/a-commons.rb', line 507
def instances
@@instances[self.class]
end
|
#main_instance ⇒ Object
476
477
478
|
# File 'lib/a-commons.rb', line 476
def main_instance
@@main_instance[self.class]
end
|
#main_instance? ⇒ Boolean
480
481
482
|
# File 'lib/a-commons.rb', line 480
def main_instance?
@@main_instance[self.class] == self
end
|
#new_name ⇒ Object
515
516
517
518
519
520
521
522
523
524
|
# File 'lib/a-commons.rb', line 515
def new_name
name = main_instance.name
i=0
while exist_name?(name)
i+=1
name = "#{main_instance.name}#{i}"
end
name
end
|
#on_destroy_instance(_event) ⇒ Object
563
564
565
566
567
568
569
|
# File 'lib/a-commons.rb', line 563
def on_destroy_instance(_event)
Arcadia.detach_listener(self)
@arcadia.unregister(self)
@frames.each_index{|i| destroy_frame(i)}
@frames.clear
end
|