Class: Watobo::Gui::RulesTable

Inherits:
FXTable
  • Object
show all
Defined in:
lib/watobo/gui/rewrite_rules_dialog.rb

Direct Known Subclasses

RequestRulesTable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, rules = [], opts = {}) ⇒ RulesTable

Returns a new instance of RulesTable.


211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 211

def initialize( owner, rules=[], opts={} )
  @event_dispatcher_listeners = Hash.new
  parms = { :opts => TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP,
    :padding => 2
  }
  parms.update opts

  super(owner, parms)
  
  self.extend Watobo::Subscriber
  self.setBackColor(FXRGB(255, 255, 255))
  self.setCellColor(0, 0, FXRGB(255, 255, 255))
  self.setCellColor(0, 1, FXRGB(255, 240, 240))
  self.setCellColor(1, 0, FXRGB(240, 255, 240))
  self.setCellColor(1, 1, FXRGB(240, 240, 255))

  @columns=Hash.new
  
  @rules = []
  @rules.concat rules
  
   add_column "Action", 50
  add_column "Location", 80
  add_column "Pattern", 80
  add_column "Content", 80
  add_column "Filter", 80

  init_columns
  
  @rules.each do |r|
    add_rule_row r
  end
  adjust_cell_width
  
  self.connect(SEL_SELECTED){|sender,sel,pos| 
             self.selectRow pos.row
           #  notify(:rule_selected, @rules[pos.row])
             }
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules


175
176
177
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 175

def rules
  @rules
end

Instance Method Details

#add_rule(rule) ⇒ Object


176
177
178
179
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 176

def add_rule(rule)
  @rules << rule
  add_rule_row(rule)
end

#current_ruleObject


181
182
183
184
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 181

def current_rule
  return nil if self.currentRow < 0
  return @rules[self.currentRow]
end

#delete_current_rowObject


205
206
207
208
209
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 205

def delete_current_row
  i = self.currentRow
  return false if i < 0
  delete_row_by_index i
end

#delete_row_by_index(index) ⇒ Object


186
187
188
189
190
191
192
193
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 186

def delete_row_by_index(index)
  return false if index < 0
  return false if index > self.numRows-1
  @rules.delete_at index
  self.clearItems
  reset_table
  true
end

#reset_tableObject


195
196
197
198
199
200
201
202
203
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 195

def reset_table
  init_columns
  
  @rules.each do |r|
    add_rule_row r
  end
  adjust_cell_width
  self.selectRow self.currentRow if self.currentRow >= 0
end