Module: Cheri::JRuby::Explorer

Defined in:
lib/cheri/jruby/explorer/common.rb,
lib/cheri/jruby/explorer/splash.rb,
lib/cheri/jruby/explorer/viewer.rb,
lib/cheri/jruby/explorer/dialogs.rb,
lib/cheri/jruby/explorer/dialogs-old.rb

Defined Under Namespace

Modules: DRbHelper, GBLViewer, InstanceListener, NavViewerConstants, ParentViewerInterface, ValueViewerInterface, ViewerInterface Classes: AboutDialog, ConnectionDialog, HtmlNameValueListViewer, HtmlTableViewer, HtmlViewer, NodeType, NodeTypeValue, SearchDialog, SplashScreen, TypeViewer, Viewer

Class Method Summary collapse

Class Method Details

.register_viewer(type, subtype, clazz) ⇒ Object

TODO: interface for registering sub* types - TypeViewer class does support it TODO: allow multiple viewer registrations for a type - user could switch via View menu or popup



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cheri/jruby/explorer/viewer.rb', line 35

def register_viewer(type,subtype,clazz)
  raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
  raise Cheri.new_type_error(clazz,Class) unless Class === clazz
  if subtype
    raise Cheri.new_type_error(subtype,Class,Symbol) unless Symbol === subtype || Class === subtype
  end
  if (tv = @viewers[type])
    if subtype
      sv = tv[subtype]
      if sv
        warn "replacing viewer for type #{type}/#{subtype} (#{sv.clazz}) with #{clazz}" if sv.clazz
        sv.clazz = clazz
      else
        tv[subtype] = TypeViewer.new(subtype,clazz)
      end
    else
      warn "replacing default viewer for type #{type} (#{tv.clazz}) with #{clazz}" if tv.clazz
      tv.clazz = clazz
    end
  else
    if subtype
      #warn "adding viewer for type #{type}/#{subtype} when no default viewer for #{type}"
      tv = TypeViewer.new(type,nil)
      tv[subtype] = TypeViewer.new(subtype,clazz)
      @viewers[type] = tv
    else
      @viewers[type] = TypeViewer.new(type,clazz)
    end      
  end
end

.viewer(type, subtype = nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cheri/jruby/explorer/viewer.rb', line 65

def viewer(type,subtype=nil)
  raise Cheri.new_type_error(type,Symbol,Class) unless Symbol === type || Class === type
  raise Cheri.new_type_error(subtype,Symbol,Class,String) unless subtype.nil? ||
      Symbol === subtype || Class === subtype || String === subtype
  unless (tv = @viewers[type])
    warn "no viewer found matching type: #{type} (#{subtype})"
    return
  end
  if subtype
    sv = tv[subtype]
    # TODO: silently return default?
    #warn "no viewer for subtype #{type}/#{subtype} - returning default for type" unless sv
    sv || tv
  else
    tv
  end
end