Class: Clevic::SwingTableIndex

Inherits:
Object
  • Object
show all
Includes:
TableIndex, Gather
Defined in:
lib/clevic/swing/swing_table_index.rb

Instance Attribute Summary collapse

Attributes included from TableIndex

#entity

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TableIndex

#<=>, #attribute, #dump, #errors, #field, #field_name, #field_value, #has_errors?, #inspect, #meta, #prev, #rc

Methods included from FieldValuer

#attribute_value, #attribute_value=, #display_value, #edit_value, #edit_value=, #find_related, #raw_value, #text_value=, #tooltip, valuer, #valuer, #writer

Constructor Details

#initialize(model, row, column) ⇒ SwingTableIndex

Returns a new instance of SwingTableIndex.



9
10
11
# File 'lib/clevic/swing/swing_table_index.rb', line 9

def initialize( model, row, column )
  @model, @row, @column = model, row.to_i, column.to_i
end

Instance Attribute Details

#modelObject

Returns the value of attribute model.



12
13
14
# File 'lib/clevic/swing/swing_table_index.rb', line 12

def model
  @model
end

Class Method Details

.invalidObject



19
20
21
# File 'lib/clevic/swing/swing_table_index.rb', line 19

def self.invalid
  new( nil, -1, -1 )
end

Instance Method Details

#choppy(*args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/clevic/swing/swing_table_index.rb', line 23

def choppy( *args, &block  )
  return self unless self.valid?
  copied = clone.gather( *args, &block )

  # TODO this is mostly shared with Qt

  # convert a column name to a column index
  unless copied.column.is_a?( Numeric )
    copied.column = model.field_column( copied.column )
  end

  # return an invalid index if it's out of bounds,
  # or the copied index if it's OK.
  if copied.row >= model.row_count || copied.column >= model.column_count
    self.class.invalid
  else
    copied
  end
end

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/clevic/swing/swing_table_index.rb', line 15

def valid?
  row != -1 && column != -1 && model != nil
end