Class: Redcar::ApplicationSWT::DialogAdapter

Inherits:
Object
  • Object
show all
Defined in:
plugins/application_swt/lib/application_swt/dialog_adapter.rb

Constant Summary

MESSAGE_BOX_TYPES =
{
  :info     => Swt::SWT::ICON_INFORMATION,
  :error    => Swt::SWT::ICON_ERROR,
  :question => Swt::SWT::ICON_QUESTION,
  :warning  => Swt::SWT::ICON_WARNING,
  :working  => Swt::SWT::ICON_WORKING
}
BUTTONS =
{
  :yes    => Swt::SWT::YES,
  :no     => Swt::SWT::NO,
  :cancel => Swt::SWT::CANCEL,
  :retry  => Swt::SWT::RETRY,
  :ok     => Swt::SWT::OK,
  :abort  => Swt::SWT::ABORT,
  :ignore => Swt::SWT::IGNORE
}
MESSAGE_BOX_BUTTON_COMBOS =
{
  :ok                 => [:ok],
  :ok_cancel          => [:ok, :cancel],
  :yes_no             => [:yes, :no],
  :yes_no_cancel      => [:yes, :no, :cancel],
  :retry_cancel       => [:retry, :cancel],
  :abort_retry_ignore => [:abort, :retry, :ignore]
}

Instance Method Summary (collapse)

Instance Method Details

- (Object) available_message_box_button_combos



69
70
71
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 69

def available_message_box_button_combos
  MESSAGE_BOX_BUTTON_COMBOS.keys
end

- (Object) available_message_box_types



65
66
67
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 65

def available_message_box_types
  MESSAGE_BOX_TYPES.keys
end

- (Object) buttons



61
62
63
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 61

def buttons
  BUTTONS.keys
end

- (Object) input(title, message, initial_value, &block)



73
74
75
76
77
78
79
80
81
82
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 73

def input(title, message, initial_value, &block)
  dialog = Dialogs::InputDialog.new(
             parent_shell,
             title, message, :initial_text => initial_value) do |text|
    block ? block[text] : nil
  end
  code = dialog.open
  button = (code == 0 ? :ok : :cancel)
  {:button => button, :value => dialog.value}
end

- (Object) message_box(text, options)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 43

def message_box(text, options)
  styles = 0
  styles = styles | MESSAGE_BOX_TYPES[options[:type]] if options[:type]
  if options[:buttons]
    buttons = MESSAGE_BOX_BUTTON_COMBOS[options[:buttons]]
    buttons.each {|b| styles = styles | BUTTONS[b] }
  end
  dialog = Swt::Widgets::MessageBox.new(parent_shell, styles)
  dialog.set_message(text)
  result = nil
  Redcar.app.protect_application_focus do
    EditView.protect_edit_view_focus do
      result = dialog.open
    end
  end
  BUTTONS.invert[result]
end

- (Object) open_directory(options)



8
9
10
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 8

def open_directory(options)
  directory_dialog(options)
end

- (Object) open_file(options)



4
5
6
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 4

def open_file(options)
  file_dialog(Swt::SWT::OPEN, options)
end

- (Object) password_input(title, message)



84
85
86
87
88
89
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 84

def password_input(title, message)
  dialog = Dialogs::InputDialog.new(parent_shell, title, message, :password => true)
  code = dialog.open
  button = (code == 0 ? :ok : :cancel)
  {:button => button, :value => dialog.value}
end


114
115
116
117
118
119
120
121
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 114

def popup_html(text,location,dimensions=nil)
  if dimensions
    box = ApplicationSWT::ModelessHtmlDialog.new(text,dimensions[0],dimensions[1])
  else
    box = ApplicationSWT::ModelessHtmlDialog.new(text)
  end
  box.open(parent_shell,*get_coordinates(location))
end


98
99
100
101
102
103
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 98

def popup_menu(menu, location)
  window = Redcar.app.focussed_window
  menu   = ApplicationSWT::Menu.new(window.controller, menu, nil, Swt::SWT::POP_UP)
  menu.move(*get_coordinates(location))
  menu.show
end


105
106
107
108
109
110
111
112
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 105

def popup_text(title, message, location,dimensions=nil)
  if dimensions
    box = ApplicationSWT::ModelessDialog.new(title,message,dimensions[0],dimensions[1])
  else
    box = ApplicationSWT::ModelessDialog.new(title,message)
  end
  box.open(parent_shell,*get_coordinates(location))
end

- (Object) save_file(options)



12
13
14
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 12

def save_file(options)
  file_dialog(Swt::SWT::SAVE, options)
end

- (Object) tool_tip(message, location)



91
92
93
94
95
96
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 91

def tool_tip(message, location)
  tool_tip = Swt::Widgets::ToolTip.new(parent_shell, Swt::SWT::ICON_INFORMATION)
  tool_tip.set_message(message)
  tool_tip.set_location(*get_coordinates(location))
  tool_tip.set_visible(true)
end