Class: ArcadiaDialogManager

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

Instance Method Summary collapse

Constructor Details

#initialize(_arcadia) ⇒ ArcadiaDialogManager

Returns a new instance of ArcadiaDialogManager.



2310
2311
2312
2313
# File 'lib/a-core.rb', line 2310

def initialize(_arcadia)
  @arcadia = _arcadia
  Arcadia.attach_listener(self, DialogEvent)
end

Instance Method Details

#on_dialog(_event) ⇒ Object



2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
# File 'lib/a-core.rb', line 2315

def on_dialog(_event)
  type = _event.type
  if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
    type = 'ok'
  end
  res_array = type.split('_')
  if _event.level.nil? || _event.level.length == 0
    icon = 'info'
  else
    icon = _event.level
  end
  tktype = type.gsub('_','').downcase
  
  if _event.msg && _event.msg.length > 500
    msg = _event.msg[0..500]+' ...'
  else
    msg = _event.msg
  end
  
  tkdialog =  Tk::BWidget::MessageDlg.new(
          'icon' => icon,
          'bg' => Arcadia.conf('background'),
          'fg' => Arcadia.conf('foreground'),
          'type' => tktype,
          'title' => _event.title, 
          'message' => msg)
          
  tkdialog.configure('font'=>'courier 6')        
  res = tkdialog.create
  if _event.level == 'error'
    if _event.exception != nil
      Arcadia.runtime_error(_event.exception, _event.title)
    else
      Arcadia.runtime_error_msg(_event.msg, _event.title)
    end
  end
  _event.add_result(self, 'value'=>res_array[res.to_i])
end

#on_dialog_old(_event) ⇒ Object



2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
# File 'lib/a-core.rb', line 2355

def on_dialog_old(_event)
  type = _event.type
  if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
    type = 'ok'
  end
  icon = _event.level
  tktype = type.gsub('_','').downcase
  
  res =  Tk.messageBox(
          'icon' => icon,
          'type' => tktype,
          'title' => _event.title, 
          'message' => _event.msg)
  _event.add_result(self, 'value'=>res)
end