Class: RubyRich

Inherits:
JRubyFX::Application
  • Object
show all
Defined in:
lib/ruby_rich/ruby_rich.rb

Overview

This is JRubyFX application.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.heightObject

Returns the value of attribute height.



39
40
41
# File 'lib/ruby_rich/ruby_rich.rb', line 39

def height
  @height
end

.launchedObject

Returns the value of attribute launched.



40
41
42
# File 'lib/ruby_rich/ruby_rich.rb', line 40

def launched
  @launched
end

.widthObject

Returns the value of attribute width.



38
39
40
# File 'lib/ruby_rich/ruby_rich.rb', line 38

def width
  @width
end

Class Method Details

.launch(width, height) ⇒ Object





111
112
113
114
115
116
# File 'lib/ruby_rich/ruby_rich.rb', line 111

def self.launch(width, height)
  RubyRich.launched = true
  RubyRich.width = width
  RubyRich.height = height
  super()
end

.launched?Boolean


Checks to see if DCFX was already launched. For some reason a JavaFX application can only be launched once.


Returns:

  • (Boolean)


103
104
105
# File 'lib/ruby_rich/ruby_rich.rb', line 103

def self.launched?
  (RubyRich.launched)? true : false
end

Instance Method Details

#start(stage) ⇒ Object





47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ruby_rich/ruby_rich.rb', line 47

def start(stage)
    
  # Create a Browser and BrowserView and embedd it in FX.  Use the default Browser
  # context.  Also create a javascript class for operating on this browser
  @browser = Browser.new
  browser_view = BrowserView.new(@browser)
  $js = Sol::Js.new(@browser)
  
  #--------------------------------------------------------------------------------------
  # User Interface
  #--------------------------------------------------------------------------------------
  
  with(stage, title: "Ruby Rich Client Interface - RubyRich") do
    Platform.set_implicit_exit(false)
    layout_scene(RubyRich.width, RubyRich.height, :oldlace) do
      pane = border_pane do
        top menu_bar 
        center browser_view
      end
    end
    set_on_close_request do
      stage.close
      # dispose of the browser and end the application
      $js.browser.dispose
    end
    show
  end
  
  #--------------------------------------------------------------------------------------
  # Load configuration file.  This loads all the Javascript scripts onto the embbeded
  # web browser
  #--------------------------------------------------------------------------------------

  f = Java::JavaIo.File.new("#{File.dirname(__FILE__)}/config.html")
  fil = f.toURI().toURL().toString()
  
  @browser.addLoadListener(
    Class.new(LoadAdapter) {
      def onFinishLoadingFrame(event)
        if (event.isMainFrame)
          # Wait for the browser to finish loading
          # Signal Sol that browser loading is done
          Sol.resource.signal
        end
      end
    }.new)
  
  @browser.loadURL(fil)

end