Class: Watobo::Gui::FilterTable

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

Direct Known Subclasses

RequestFilterTable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, filters = [], opts = {}) ⇒ FilterTable

Returns a new instance of FilterTable.



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 189

def initialize( owner, filters=[], 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
  
  @filters = []
  @filters.concat filters

  add_column "Location", 80
  add_column "Match", 80
  add_column "Pattern", 80
   add_column "Flags", 80


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

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



158
159
160
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 158

def filters
  @filters
end

Instance Method Details

#add_filter(filter) ⇒ Object



159
160
161
162
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 159

def add_filter(filter)
  @filters << filter
  add_filter_row(filter)
end

#delete_current_rowObject



183
184
185
186
187
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 183

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

#delete_row_by_index(index) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 168

def delete_row_by_index(index)
  return false if index < 0
  return false if index > self.numRows-1
  @filters.delete_at index
  self.clearItems
   init_columns
  
  @filters.each do |r|
    add_filter_row r
  end
  adjust_cell_width
  self.selectRow self.currentRow if self.currentRow >= 0
  true
end

#get_current_filterObject



164
165
166
# File 'lib/watobo/gui/rewrite_filters_dialog.rb', line 164

def get_current_filter
  puts self.currentRow
end