Class: RSence::Plugins::GUIPlugin__

Inherits:
Plugin__
  • Object
show all
Defined in:
lib/rsence/plugins/gui_plugin.rb

Overview

The CUIPlugin__ is actually available as GUIPlugin from plugin bundle code using the GUIPlugin class mimic method.

GUIPlugin extends Plugin by automatically initializing an GUIParser instance as @gui.

Read Plugin for usage of the API, Example GUIPlugin for an example of use and Plugin Bundles for overall information about plugin bundle usage.

  • It implements automatic dependency loading based on the dependencies item in the YAML gui declaration.

  • It inits the gui automatically.

User Interface -related hooks:

  • #init_ui – Extend to implement logic when the MainPlugin plugin has started the client. The GUIPlugin class extends this method to automatically load and initialize the user interface from a GUITree data structure defined in the gui/main.yaml document in the bundle directory.

  • #gui_params – Extend to define your own params for the gui data.

Instance Attribute Summary

Attributes inherited from Plugin__

#info, #name, #path

Instance Method Summary collapse

Methods inherited from Plugin__

#cloned_source, #cloned_target, #get_ses, #idle, #include_js, #init_ses, #name_with_manager_s, #read_js, #read_js_once, #restore_ses, #restore_ses_value, #values_js

Methods included from PluginBase

#bundle_path, #file_read, #file_write, #flush, #httime, #method_missing, #yaml_read, #yaml_write

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RSence::Plugins::PluginBase

Instance Method Details

#gui_params(msg) ⇒ Hash

Extend this method to return custom params to RSence::Plugins::GUIParser#init.

Called from #init_ui.

By default assigns the session values as :values to use for bind: :values.my_value_name in the YAML GUI file for client-side value bindings.

Examples:

To provide extra parameters, do this:

def gui_params( msg )
  params = super
  params[:extra] = {
    :foo => "Foo",       # use in the GUITree as :extra.foo
    :num => 124334,      # use in the GUITree as :extra.num
    :bar => {
      :barbar => "Bar"   # use in the GUITree as :extra.bar.barbar
    }
    :arr => [1,2,4,8]    # use in the GUITree as :extra.arr
  }
  params[:more] = "More" # use in the GUITree as :more
  return params
end

Parameters:

  • msg (Message)

    The message is supplied by the system.

Returns:



77
78
79
80
# File 'lib/rsence/plugins/gui_plugin.rb', line 77

def gui_params( msg )
  return unless @gui
  { :values => @gui.values( get_ses( msg ) ) }
end

#initnil

In addition to Plugin#init, also automatically initializes a RSence::Plugins::GUIParser instance as @gui

Returns:

  • (nil)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rsence/plugins/gui_plugin.rb', line 35

def init
  super
  yaml_src = false
  [ "#{@name}.yaml", 'gui.yaml',
    "gui/#{@name}.yaml", "gui/main.yaml"
  ].each do |yaml_name|
    yaml_src = file_read( yaml_name )
    break if yaml_src
  end
  if yaml_src
    @gui = GUIParser.new( self, yaml_src, @name )
  else
    @gui = nil
  end
  @client_pkgs = false
end

#init_ui(msg) ⇒ nil

Automatically inits the UI using RSence::Plugins::GUIParser#init

Parameters:

  • msg (Message)

    The message is supplied by the system.

Returns:

  • (nil)


151
152
153
154
# File 'lib/rsence/plugins/gui_plugin.rb', line 151

def init_ui( msg )
  return unless @gui
  @gui.init( msg, gui_params( msg ) )
end