Class: RSence::Plugins::GUIPlugin__

Inherits:
Plugin__
  • Object
show all
Includes:
Localization
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 included from Localization

#deep_merge_hash, #fill_strs_raw_path, #init_localized_strings, #init_strings, #localized_strings, #parse_strs_raw, #process_localized_strings, #read_localized_strings, #read_strings, #strings, #strings_params_search

Methods inherited from Plugin__

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

Methods included from PluginBase

#bundle_path, #file_exist?, #file_read, #file_write, #flush, #httime, #json_read, #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:



73
74
75
76
77
78
# File 'lib/rsence/plugins/gui_plugin.rb', line 73

def gui_params( msg )
  return unless @gui
  params = super
  params[:values] = @gui.values( get_ses( msg ) )
  params
end

#initnil

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

Returns:

  • (nil)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rsence/plugins/gui_plugin.rb', line 31

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)


234
235
236
237
# File 'lib/rsence/plugins/gui_plugin.rb', line 234

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