Module: Rubeus::Extensions::Javax::Swing::Table::DefaultTableModel

Defined in:
lib/rubeus/extensions/javax/swing/table/default_table_model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#readonlyObject

Returns the value of attribute readonly.



57
58
59
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 57

def readonly
  @readonly
end

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 6

def self.included(base)
  base.module_eval do
    alias_method :add_row_without_rubeus, :add_row
    alias_method :add_row, :add_row_with_rubeus
    alias_method :insert_row_without_rubeus, :insert_row
    alias_method :insert_row, :insert_row_with_rubeus
  end
  base.extend(ClassMethods)
  base.instance_eval do
    alias :new_without_rubeus :new
    alias :new :new_with_rubeus
  end
end

Instance Method Details

#add_row_with_rubeus(row) ⇒ Object



67
68
69
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 67

def add_row_with_rubeus(row)
  add_row_without_rubeus(vectorize_if_array(row))
end

#insert_row_with_rubeus(index, row) ⇒ Object



71
72
73
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 71

def insert_row_with_rubeus(index, row)
  insert_row_without_rubeus(index, vectorize_if_array(row))
end

#isCellEditable(row, col) ⇒ Object



59
60
61
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 59

def isCellEditable(row, col)
  !readonly
end

#load_from_xml(rexml_doc, options = {:refresh_columns => false}) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 75

def load_from_xml(rexml_doc, options = {:refresh_columns => false})
  row_path = options[:row_path]
  col_paths = options[:column_paths]
  if row_path.nil?
    raise ArgumentError, "require :row_path but options was #{options}"
  end
  unless col_paths
    rexml_doc.elements.each(row_path) do |row|
      col_paths = row.elements.map{|prop| prop.name}
      break
    end
  end
  if options[:refresh_columns]
    self.column_count = 0
    (options[:column_names] || col_paths).each{|col_name| add_column(col_name)}
  end
  self.row_count = 0
  rexml_doc.elements.each(row_path) do |row|
    values = col_paths.map do |col_path|
      element = row.elements[col_path]
      element ? element.text :
        options[:ignore_unexist_column] ? nil :
          (raise ArgumentError, "column  '#{col_path}' not found.")
    end
    add_row(values)
  end
end

#vectorize_if_array(value) ⇒ Object



63
64
65
# File 'lib/rubeus/extensions/javax/swing/table/default_table_model.rb', line 63

def vectorize_if_array(value)
  self.class.vectorize_if_array(value)
end