Class: UU::OS::GVC::Dialog

Inherits:
Object
  • Object
show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb

Overview

Component for generating URIs for opening dialog windows.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Dialog) initialize(use_case_uri, window_parameters = nil)

Creates a new instance of Dialog which can be used for opening a dialog. The Dialog is then typically converted to a UES-URI by using #to_uri method.

Examples:

# modify button so that it opens uc_uri in a dialog window with size
# 400x300px and executes 'dialogClosed' event after the dialog closes
button.action_uri = UU::OS::GVC::Dialog.new(uc_uri, {
  :width => 400,
  :height => 300,
  :callbackAction => 'dialogClosed'
}).to_uri
# init dialog
dialog = UU::OS::GVC::Dialog.new('ues:TER:ART:?VENDOR.APP/PKG/UC&param=value')
dialog.width = 400
dialog.height = 300
dialog.callback_action = 'dialogClosed'
view.navigation.action = dialog.to_uri

Parameters:

  • use_case_uri (String, UU::OS::UESURI)

    The UES-URI to be opened in the dialog window.

  • window_parameters (Hash) (defaults to: nil)

    The dialog window parameters:

    • width - the width of the dialog

    • height - the height of the dialog. If not given, the dialog will size itself automatically.

    • callbackAction - the VUC action code to trigger in main window (from which the dialog was opened)

      after the dialog gets closed


49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 49

def initialize(use_case_uri, window_parameters = nil)
  @use_case_uri = use_case_uri
  if !window_parameters.nil? && window_parameters.kind_of?(Hash)
    window_parameters.entries.each do |attribute|
      field_setter = get_setter(attribute[0])
      begin
        self.send(field_setter, attribute[1])
      rescue Exception => e
        raise e
      end
    end
  end
end

Instance Attribute Details

- (Object) callback_action

The VUC action to trigger after the dialog is closed.



21
22
23
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 21

def callback_action
  @callback_action
end

- (Object) height

The height of the dialog.



18
19
20
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 18

def height
  @height
end

- (Object) use_case_uri

The use case to show in the dialog.



12
13
14
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 12

def use_case_uri
  @use_case_uri
end

- (Object) width

The width of the dialog.



15
16
17
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 15

def width
  @width
end

Instance Method Details

- (String) to_s

Returns dialog as a String.

Returns:

  • (String)

    Dialog as String.



66
67
68
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 66

def to_s
  to_uri
end

- (String) to_uri

Returns dialog as a URI.

dialog = UU::OS::GVC::Dialog.new(uc_uri, { :width => 400 })
button.action_uri = dialog.to_uri

Returns:

  • (String)

    Data as String.



76
77
78
79
80
81
82
83
84
85
86
87
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/dialog.rb', line 76

def to_uri
  win_params = {
    :target => "DIALOG_WINDOW"
  }
  if !@width.nil? then win_params[:width] = @width; end
  if !@height.nil? then win_params[:height] = @height; end
  if !@callback_action.nil? then win_params[:callbackAction] = @callback_action; end

  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(@use_case_uri)
  uri_builder = uri_builder.add_parameter('windowParameters', win_params.to_json)
  uri_builder.to_uesuri
end