Class: Watobo::Gui::DefineScopeFrame
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::DefineScopeFrame
- Defined in:
- lib/watobo/gui/define_scope_frame.rb
Instance Method Summary collapse
- #editSiteDetails(site) ⇒ Object
- #getScope ⇒ Object
-
#initialize(owner, opts) ⇒ DefineScopeFrame
constructor
A new instance of DefineScopeFrame.
- #onDeselectAll(sender, sel, item) ⇒ Object
- #onSelectAll(sender, sel, item) ⇒ Object
- #setScope(scope) ⇒ Object
- #updateFrame ⇒ Object
Constructor Details
#initialize(owner, opts) ⇒ DefineScopeFrame
Returns a new instance of DefineScopeFrame.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 256 def initialize(owner, opts) super(owner, :opts => opts, :padding => 0) # @scope = Hash.new # @scope = YAML.load(YAML.dump(scope)) if scope.is_a? Hash @scope = YAML.load(Watobo::Scope.to_yaml) @cb_sites = Hash.new @edit_btns = Hash.new title = FXLabel.new(self, "Target Scope") info_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|FRAME_GROOVE) title.setFont(FXFont.new(getApp(), "helvetica", 12, FONTWEIGHT_BOLD, FONTSLANT_ITALIC, FONTENCODING_DEFAULT)) scope_text =<<'EOF' The target scopes affects primarly the behaviour all WATOBO scanner tools. Click the appropriate edit-button for more detailed settings. EOF btn = FXButton.new(info_frame, scope_text, :opts => LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT, :height => 90) #btn.font = @font #btn.backColor = FXColor::White btn.justify = JUSTIFY_LEFT quickSelectFrame = FXHorizontalFrame.new(self, LAYOUT_FILL_X) @sel_all_btn = FXButton.new(quickSelectFrame, "Select All", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X) @sel_all_btn.connect(SEL_COMMAND, method(:onSelectAll)) @sel_all_btn.setFocus() @sel_all_btn.setDefault() @desel_all_btn = FXButton.new(quickSelectFrame, "Deselect All", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X) @desel_all_btn.connect(SEL_COMMAND, method(:onDeselectAll)) frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE, :padding => 0) sitesArea = FXScrollWindow.new(frame, SCROLLERS_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y) sitesFrame = FXVerticalFrame.new(sitesArea, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0) puts "list sites" sites = Watobo::Chats.sites() puts sites.length sites.sort.each do |site| puts site site_frame = FXHorizontalFrame.new(sitesFrame, :opts => LAYOUT_FILL_X) b = FXCheckButton.new(site_frame, site, nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT) eb = FXButton.new(site_frame, "edit..", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT) @edit_btns[site] = eb b.connect(SEL_COMMAND){ b.checked? ? @edit_btns[site].enable : @edit_btns[site].disable @scope[site][:enabled] = true } @cb_sites[site] = b b.setCheck(false) scope_details = { :site => site, :enabled => false, :root_path => '', :excluded_paths => [], #:exclude_pattern => [] } if !@scope[site] @scope[site] = scope_details else @scope[site][:enabled] = true end eb.connect(SEL_COMMAND){ editSiteDetails(site) } end updateFrame() end |
Instance Method Details
#editSiteDetails(site) ⇒ Object
221 222 223 224 225 226 227 228 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 221 def editSiteDetails(site) dlg = EditScopeDetailsDialog.new(self, @scope[site]) if dlg.execute != 0 @scope[site].update dlg.details puts dlg.details.to_yaml end end |
#getScope ⇒ Object
230 231 232 233 234 235 236 237 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 230 def getScope() scope = Hash.new @cb_sites.keys.each do |site| @scope.delete(site) if !@cb_sites[site].checked? # scope[site] = @scope[site] if @cb_sites[site].checked? end return @scope end |
#onDeselectAll(sender, sel, item) ⇒ Object
201 202 203 204 205 206 207 208 209 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 201 def onDeselectAll(sender, sel, item) @scope.each do |site, val| @cb_sites[site].setCheck(false) @edit_btns[site].disable end @sel_all_btn.setFocus() @sel_all_btn.setDefault() end |
#onSelectAll(sender, sel, item) ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 211 def onSelectAll(sender, sel, item) sites = [] @scope.each do |site, scope| @cb_sites[site].setCheck(true) @edit_btns[site].enable end @desel_all_btn.setFocus() @desel_all_btn.setDefault() end |
#setScope(scope) ⇒ Object
248 249 250 251 252 253 254 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 248 def setScope(scope) @scope = scope Watobo::Scope.each do |site, scope_def| @scope[site].update @scope[site] if !@scope[site].nil? end updateFrame() end |
#updateFrame ⇒ Object
239 240 241 242 243 244 245 246 |
# File 'lib/watobo/gui/define_scope_frame.rb', line 239 def updateFrame() @scope.each do |site, scope| next if @cb_sites[site].nil? @cb_sites[site].setCheck(scope[:enabled]) @cb_sites[site].checked? ? @edit_btns[site].enable : @edit_btns[site].disable end end |