class ArcadiaProblemsShower

Public Class Methods

new(_arcadia) click to toggle source
# 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

Public Instance Methods

append_problem(e) click to toggle source
# 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 !@tree.exist?(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 !@tree.exist?(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_text() click to toggle source
# 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_gui() click to toggle source
# 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_value() click to toggle source
# File lib/a-core.rb, line 2586
def new_sequence_value
  @seq+=1
end
on_after_initialize(_event) click to toggle source
# 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) click to toggle source
# 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_problems() click to toggle source
# 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