Class: ArcadiaProblemsShower

Inherits:
Object
  • Object
show all
Defined in:
lib/a-core.rb

Instance Method Summary collapse

Constructor Details

#initialize(_arcadia) ⇒ ArcadiaProblemsShower

Returns a new instance of ArcadiaProblemsShower.



2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
# File 'lib/a-core.rb', line 2453

def initialize(_arcadia)
  @arcadia = _arcadia
  @showed = false
  @initialized = false
  #@visible = false
  @problems = Array.new
  @seq = 0
  @dmc=0
  @rec=0
  Arcadia.attach_listener(self, ArcadiaProblemEvent)
  Arcadia.attach_listener(self, InitializeEvent)
end

Instance Method Details

#append_problem(e) ⇒ Object



2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
# File 'lib/a-core.rb', line 2590

def append_problem(e)
#    parent_node='root'
  case e.type
  when ArcadiaProblemEvent::DEPENDENCE_MISSING_TYPE
#      parent_node='dependences_missing_node'
    text = Arcadia.text("main.ps.dependences_missing")
#      if [email protected]?(parent_node)
#        @tree.insert('end', 'root' ,parent_node, {
#          'text' =>  text ,
#          'helptext' => text,
#          'drawcross'=>'auto',
#          'deltax'=>-1,
#          'image'=> Arcadia.image_res(BROKEN_GIF)
#        }.update(Arcadia.style('treeitem'))
#        )
#
#      end
#      @dmc+=1
#      @tree.itemconfigure('dependences_missing_node','text'=>"#{text} (#{@dmc})" )

  when ArcadiaProblemEvent::RUNTIME_ERROR_TYPE
#      parent_node='runtime_error_node'
    text = Arcadia.text("main.ps.runtime_errors")
#      if [email protected]?(parent_node)
#        @tree.insert('end', 'root' ,parent_node, {
#          'text' =>  text ,
#          'helptext' => text,
#          'drawcross'=>'auto',
#          'deltax'=>-1,
#          'image'=> Arcadia.image_res(ERROR_GIF)
#        }.update(Arcadia.style('treeitem'))  #.update({'fill'=>Arcadia.conf('inactiveforeground')}))
#        )
#      end
#      @rec+=1
#      @tree.itemconfigure('runtime_error_node','text'=>"#{text} (#{@rec})" )
  end

  output_mark = Arcadia.console(self,'msg'=>"#{text} : ", 'level'=>'system_error', 'mark'=>output_mark)      

  title_node="node_#{new_sequence_value}"
  detail_node="detail_of_#{title_node}"

#    @tree.insert('end', parent_node ,title_node, {
#      'text' =>  e.title ,
#      'helptext' => e.title,
#      'drawcross'=>'auto',
#      'deltax'=>-1,
#      'image'=> Arcadia.image_res(ITEM_GIF)
#    }.update(Arcadia.style('treeitem'))  
#    )


  if e.detail.kind_of?(Array)
#      e.detail.each_with_index{|line,i|
#        @tree.insert('end', title_node , "#{detail_node}_#{i}" , {
#          'text' =>  line ,
#          'helptext' => i.to_s,
#          'drawcross'=>'auto',
#          'deltax'=>-1,
#          'image'=> Arcadia.image_res(ITEM_DETAIL_GIF)
#        }.update(Arcadia.style('treeitem'))  
#        )
#     }
  else
#      @tree.insert('end', title_node , detail_node , {
#        'text' =>  e.detail ,
#        'helptext' => e.title,
#        'drawcross'=>'auto',
#        'deltax'=>-1,
#        'image'=> Arcadia.image_res(ITEM_DETAIL_GIF)
#      }.update(Arcadia.style('treeitem'))  
#      )
  end

  output_mark = Arcadia.console(self,'msg'=>"#{e.title}\n> #{e.detail}", 'level'=>'system_error', 'mark'=>output_mark, 'append'=>true)      

end

#button_textObject



2515
2516
2517
# File 'lib/a-core.rb', line 2515

def button_text
  @problems.count > 1 ? Arcadia.text("main.ps.problems", [@problems.count]) : Arcadia.text("main.ps.problem", [@problems.count])
end

#initialize_guiObject



2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
# File 'lib/a-core.rb', line 2520

def initialize_gui
  # float_frame
#    args = {'width'=>600, 'height'=>300, 'x'=>400, 'y'=>100}
#    @ff = @arcadia.layout.add_float_frame(args).hide
#    @ff.title(Arcadia.text("main.ps.title"))
#
#    #tree
#    @tree = BWidgetTreePatched.new(@ff.frame, Arcadia.style('treepanel')){
#      showlines false
#      deltay 22
#    }
#    @tree.extend(TkScrollableWidget).show(0,0)
#
#    do_double_click = proc{
#      _selected = @tree.selected
#      _selected_text = @tree.itemcget(_selected, 'text')
#      if _selected_text
#        _file, _row, _other = _selected_text.split(':')
#        if File.exist?(_file)
#          begin
#            r = _row.strip.to_i
#            integer = true
#          rescue Exception => e
#            integer = false
#          end
#          if integer
#            OpenBufferTransientEvent.new(self,'file'=>_file, 'row'=>r).go!
#          end
#        end
#      end
#    }
#    @tree.textbind_append('Double-1',do_double_click)
#
#
#    # call button
#    command = proc{
#      if @ff.visible?
#        @ff.hide
#        #@visible = false
#      else
#        @ff.show
#        #@visible = true
#      end
#    }
#
#    b_style = Arcadia.style('toolbarbutton')
#    b_style["relief"]='groove'
#    #    b_style["borderwidth"]=2
#    b_style["highlightbackground"]='red'
#
#    b_text = button_text
#
#    @b_err = Tk::BWidget::Button.new(@arcadia['toolbar'].frame, b_style){
#      image  Arcadia.image_res(ALERT_GIF)
#      compound 'left'
#      padx  2
#      command command if command
#      #width 100
#      #height 20
#      #helptext  _hint if _hint
#      text b_text
#    }.pack('side' =>'left','before'=>@arcadia['toolbar'].items.values[0].item_obj, :padx=>2, :pady=>0)

end

#new_sequence_valueObject



2586
2587
2588
# File 'lib/a-core.rb', line 2586

def new_sequence_value
  @seq+=1
end

#on_after_initialize(_event) ⇒ Object



2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
# File 'lib/a-core.rb', line 2478

def on_after_initialize(_event)
  @initialized = true
  if @problems.count > 0
    show_problems
    Thread.new do
      num_sleep = 0
      while TkWinfo.viewable(Arcadia.layout.root) == false && num_sleep < 20
        sleep(1)
        num_sleep += 1
      end
      @ff.show
    end
#      p TkWinfo.viewable(Arcadia.layout.root)
#      Tk.after(1000, proc{@ff.show; p TkWinfo.viewable(Arcadia.layout.root)})
    
  end
end

#on_arcadia_problem(_event) ⇒ Object



2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
# File 'lib/a-core.rb', line 2466

def on_arcadia_problem(_event)
  @problems << _event
  if @initialized
    if !@showed
      show_problems
    else
      append_problem(_event)
      #@b_err.configure('text'=> button_text)
    end
  end
end

#show_problemsObject



2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
# File 'lib/a-core.rb', line 2496

def show_problems
  begin
    initialize_gui
    @problems.each{|e|
      append_problem(e)
    }
#      if @tree.exist?('dependences_missing_node')
#        @tree.open_tree('dependences_missing_node', true)
#      end
#      if @tree.exist?('runtime_error_node')
#        @tree.open_tree('runtime_error_node', true)
#      end
    @showed=true
  rescue RuntimeError => e
    Arcadia.detach_listener(self, ArcadiaProblemEvent)
    Arcadia.detach_listener(self, InitializeEvent)
  end
end