Class: Watobo::Gui::ConversationFilterDialog

Inherits:
FXDialogBox
  • Object
show all
Includes:
Responder
Defined in:
lib/watobo/gui/conversation_table_ctrl2.rb

Overview

class ConversationFilterFrame < FXVerticalFrame

Instance Method Summary collapse

Constructor Details

#initialize(owner, filter) ⇒ ConversationFilterDialog

Returns a new instance of ConversationFilterDialog.


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/watobo/gui/conversation_table_ctrl2.rb', line 84

def initialize(owner, filter)
  super(owner, "Filter Settings", :opts => DECOR_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  
  main = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED )
  FXMAPFUNC(SEL_COMMAND, ID_ACCEPT, :onAccept)
  matrix = FXMatrix.new(main, 5, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y)
  f = FXVerticalFrame.new(matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  generell_gb = FXGroupBox.new(f, "Generell", FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  generell_frame = FXVerticalFrame.new(generell_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  @table_option_unique = FXCheckButton.new(generell_frame, "unique chats", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:unique) ? filter[:unique] : false
  @table_option_unique.setCheck(state)

  @table_option_scope = FXCheckButton.new(generell_frame, "scope only", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
 
  state = filter.has_key?(:scope_only) ? filter[:scope_only] : false
  @table_option_scope.setCheck(state)

  @table_option_hidetested_cb = FXCheckButton.new(generell_frame, "hide tested", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:hide_tested) ? filter[:hide_tested] : false
  @table_option_hidetested_cb.setCheck(state)        
  
  f = FXVerticalFrame.new(matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  mime_types_gb = FXGroupBox.new(f, "MIME Types", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  mime_types_frame = FXVerticalFrame.new(mime_types_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  
  
  
  @mime_html = FXCheckButton.new(mime_types_frame, "HTML", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:mime_types) ? filter[:mime_types].include?("html") : false 
  @mime_html.setCheck(state)
  
  @mime_css = FXCheckButton.new(mime_types_frame, "CSS", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:mime_types) ? filter[:mime_types].include?("css") : false
  @mime_css.setCheck(state)
  
  @mime_xml = FXCheckButton.new(mime_types_frame, "XML", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:mime_types) ? filter[:mime_types].include?("xml") : false
  @mime_xml.setCheck(state)
  
  @mime_script = FXCheckButton.new(mime_types_frame, "Script", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:mime_types) ? filter[:mime_types].include?("script") : false
  @mime_script.setCheck(state)
  
  @mime_flash = FXCheckButton.new(mime_types_frame, "Flash", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:mime_types) ? filter[:mime_types].include?("flash") : false
  @mime_flash.setCheck(state)
  
  f = FXVerticalFrame.new(matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  status_codes_gb = FXGroupBox.new(f, "Status Codes", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  status_codes_frame = FXVerticalFrame.new(status_codes_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  @status_2 = FXCheckButton.new(status_codes_frame, "2xx", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:status_codes) ? filter[:status_codes].include?("^2") : false
  @status_2.setCheck(state)
  
  @status_3 = FXCheckButton.new(status_codes_frame, "3xx", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:status_codes) ? filter[:status_codes].include?("^3") : false
  @status_3.setCheck(state)
  @status_4 = FXCheckButton.new(status_codes_frame, "4xx", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:status_codes) ? filter[:status_codes].include?("^4") : false
  @status_4.setCheck(state)
  @status_5 = FXCheckButton.new(status_codes_frame, "5xx", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:status_codes) ? filter[:status_codes].include?("^5") : false
  @status_5.setCheck(state)
  
  
  f = FXVerticalFrame.new(matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  extension_gb = FXGroupBox.new(f, "Extensions", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  extension_frame = FXVerticalFrame.new(extension_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  extension_matrix = FXMatrix.new(extension_frame, 2, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @show_extensions_cb = FXCheckButton.new(extension_matrix, "Show only: ", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:show_extensions) ? filter[:show_extensions] : false
  @show_extensions_cb.setCheck(state)  
  @show_only_ex = FXTextField.new(extension_matrix, 25, nil, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X)        
  @show_only_ex.text = filter.has_key?(:show_extension_patterns) ? filter[:show_extension_patterns].join(", ") : "jsp, php, asp, aspx"
  
  @hide_ex_cb = FXCheckButton.new(extension_matrix, "Hide: ", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = filter.has_key?(:hidden_extensions) ? filter[:hidden_extensions] : false
 # @show_extensions_cb.setCheck(state)  
  @hide_ex_cb.setCheck(state)
  f = FXVerticalFrame.new(extension_matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_THICK|FRAME_SUNKEN, :padding => 0)  
  @hide_ex =  FXText.new(f, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP)
  @hide_ex.text = filter.has_key?(:hidden_extension_patterns) ? filter[:hidden_extension_patterns].join(", ") : "ppt, doc, xls, pptx, docx, xlsx, pdf, jpg, jpeg, ico, png, css, gif, js"
    
  # PATTERN
  f = FXVerticalFrame.new(matrix, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  pattern_gb = FXGroupBox.new(f, "Pattern", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  pattern_frame = FXVerticalFrame.new(pattern_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)

  
  @text_filter = FXTextField.new(pattern_frame, 40, nil, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X)
  
  [ :url_pattern, :request_pattern, :response_pattern ].each do |k|
    if filter.has_key? k
      @text_filter.text = filter[k] unless filter[k].empty?
    end
  end
  # filterOptionsFrame =FXHorizontalFrame.new(fbox, LAYOUT_FILL_X)
  @foption_url = FXCheckButton.new(pattern_frame, "URL", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = ( filter.has_key?(:url_pattern) and not filter[:url_pattern].empty? )
  @foption_url.setCheck(state)
 # @foption_url.connect(SEL_COMMAND){ update_text_filter }
  @foption_req = FXCheckButton.new(pattern_frame, "Request", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = ( filter.has_key?(:request_pattern) and not filter[:request_pattern].empty? )
  @foption_req.setCheck state
 # @foption_req .connect(SEL_COMMAND){ update_text_filter }
  @foption_res = FXCheckButton.new(pattern_frame, "Response", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  state = ( filter.has_key?(:response_pattern) and not filter[:response_pattern].empty? )
  @foption_res.setCheck state
 # @foption_res.connect(SEL_COMMAND){ update_text_filter }
   
 buttons = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
    accept = FXButton.new(buttons, "&Apply", nil, self, ID_ACCEPT,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  accept.enable
  # Cancel
  FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  
end

Instance Method Details

#filter_settingsObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/watobo/gui/conversation_table_ctrl2.rb', line 32

def filter_settings
  fs = {
    :scope_only => @table_option_scope.checked?,         
    :hide_tested => @table_option_hidetested_cb.checked?,
    :unique => @table_option_unique.checked?
  }
  
  pattern = @text_filter.text
  unless pattern.empty?
    begin
      "test for valid regex".match(/#{pattern}/)
    rescue => bang
      pattern = Regexp.quote(@text_filter.text)
    end
  
  
  end
  fs[:url_pattern] = @foption_url.checked? ? pattern : ''
  fs[:request_pattern] = @foption_req.checked? ? pattern : ''
  fs[:response_pattern] = @foption_res.checked? ? pattern : ''
  
  mime_types = []
  mime_types << "html" if @mime_html.checked?
  mime_types << "css" if @mime_css.checked?
  mime_types << "flash" if @mime_flash.checked?
  mime_types << "script" if @mime_script.checked?
  mime_types << "xml" if @mime_xml.checked?  
  fs[:mime_types] = mime_types
  
  status_codes = []
  status_codes << "^2" if @status_2.checked?      
  status_codes << "^3" if @status_3.checked?
  status_codes << "^4" if @status_4.checked?
  status_codes << "^5" if @status_5.checked?
  fs[:status_codes] = status_codes
  
  hidden_extension_patterns = []
  hidden_extension_patterns.concat @hide_ex.text.split(",").map{|e| e.strip } 
#  hidden_extension_patterns.concat @hide_images_ex.text.split(",").map{|e| e.strip } if @hide_images.checked?
  fs[:hidden_extension_patterns] = hidden_extension_patterns
  fs[:hidden_extensions] = @hide_ex_cb.checked?
  
  show_extension_patterns = []
  show_extension_patterns.concat @show_only_ex.text.split(",").map{|e| e.strip } 
  fs[:show_extensions] = @show_extensions_cb.checked?
  fs[:show_extension_patterns] = show_extension_patterns
        
    
  fs
end