Class: Redcar::ApplicationSWT::DialogAdapter
- Inherits:
-
Object
- Object
- Redcar::ApplicationSWT::DialogAdapter
- 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)
- - (Object) available_message_box_button_combos
- - (Object) available_message_box_types
- - (Object) buttons
- - (Object) input(title, message, initial_value, &block)
- - (Object) message_box(text, options)
- - (Object) open_directory(options)
- - (Object) open_file(options)
- - (Object) password_input(title, message)
- - (Object) popup_html(text, location, dimensions = nil)
- - (Object) popup_menu(menu, location)
- - (Object) popup_text(title, message, location, dimensions = nil)
- - (Object) save_file(options)
- - (Object) tool_tip(message, location)
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 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 MESSAGE_BOX_TYPES.keys end |
- (Object) buttons
61 62 63 |
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 61 def 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, , initial_value, &block) dialog = Dialogs::InputDialog.new( parent_shell, title, , :initial_text => initial_value) do |text| block ? block[text] : nil end code = dialog.open = (code == 0 ? :ok : :cancel) {: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 (text, ) styles = 0 styles = styles | MESSAGE_BOX_TYPES[[:type]] if [:type] if [:buttons] = MESSAGE_BOX_BUTTON_COMBOS[[:buttons]] .each {|b| styles = styles | BUTTONS[b] } end dialog = Swt::Widgets::MessageBox.new(parent_shell, styles) dialog.(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() directory_dialog() end |
- (Object) open_file(options)
4 5 6 |
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 4 def open_file() file_dialog(Swt::SWT::OPEN, ) 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, ) dialog = Dialogs::InputDialog.new(parent_shell, title, , :password => true) code = dialog.open = (code == 0 ? :ok : :cancel) {:button => , :value => dialog.value} end |
- (Object) popup_html(text, location, dimensions = nil)
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 |
- (Object) popup_menu(menu, location)
98 99 100 101 102 103 |
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 98 def (, location) window = Redcar.app.focussed_window = ApplicationSWT::Menu.new(window.controller, , nil, Swt::SWT::POP_UP) .move(*get_coordinates(location)) .show end |
- (Object) popup_text(title, message, location, dimensions = nil)
105 106 107 108 109 110 111 112 |
# File 'plugins/application_swt/lib/application_swt/dialog_adapter.rb', line 105 def popup_text(title, , location,dimensions=nil) if dimensions box = ApplicationSWT::ModelessDialog.new(title,,dimensions[0],dimensions[1]) else box = ApplicationSWT::ModelessDialog.new(title,) 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() file_dialog(Swt::SWT::SAVE, ) 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(, location) tool_tip = Swt::Widgets::ToolTip.new(parent_shell, Swt::SWT::ICON_INFORMATION) tool_tip.() tool_tip.set_location(*get_coordinates(location)) tool_tip.set_visible(true) end |