Class: Watobo::Gui::ChecksPolicyFrame
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::ChecksPolicyFrame
- Defined in:
- lib/watobo/gui/checks_policy_frame.rb
Instance Method Summary collapse
- #applyPolicy(policy = nil) ⇒ Object
- #getSelectedModules ⇒ Object
-
#initialize(parent, policy = nil) ⇒ ChecksPolicyFrame
constructor
A new instance of ChecksPolicyFrame.
-
#onPolicyChanged(sender, sel, item) ⇒ Object
attr :policy_name.
- #set_checks(elements, policy = {}) ⇒ Object
- #showInfo(check) ⇒ Object
- #showTree(elements) ⇒ Object
Constructor Details
#initialize(parent, policy = nil) ⇒ ChecksPolicyFrame
Returns a new instance of ChecksPolicyFrame.
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 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 84 def initialize(parent, policy=nil) # Invoke base class initialize function first super(parent, :opts => LAYOUT_FILL_X| LAYOUT_FILL_Y, :padding => 0) @checks = Watobo::ActiveModules.to_a #@checks = Watobo.active_checks =begin @policy_list = policy.is_a?(Hash) ? policy : default_policy(checks) # policy settings policy_frame = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP) policy_name = @policy_list[:default_policy] if @policy_list.has_key? :default_policy @current_policy = @policy_list[policy_name] if @policy_list.has_key? policy_name policy_count = ( @policy_list.is_a? Hash ) ? @policy_list.length : 0 @policyCombo = FXComboBox.new(policy_frame, policy_count, nil, 0, COMBOBOX_INSERT_LAST|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X) @policyCombo.numVisible = policy_count # @policyCombo.connect(SEL_COMMAND, method(:onPolicyChanged)) =end 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){ @tree.checkAll @tree.update } # @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){ @tree.uncheckAll @tree.update } tree_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE) @tree = CheckBoxTreeList.new(tree_frame) #if @policy_list # @policy_list.each do |pname, p| # next if pname.is_a? Symbol # @policyCombo.appendItem(pname, p) # end # # select policy # index = @policyCombo.findItem(policy_name) # if index >= 0 then # @policyCombo.setCurrentItem(index) # end #applyPolicy(@current_policy) #end #applyPolicy() set_checks @checks end |
Instance Method Details
#applyPolicy(policy = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 33 def applyPolicy(policy=nil) #return false if policy.nil? tree_elements = [] @checks.each do |check| status = true begin # status = policy[check.class.to_s] status = false rescue puts "unknown policy or unknown test [#{@policy}] - [#{check.class.to_s}" end a = { :name => "#{check.check_group}|#{check.check_name}", :enabled => status, :data => check } tree_elements.push a end showTree(tree_elements) end |
#getSelectedModules ⇒ Object
78 79 80 81 82 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 78 def getSelectedModules() sel = @tree.getCheckedData #sel.map { |i| p i.class } end |
#onPolicyChanged(sender, sel, item) ⇒ Object
attr :policy_name
27 28 29 30 31 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 27 def onPolicyChanged(sender, sel, item) @policy_name = @policyCombo.getItemText(@policyCombo.currentItem) policy = @policyCombo.getItemData(@policyCombo.currentItem) applyPolicy(policy) end |
#set_checks(elements, policy = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 55 def set_checks(elements, policy={}) tree_elements = [] @checks.each do |check| a = { :name => "#{check.check_group}|#{check.check_name}", :enabled => false, :data => check } puts a[:name] tree_elements.push a end showTree(tree_elements) end |
#showInfo(check) ⇒ Object
70 71 72 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 70 def showInfo(check) end |
#showTree(elements) ⇒ Object
74 75 76 |
# File 'lib/watobo/gui/checks_policy_frame.rb', line 74 def showTree(elements) @tree.elements = elements end |