Class: Glimmer::SWT::FileDialogProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/swt/file_dialog_proxy.rb

Overview

Proxy for org.eclipse.swt.widgets.FileDialog

Automatically uses the current shell if one is open. Otherwise, it instantiates a new shell parent

Optionally takes a shell as an argument

Follows the Proxy Design Pattern

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::DEFAULT_STYLES, WidgetProxy::KEYWORD_ALIASES

Instance Attribute Summary

Attributes inherited from WidgetProxy

#drag_source_proxy, #drag_source_style, #drag_source_transfer, #drop_target_proxy, #drop_target_transfer, #parent_proxy, #swt_widget

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_observer, #async_exec, #can_add_observer?, #can_handle_drag_observation_request?, #can_handle_drop_observation_request?, #can_handle_observation_request?, #content, create, #dispose, #ensure_drag_source_proxy, #ensure_drop_target_proxy, #extract_args, #get_attribute, #handle_observation_request, #has_attribute?, #has_style?, #method_missing, #pack_same_size, #post_add_content, #post_initialize_child, #remove_observer, #respond_to?, #set_attribute, swt_widget_class_for, #sync_exec, underscored_widget_name, widget_exists?, #widget_property_listener_installers, widget_proxy_class

Methods included from Packages

included

Constructor Details

#initialize(*args, swt_widget: nil) ⇒ FileDialogProxy

Returns a new instance of FileDialogProxy.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/glimmer/swt/file_dialog_proxy.rb', line 41

def initialize(*args, swt_widget: nil)
  if swt_widget
    @swt_widget = swt_widget
  else
    style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
    if style_args.any?
      style_arg_start_index = args.index(style_args.first)
      style_arg_last_index = args.index(style_args.last)
      args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
    end
    if !args.first.is_a?(Shell)
      current_shell = DisplayProxy.instance.swt_display.shells.first
      args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
    end
    if args.first.is_a?(ShellProxy)
      args[0] = args[0].swt_widget
    end
    parent = args[0]
    @parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
    @swt_widget = FileDialog.new(*args)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy