Module: Kernel

Defined in:
lib/jrubyfx/controller.rb

Overview

Special methods for fxml loading

Constant Summary collapse

@@jrubyfx_res_dir =
{}
@@jrubyfx_fxml_res_cl =
nil

Instance Method Summary collapse

Instance Method Details

#fxml_root(value = nil, jar_value = nil, class_loader = nil) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/jrubyfx/controller.rb', line 30

def fxml_root(value=nil, jar_value=nil, class_loader = nil)
	@@jrubyfx_fxml_res_cl = class_loader if class_loader
  if value or jar_value
    @@jrubyfx_fxml_dir = (JRubyFX::Application.in_jar? and jar_value) ? jar_value : File.expand_path(value)
  else
    @@jrubyfx_fxml_dir
  end
end

#get_fxml_resource_class_loaderObject



45
46
47
# File 'lib/jrubyfx/controller.rb', line 45

def get_fxml_resource_class_loader
	@@jrubyfx_fxml_res_cl || JRuby.runtime.jruby_class_loader.method("get_resource")
end

#resource_root(res_name, value = nil, jar_value = nil) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/jrubyfx/controller.rb', line 38

def resource_root(res_name, value=nil, jar_value=nil)
  if value or jar_value
    @@jrubyfx_res_dir[res_name.to_sym] = (JRubyFX::Application.in_jar? and jar_value) ? jar_value : File.expand_path(value)
  else
    @@jrubyfx_res_dir[res_name.to_sym]
  end
end

#resource_url(type, relative_path) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/jrubyfx/controller.rb', line 48

def resource_url(type, relative_path)
  if JRubyFX::Application.in_jar?
    get_fxml_resource_class_loader.call("#{resource_root(type)}/#{relative_path}")
  else
    java.net.URL.new("file:" + File.join(resource_root(type), relative_path))
  end
end