Class: Glimmer::SWT::TableEditor

Inherits:
ControlEditor show all
Defined in:
lib/glimmer/swt/table_editor.rb

Overview

Emulates SWT’s native org.eclipse.swt.custom.TableEditor

Constant Summary

Constants inherited from ControlEditor

ControlEditor::ATTRIBUTES

Instance Attribute Summary

Attributes inherited from ControlEditor

#composite, #editor

Instance Method Summary collapse

Methods inherited from ControlEditor

#initialize

Constructor Details

This class inherits a constructor from Glimmer::SWT::ControlEditor

Instance Method Details

#cancel!Object



51
52
53
# File 'lib/glimmer/swt/table_editor.rb', line 51

def cancel!
  done!
end

#done!Object



59
60
61
62
# File 'lib/glimmer/swt/table_editor.rb', line 59

def done!
  @table_item.cell_dom_element(@table_column_index).html(@old_value) unless @old_value.nil?
  @old_value = nil
end

#editor=(editor_widget, table_item, table_column_index) ⇒ Object Also known as: set_editor, setEditor



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/glimmer/swt/table_editor.rb', line 30

def editor=(editor_widget, table_item, table_column_index)
  # TODO consider making editor not gain an ID or gain a separate set of IDs to avoid clashing with standard widget predictability of ID
  @table_item = table_item
  @table_column_index = table_column_index
  @editor_widget = editor_widget
  @old_value = table_item.cell_dom_element(table_column_index).html
  table_item.cell_dom_element(table_column_index).html('')
  editor_widget.render(custom_parent_dom_element: table_item.cell_dom_element(table_column_index))
  # TODO tweak the width perfectly so it doesn't expand the table cell
#         editor_widget.dom_element.css('width', 'calc(100% - 20px)')
  editor_widget.dom_element.css('width', "#{minimumWidth}%") # TODO implement property with pixels (and perhaps derive percentage separately from pixels)
  editor_widget.dom_element.css('height', "#{minimumHeight}px")
  editor_widget.dom_element.add_class('table-editor')
  # TODO consider relying on autofocus instead
  editor_widget.dom_element.focus
  # TODO consider doing the following line only for :text editor
  editor_widget.dom_element.select
end

#save!Object



55
56
57
# File 'lib/glimmer/swt/table_editor.rb', line 55

def save!
  done!
end